diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index d79ddac04..5335bae9a 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -568,7 +568,7 @@ def to_cloudformation(self, **kwargs): def _construct_nested_stack(self): """Constructs a AWS::CloudFormation::Stack resource """ - nested_stack = NestedStack(self.logical_id, depends_on=self.depends_on) + nested_stack = NestedStack(self.logical_id, depends_on=self.depends_on, attributes=self.get_passthrough_resource_attributes()) nested_stack.Parameters = self.Parameters nested_stack.NotificationArns = self.NotificationArns application_tags = self._get_application_tags() @@ -633,15 +633,16 @@ def _construct_lambda_layer(self, intrinsics_resolver): """ retention_policy_value = self._get_retention_policy_value(intrinsics_resolver) - retention_policy = { - 'DeletionPolicy': retention_policy_value - } + attributes = self.get_passthrough_resource_attributes() + if attributes is None: + attributes = {} + attributes['DeletionPolicy'] = retention_policy_value old_logical_id = self.logical_id new_logical_id = logical_id_generator.LogicalIdGenerator(old_logical_id, self.to_dict()).gen() self.logical_id = new_logical_id - lambda_layer = LambdaLayerVersion(self.logical_id, depends_on=self.depends_on, attributes=retention_policy) + lambda_layer = LambdaLayerVersion(self.logical_id, depends_on=self.depends_on, attributes=attributes) # Changing the LayerName property: when a layer is published, it is given an Arn # example: arn:aws:lambda:us-west-2:123456789012:layer:MyLayer:1 diff --git a/tests/translator/input/basic_application.yaml b/tests/translator/input/basic_application.yaml index b68508814..6cef038fb 100644 --- a/tests/translator/input/basic_application.yaml +++ b/tests/translator/input/basic_application.yaml @@ -25,4 +25,12 @@ Resources: Properties: Location: https://s3-us-east-1.amazonaws.com/demo-bucket/template.yaml Tags: - TagName2: TagValue2 \ No newline at end of file + TagName2: TagValue2 + + ApplicationWithCondition: + Type: 'AWS::Serverless::Application' + Condition: "this is a test" + Properties: + Location: + ApplicationId: arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world + SemanticVersion: 1.0.2 \ No newline at end of file diff --git a/tests/translator/input/basic_layer.yaml b/tests/translator/input/basic_layer.yaml index 2e7c95cd5..39e0443ca 100644 --- a/tests/translator/input/basic_layer.yaml +++ b/tests/translator/input/basic_layer.yaml @@ -24,3 +24,9 @@ Resources: - python2.7 LicenseInfo: "License information" RetentionPolicy: Retain + + LayerWithCondition: + Type: 'AWS::Serverless::LayerVersion' + Condition: "this is a test" + Properties: + ContentUri: s3://sam-demo-bucket/layer.zip diff --git a/tests/translator/output/aws-cn/basic_application.json b/tests/translator/output/aws-cn/basic_application.json index bbdb760ad..e2056aaca 100644 --- a/tests/translator/output/aws-cn/basic_application.json +++ b/tests/translator/output/aws-cn/basic_application.json @@ -68,6 +68,27 @@ } ] } + }, + "ApplicationWithCondition": { + "Type": "AWS::CloudFormation::Stack", + "Properties": { + "TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + }, + { + "Value": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world", + "Key": "serverlessrepo:applicationId" + }, + { + "Value": "1.0.2", + "Key": "serverlessrepo:semanticVersion" + } + ] + }, + "Condition": "this is a test" } } } diff --git a/tests/translator/output/aws-cn/basic_layer.json b/tests/translator/output/aws-cn/basic_layer.json index af2794614..0b0a67400 100644 --- a/tests/translator/output/aws-cn/basic_layer.json +++ b/tests/translator/output/aws-cn/basic_layer.json @@ -39,6 +39,18 @@ "S3ObjectVersion": 1 } } + }, + "LayerWithCondition93cfa80b64": { + "DeletionPolicy": "Retain", + "Type": "AWS::Lambda::LayerVersion", + "Properties": { + "Content": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "layer.zip" + }, + "LayerName": "LayerWithCondition" + }, + "Condition": "this is a test" } } } diff --git a/tests/translator/output/aws-us-gov/basic_application.json b/tests/translator/output/aws-us-gov/basic_application.json index bbdb760ad..e2056aaca 100644 --- a/tests/translator/output/aws-us-gov/basic_application.json +++ b/tests/translator/output/aws-us-gov/basic_application.json @@ -68,6 +68,27 @@ } ] } + }, + "ApplicationWithCondition": { + "Type": "AWS::CloudFormation::Stack", + "Properties": { + "TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + }, + { + "Value": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world", + "Key": "serverlessrepo:applicationId" + }, + { + "Value": "1.0.2", + "Key": "serverlessrepo:semanticVersion" + } + ] + }, + "Condition": "this is a test" } } } diff --git a/tests/translator/output/aws-us-gov/basic_layer.json b/tests/translator/output/aws-us-gov/basic_layer.json index af2794614..0b0a67400 100644 --- a/tests/translator/output/aws-us-gov/basic_layer.json +++ b/tests/translator/output/aws-us-gov/basic_layer.json @@ -39,6 +39,18 @@ "S3ObjectVersion": 1 } } + }, + "LayerWithCondition93cfa80b64": { + "DeletionPolicy": "Retain", + "Type": "AWS::Lambda::LayerVersion", + "Properties": { + "Content": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "layer.zip" + }, + "LayerName": "LayerWithCondition" + }, + "Condition": "this is a test" } } } diff --git a/tests/translator/output/basic_application.json b/tests/translator/output/basic_application.json index bbdb760ad..e2056aaca 100644 --- a/tests/translator/output/basic_application.json +++ b/tests/translator/output/basic_application.json @@ -68,6 +68,27 @@ } ] } + }, + "ApplicationWithCondition": { + "Type": "AWS::CloudFormation::Stack", + "Properties": { + "TemplateURL": "https://awsserverlessrepo-changesets-xxx.s3.amazonaws.com/signed-url", + "Tags": [ + { + "Value": "SAM", + "Key": "lambda:createdBy" + }, + { + "Value": "arn:aws:serverlessrepo:us-east-1:123456789012:applications/hello-world", + "Key": "serverlessrepo:applicationId" + }, + { + "Value": "1.0.2", + "Key": "serverlessrepo:semanticVersion" + } + ] + }, + "Condition": "this is a test" } } } diff --git a/tests/translator/output/basic_layer.json b/tests/translator/output/basic_layer.json index af2794614..0b0a67400 100644 --- a/tests/translator/output/basic_layer.json +++ b/tests/translator/output/basic_layer.json @@ -39,6 +39,18 @@ "S3ObjectVersion": 1 } } + }, + "LayerWithCondition93cfa80b64": { + "DeletionPolicy": "Retain", + "Type": "AWS::Lambda::LayerVersion", + "Properties": { + "Content": { + "S3Bucket": "sam-demo-bucket", + "S3Key": "layer.zip" + }, + "LayerName": "LayerWithCondition" + }, + "Condition": "this is a test" } } }