Skip to content

Commit

Permalink
Merge pull request #2362 from aws/release/v1.44.0
Browse files Browse the repository at this point in the history
Release/v1.44.0 (to main)
  • Loading branch information
hawflau committed Mar 28, 2022
2 parents 0eebbec + e35a468 commit ce9a905
Show file tree
Hide file tree
Showing 18 changed files with 459 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/globals.rst
Expand Up @@ -71,6 +71,7 @@ Currently, the following resources and properties are being supported:
ReservedConcurrentExecutions:
EventInvokeConfig:
Architectures:
EphemeralStorage:
Api:
# Properties of AWS::Serverless::Api
Expand Down
@@ -0,0 +1,4 @@
[
{ "LogicalResourceId":"MyLambdaFunction", "ResourceType":"AWS::Lambda::Function" },
{ "LogicalResourceId":"MyLambdaFunctionRole", "ResourceType":"AWS::IAM::Role" }
]
@@ -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
19 changes: 19 additions & 0 deletions integration/single/test_basic_function.py
Expand Up @@ -204,3 +204,22 @@ def test_basic_function_with_tracing(self):
"PassThrough",
"Expecting tracing config mode to be set to PassThrough.",
)

@parameterized.expand(
[
"single/function_with_ephemeral_storage",
]
)
def test_function_with_ephemeral_storage(self, file_name):
"""
Creates a basic function with ephemeral storage
"""
self.create_and_verify_stack(file_name)

function_id = self.get_physical_id_by_logical_id("MyLambdaFunction")

function_configuration_result = self.client_provider.lambda_client.get_function_configuration(
FunctionName=function_id
)

self.assertEqual(function_configuration_result.get("EphemeralStorage", {}).get("Size", 0), 1024)
2 changes: 1 addition & 1 deletion samtranslator/__init__.py
@@ -1 +1 @@
__version__ = "1.43.0"
__version__ = "1.44.0"
1 change: 1 addition & 0 deletions samtranslator/model/lambda_.py
Expand Up @@ -27,6 +27,7 @@ class LambdaFunction(Resource):
"CodeSigningConfigArn": PropertyType(False, is_str()),
"ImageConfig": PropertyType(False, is_type(dict)),
"Architectures": PropertyType(False, list_of(one_of(is_str(), is_type(dict)))),
"EphemeralStorage": PropertyType(False, is_type(dict)),
}

runtime_attrs = {"name": lambda self: ref(self.logical_id), "arn": lambda self: fnGetAtt(self.logical_id, "Arn")}
Expand Down
2 changes: 2 additions & 0 deletions samtranslator/model/sam_resources.py
Expand Up @@ -83,6 +83,7 @@ class SamFunction(SamResourceMacro):
"ReservedConcurrentExecutions": PropertyType(False, any_type()),
"Layers": PropertyType(False, list_of(one_of(is_str(), is_type(dict)))),
"EventInvokeConfig": PropertyType(False, is_type(dict)),
"EphemeralStorage": PropertyType(False, is_type(dict)),
# Intrinsic functions in value of Alias property are not supported, yet
"AutoPublishAlias": PropertyType(False, one_of(is_str())),
"AutoPublishCodeSha256": PropertyType(False, one_of(is_str())),
Expand Down Expand Up @@ -426,6 +427,7 @@ def _construct_lambda_function(self):
lambda_function.ImageConfig = self.ImageConfig
lambda_function.PackageType = self.PackageType
lambda_function.Architectures = self.Architectures
lambda_function.EphemeralStorage = self.EphemeralStorage

if self.Tracing:
lambda_function.TracingConfig = {"Mode": self.Tracing}
Expand Down
1 change: 1 addition & 0 deletions samtranslator/plugins/globals/globals.py
Expand Up @@ -42,6 +42,7 @@ class Globals(object):
"FileSystemConfigs",
"CodeSigningConfigArn",
"Architectures",
"EphemeralStorage",
],
# Everything except
# DefinitionBody: because its hard to reason about merge of Swagger dictionaries
Expand Down
20 changes: 20 additions & 0 deletions tests/translator/input/function_with_ephemeral_storage.yaml
@@ -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
2 changes: 2 additions & 0 deletions tests/translator/input/globals_for_function.yaml
Expand Up @@ -24,6 +24,8 @@ Globals:
ReservedConcurrentExecutions: 50
Architectures:
- x86_64
EphemeralStorage:
Size: 1024

Resources:
MinimalFunction:
Expand Down
123 changes: 123 additions & 0 deletions tests/translator/output/aws-cn/function_with_ephemeral_storage.json
@@ -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"
}
}
}
8 changes: 7 additions & 1 deletion tests/translator/output/aws-cn/globals_for_function.json
Expand Up @@ -84,6 +84,9 @@
],
"ReservedConcurrentExecutions": 100,
"Architectures": ["x86_64"],
"EphemeralStorage": {
"Size": 1024
},
"MemorySize": 512,
"Environment": {
"Variables": {
Expand Down Expand Up @@ -190,6 +193,9 @@
],
"ReservedConcurrentExecutions": 50,
"Architectures": ["x86_64"],
"EphemeralStorage": {
"Size": 1024
},
"MemorySize": 1024,
"Environment": {
"Variables": {
Expand Down Expand Up @@ -242,4 +248,4 @@
}
}
}
}
}
@@ -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"
}
}
}

0 comments on commit ce9a905

Please sign in to comment.