-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: SAM support for /tmp config (#87) * Add EphemeralStorage field Add EphemeralStorage as a new option when creating SAM templates. Add functionality to transform SAM templates with EphemeralStorage to Cloudformation templates. Add /translate tests for new field * Add EphemeralStorage to global configs * Add EphemeralStorage to global configs * Add testing for functions with intrinsic refs, add EphemeralStorage to versions Co-authored-by: Kevin Weng <kwweng@amazon.com> * chore: add integration test for /tmp (#101) * Add integration test for /tmp Also edit basic_function_event_destinations template file to avoid deprecated runtime error * Add integration test for /tmp Also edit basic_function_event_destinations template file to avoid deprecated runtime error * Revert changes to template runtime and use getters in test_function_with_ephemeral_storage. Delete duplicated test * Revert runtime changes Co-authored-by: Kevin Weng <kwweng@amazon.com> Co-authored-by: Kevin Weng <42563047+slowpokesnail@users.noreply.github.com> Co-authored-by: Kevin Weng <kwweng@amazon.com>
- Loading branch information
1 parent
594c54f
commit d5d81b5
Showing
17 changed files
with
458 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
integration/resources/expected/single/function_with_ephemeral_storage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
{ "LogicalResourceId":"MyLambdaFunction", "ResourceType":"AWS::Lambda::Function" }, | ||
{ "LogicalResourceId":"MyLambdaFunctionRole", "ResourceType":"AWS::IAM::Role" } | ||
] |
17 changes: 17 additions & 0 deletions
17
integration/resources/templates/single/function_with_ephemeral_storage.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Resources: | ||
MyLambdaFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: index.handler | ||
Runtime: nodejs12.x | ||
CodeUri: ${codeuri} | ||
MemorySize: 128 | ||
EphemeralStorage: | ||
Size: 1024 | ||
Policies: | ||
- AWSLambdaRole | ||
- AmazonS3ReadOnlyAccess | ||
Environment: | ||
Variables: | ||
Name: Value | ||
Name2: Value2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/translator/input/function_with_ephemeral_storage.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Parameters: | ||
EphemeralStorageSizeRef: | ||
Type: Number | ||
Resources: | ||
MinimalFunction: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/hello.zip | ||
Handler: hello.handler | ||
Runtime: python2.7 | ||
EphemeralStorage: | ||
Size: 1024 | ||
FunctionWithIntrinsicRef: | ||
Type: 'AWS::Serverless::Function' | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/hello.zip | ||
Handler: hello.handler | ||
Runtime: python2.7 | ||
EphemeralStorage: | ||
Size: !Ref EphemeralStorageSizeRef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
tests/translator/output/aws-cn/function_with_ephemeral_storage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
{ | ||
"Resources": { | ||
"FunctionWithIntrinsicRef": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": "sam-demo-bucket", | ||
"S3Key": "hello.zip" | ||
}, | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
], | ||
"EphemeralStorage": { | ||
"Size": { | ||
"Ref": "EphemeralStorageSizeRef" | ||
} | ||
}, | ||
"Handler": "hello.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"FunctionWithIntrinsicRefRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "python2.7" | ||
} | ||
}, | ||
"FunctionWithIntrinsicRefRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"ManagedPolicyArns": [ | ||
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
}, | ||
"MinimalFunctionRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"ManagedPolicyArns": [ | ||
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
}, | ||
"MinimalFunction": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": "sam-demo-bucket", | ||
"S3Key": "hello.zip" | ||
}, | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
], | ||
"EphemeralStorage": { | ||
"Size": 1024 | ||
}, | ||
"Handler": "hello.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"MinimalFunctionRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "python2.7" | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"EphemeralStorageSizeRef": { | ||
"Type": "Number" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
tests/translator/output/aws-us-gov/function_with_ephemeral_storage.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
{ | ||
"Resources": { | ||
"FunctionWithIntrinsicRef": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": "sam-demo-bucket", | ||
"S3Key": "hello.zip" | ||
}, | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
], | ||
"EphemeralStorage": { | ||
"Size": { | ||
"Ref": "EphemeralStorageSizeRef" | ||
} | ||
}, | ||
"Handler": "hello.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"FunctionWithIntrinsicRefRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "python2.7" | ||
} | ||
}, | ||
"FunctionWithIntrinsicRefRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"ManagedPolicyArns": [ | ||
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
}, | ||
"MinimalFunctionRole": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Action": [ | ||
"sts:AssumeRole" | ||
], | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": [ | ||
"lambda.amazonaws.com" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"ManagedPolicyArns": [ | ||
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
], | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
] | ||
} | ||
}, | ||
"MinimalFunction": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"S3Bucket": "sam-demo-bucket", | ||
"S3Key": "hello.zip" | ||
}, | ||
"Tags": [ | ||
{ | ||
"Value": "SAM", | ||
"Key": "lambda:createdBy" | ||
} | ||
], | ||
"EphemeralStorage": { | ||
"Size": 1024 | ||
}, | ||
"Handler": "hello.handler", | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"MinimalFunctionRole", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "python2.7" | ||
} | ||
} | ||
}, | ||
"Parameters": { | ||
"EphemeralStorageSizeRef": { | ||
"Type": "Number" | ||
} | ||
} | ||
} |
Oops, something went wrong.