Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion tests/translator/input/basic_application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ Resources:
Properties:
Location: https://s3-us-east-1.amazonaws.com/demo-bucket/template.yaml
Tags:
TagName2: TagValue2
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
6 changes: 6 additions & 0 deletions tests/translator/input/basic_layer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions tests/translator/output/aws-cn/basic_application.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
12 changes: 12 additions & 0 deletions tests/translator/output/aws-cn/basic_layer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
21 changes: 21 additions & 0 deletions tests/translator/output/aws-us-gov/basic_application.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
12 changes: 12 additions & 0 deletions tests/translator/output/aws-us-gov/basic_layer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
21 changes: 21 additions & 0 deletions tests/translator/output/basic_application.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
12 changes: 12 additions & 0 deletions tests/translator/output/basic_layer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}