Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
blueprint = DNSRecords('route53_both_hosted_zone_id_and_name_error',
self.ctx)
blueprint.resolve_variables(
[
Variable(
"RecordSets",
[
{
"Name": "host.testdomain.com.",
"Type": "A",
"ResourceRecords": ["10.0.0.1"],
},
]
),
Variable("HostedZoneId", "fake_zone_id"),
Variable("HostedZoneName", "fake_zone_name"),
]
)
with self.assertRaises(ValueError):
blueprint.create_template()
def test_create_template_external_role(self):
blueprint = Function('test_aws_lambda_Function_external_role',
self.ctx)
blueprint.resolve_variables(
[
Variable(
"Code",
Code(S3Bucket="test_bucket", S3Key="code_key")
),
Variable("Description", "Test function."),
Variable("Environment", {"TEST_NAME": "test_value"}),
Variable("Runtime", "python2.7"),
Variable("Role", "my-fake-role"),
]
)
blueprint.create_template()
self.assertRenderedBlueprint(blueprint)
def test_create_template_with_alias_provided_version(self):
blueprint = Function(
'test_aws_lambda_Function_with_alias_provided_version',
self.ctx
)
blueprint.resolve_variables(
[
Variable(
"Code",
Code(S3Bucket="test_bucket", S3Key="code_key")
),
Variable("Description", "Test function."),
Variable("Environment", {"TEST_NAME": "test_value"}),
Variable("Runtime", "python2.7"),
Variable("AliasName", "prod"),
Variable("AliasVersion", "1")
]
)
blueprint.create_template()
self.assertRenderedBlueprint(blueprint)
self.ctx)
blueprint.resolve_variables(
[
Variable(
"RecordSets",
[
{
"Name": "host.testdomain.com.",
"Type": "A",
"AliasTarget": {
"DNSName": "s3-website-us-east-1.amazonaws.com", # noqa
},
},
]
),
Variable("HostedZoneId", "fake_zone_id"),
]
)
record_sets = blueprint.create_template()
self.assertEqual(
record_sets[0].AliasTarget.HostedZoneId, "Z3AQBSTGFYJSTF"
)
def test_create_template_with_alias_partial_name(self):
blueprint = Function(
'test_aws_lambda_Function_with_alias_partial_name',
self.ctx
)
blueprint.resolve_variables(
[
Variable(
"Code",
Code(S3Bucket="test_bucket", S3Key="code_key")
),
Variable("Description", "Test function."),
Variable("Environment", {"TEST_NAME": "test_value"}),
Variable("Runtime", "python2.7"),
Variable("AliasName", "prod"),
]
)
blueprint.create_template()
self.assertRenderedBlueprint(blueprint)
def test_create_template_external_role(self):
blueprint = Function('test_aws_lambda_Function_external_role',
self.ctx)
blueprint.resolve_variables(
[
Variable(
"Code",
Code(S3Bucket="test_bucket", S3Key="code_key")
),
Variable("Description", "Test function."),
Variable("Environment", {"TEST_NAME": "test_value"}),
Variable("Runtime", "python2.7"),
Variable("Role", "my-fake-role"),
]
)
blueprint.create_template()
self.assertRenderedBlueprint(blueprint)
def test_validate_subnets_empty(self):
blueprint = ElasticFileSystem('test_efs_ElasticFileSystem', self.ctx)
variables = EFS_VARIABLES.copy()
variables['Subnets'] = []
with self.assertRaises(ValidatorError):
blueprint.resolve_variables(
[Variable(k, v) for k, v in variables.items()])
def setUp(self):
self.variables = [
Variable('Buckets', {
'Simple': {},
'Cycle': {
'LifecycleConfiguration': {
'Rules': [{
'Status': 'Enabled',
'ExpirationInDays': 40,
}],
},
}
}),
Variable('ReadRoles', [
'Role1',
'Role2',
]),
Variable('ReadWriteRoles', [
'Role3',
'Role4',
]),
def test_create_template_hosted_zone_name(self):
blueprint = DNSRecords('route53_dnsrecords_zone_name', self.ctx)
blueprint.resolve_variables(
[
Variable(
"RecordSets",
[
{
"Name": "host.testdomain.com.",
"Type": "A",
"ResourceRecords": ["10.0.0.1"],
},
{
"Name": "host2.testdomain.com.",
"Type": "A",
"ResourceRecords": ["10.0.0.2"],
"Comment": "This is host2's record. : )",
},
{
"Name": "host3.testdomain.com.",
"Type": "A",
def test_create_template_with_alias_full_name_arn(self):
blueprint = Function(
'test_aws_lambda_Function_with_alias_full_name_arn',
self.ctx
)
blueprint.resolve_variables(
[
Variable(
"Code",
Code(S3Bucket="test_bucket", S3Key="code_key")
),
Variable("Description", "Test function."),
Variable("Environment", {"TEST_NAME": "test_value"}),
Variable("Runtime", "python2.7"),
Variable("AliasName", "arn:aws:lambda:aws-region:"
"acct-id:function:helloworld:PROD"),
]
)
blueprint.create_template()
self.assertRenderedBlueprint(blueprint)