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
1 change: 1 addition & 0 deletions .cfnlintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ ignore_templates:
- tests/translator/output/**/function_with_tenancy_and_api_event.json # cfnlint is not updated to recognize the TenancyConfig property
- tests/translator/output/**/function_with_tenancy_and_httpapi_event.json # cfnlint is not updated to recognize the TenancyConfig property
- tests/translator/output/**/function_with_tenancy_config_global.json # cfnlint is not updated to recognize the TenancyConfig property
- tests/translator/output/**/*durable_config*.json # TODO: Remove this once Durable Function is launched in CFN

ignore_checks:
- E2531 # Deprecated runtime; not relevant for transform tests
Expand Down
2 changes: 1 addition & 1 deletion samtranslator/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.104.0"
__version__ = "1.105.0"
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ class Properties(BaseModel):
) # TODO: add documentation
PublishToLatestPublished: Optional[SamIntrinsicable[Union[str, bool]]] # TODO: add documentation
TenancyConfig: Optional[PassThroughProp] # TODO: add documentation
DurableConfig: Optional[PassThroughProp] # TODO: add documentation


class Globals(BaseModel):
Expand Down Expand Up @@ -746,6 +747,7 @@ class Globals(BaseModel):
) # TODO: add documentation
PublishToLatestPublished: Optional[SamIntrinsicable[Union[str, bool]]] # TODO: add documentation
TenancyConfig: Optional[PassThroughProp] # TODO: add documentation
DurableConfig: Optional[PassThroughProp] # TODO: add documentation


class Resource(ResourceAttributes):
Expand Down
2 changes: 2 additions & 0 deletions samtranslator/model/lambda_.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class LambdaFunction(Resource):
"FunctionScalingConfig": GeneratedProperty(),
"PublishToLatestPublished": GeneratedProperty(),
"TenancyConfig": GeneratedProperty(),
"DurableConfig": GeneratedProperty(),
}

Code: Dict[str, Any]
Expand Down Expand Up @@ -72,6 +73,7 @@ class LambdaFunction(Resource):
FunctionScalingConfig: Optional[Dict[str, Any]]
PublishToLatestPublished: Optional[Dict[str, Any]]
TenancyConfig: Optional[Dict[str, Any]]
DurableConfig: Optional[Dict[str, Any]]

runtime_attrs = {"name": lambda self: ref(self.logical_id), "arn": lambda self: fnGetAtt(self.logical_id, "Arn")}

Expand Down
3 changes: 3 additions & 0 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class SamFunction(SamResourceMacro):
"VersionDeletionPolicy": PropertyType(False, IS_STR_ENUM(["Delete", "Retain"])),
"PublishToLatestPublished": PassThroughProperty(False),
"TenancyConfig": PassThroughProperty(False),
"DurableConfig": PropertyType(False, IS_DICT),
}

FunctionName: Optional[Intrinsicable[str]]
Expand Down Expand Up @@ -247,6 +248,7 @@ class SamFunction(SamResourceMacro):
PublishToLatestPublished: Optional[PassThrough]
VersionDeletionPolicy: Optional[Intrinsicable[str]]
TenancyConfig: Optional[Dict[str, Any]]
DurableConfig: Optional[Dict[str, Any]]

event_resolver = ResourceTypeResolver(
samtranslator.model.eventsources,
Expand Down Expand Up @@ -690,6 +692,7 @@ def _construct_lambda_function(self, intrinsics_resolver: IntrinsicsResolver) ->
lambda_function.LoggingConfig = self.LoggingConfig
lambda_function.TenancyConfig = self.TenancyConfig
lambda_function.RecursiveLoop = self.RecursiveLoop
lambda_function.DurableConfig = self.DurableConfig

# Transform capacity provider configuration
if self.CapacityProviderConfig:
Expand Down
2 changes: 2 additions & 0 deletions samtranslator/plugins/globals/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Globals:
"RecursiveLoop",
"SourceKMSKeyArn",
"TenancyConfig",
"DurableConfig",
"CapacityProviderConfig",
"FunctionScalingConfig",
"PublishToLatestPublished",
Expand Down Expand Up @@ -117,6 +118,7 @@ class Globals:
unreleased_properties: Dict[str, List[str]] = {
SamResourceType.Function.value: [
"TenancyConfig",
"DurableConfig",
"CapacityProviderConfig",
"FunctionScalingConfig",
"PublishToLatestPublished",
Expand Down
27 changes: 27 additions & 0 deletions samtranslator/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -142798,6 +142798,11 @@
"title": "Description",
"type": "string"
},
"DurableConfig": {
"$ref": "#/definitions/AWS::Lambda::Function.DurableConfig",
"markdownDescription": "Configuration for durable function execution.",
"title": "DurableConfig"
},
"Environment": {
"$ref": "#/definitions/AWS::Lambda::Function.Environment",
"markdownDescription": "Environment variables that are accessible from function code during execution.",
Expand Down Expand Up @@ -142977,6 +142982,22 @@
},
"type": "object"
},
"AWS::Lambda::Function.DurableConfig": {
"additionalProperties": false,
"properties": {
"ExecutionTimeout": {
"markdownDescription": "The maximum execution timeout in seconds for durable function executions.",
"title": "ExecutionTimeout",
"type": "number"
},
"RetentionPeriodInDays": {
"markdownDescription": "The retention period in days for durable function execution history.",
"title": "RetentionPeriodInDays",
"type": "number"
}
},
"type": "object"
},
"AWS::Lambda::Function.Environment": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -278805,6 +278826,9 @@
"markdownDescription": "A description of the function\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Description`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-description) property of an `AWS::Lambda::Function` resource\\.",
"title": "Description"
},
"DurableConfig": {
"$ref": "#/definitions/PassThroughProp"
},
"Environment": {
"$ref": "#/definitions/AWS::Lambda::Function.Environment",
"markdownDescription": "The configuration for the runtime environment\\. \n*Type*: [Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Environment`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html) property of an `AWS::Lambda::Function` resource\\.",
Expand Down Expand Up @@ -279097,6 +279121,9 @@
"title": "Description",
"type": "string"
},
"DurableConfig": {
"$ref": "#/definitions/PassThroughProp"
},
"Environment": {
"$ref": "#/definitions/AWS::Lambda::Function.Environment",
"markdownDescription": "The configuration for the runtime environment\\. \n*Type*: [Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Environment`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html) property of an `AWS::Lambda::Function` resource\\.",
Expand Down
21 changes: 21 additions & 0 deletions schema_source/cloudformation.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -142749,6 +142749,11 @@
"title": "Description",
"type": "string"
},
"DurableConfig": {
"$ref": "#/definitions/AWS::Lambda::Function.DurableConfig",
"markdownDescription": "Configuration for durable function execution.",
"title": "DurableConfig"
},
"Environment": {
"$ref": "#/definitions/AWS::Lambda::Function.Environment",
"markdownDescription": "Environment variables that are accessible from function code during execution.",
Expand Down Expand Up @@ -143119,6 +143124,22 @@
},
"type": "object"
},
"AWS::Lambda::Function.DurableConfig": {
"additionalProperties": false,
"properties": {
"ExecutionTimeout": {
"markdownDescription": "The maximum execution timeout in seconds for durable function executions.",
"title": "ExecutionTimeout",
"type": "number"
},
"RetentionPeriodInDays": {
"markdownDescription": "The retention period in days for durable function execution history.",
"title": "RetentionPeriodInDays",
"type": "number"
}
},
"type": "object"
},
"AWS::Lambda::LayerVersion": {
"additionalProperties": false,
"properties": {
Expand Down
6 changes: 6 additions & 0 deletions schema_source/sam.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5828,6 +5828,9 @@
"markdownDescription": "A description of the function\\. \n*Type*: String \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Description`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-description) property of an `AWS::Lambda::Function` resource\\.",
"title": "Description"
},
"DurableConfig": {
"$ref": "#/definitions/PassThroughProp"
},
"Environment": {
"__samPassThrough": {
"markdownDescriptionOverride": "The configuration for the runtime environment\\. \n*Type*: [Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Environment`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html) property of an `AWS::Lambda::Function` resource\\.",
Expand Down Expand Up @@ -6246,6 +6249,9 @@
],
"title": "Description"
},
"DurableConfig": {
"$ref": "#/definitions/PassThroughProp"
},
"Environment": {
"__samPassThrough": {
"markdownDescriptionOverride": "The configuration for the runtime environment\\. \n*Type*: [Environment](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`Environment`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html) property of an `AWS::Lambda::Function` resource\\.",
Expand Down
10 changes: 10 additions & 0 deletions tests/translator/input/function_with_durable_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Resources:
FunctionWithDurableConfig:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://sam-demo-bucket/hello.zip
Handler: hello.handler
Runtime: python3.9
DurableConfig:
ExecutionTimeout: 3600
RetentionPeriodInDays: 45
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Globals:
Function:
Runtime: python3.11
Handler: index.handler
DurableConfig:
ExecutionTimeout: 3600
RetentionPeriodInDays: 30

Resources:
DurableFunctionWithGlobals:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://my-bucket/my-function.zip

DurableFunctionWithOverride:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://my-bucket/my-function.zip
DurableConfig:
ExecutionTimeout: 7200
RetentionPeriodInDays: 7

RegularFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://my-bucket/my-function.zip
# This function should inherit the global DurableConfig
6 changes: 6 additions & 0 deletions tests/translator/input/globals_for_function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Globals:
LogGroup: myJsonStructuredLogs
RecursiveLoop: ALLOW
SourceKMSKeyArn: arn:aws:kms:us-west-2:123456789012:key/dec86919-7219-4e8d-8871-7f1609df2c7f
DurableConfig:
ExecutionTimeout: 3600
RetentionPeriodInDays: 30



Expand Down Expand Up @@ -69,3 +72,6 @@ Resources:
UpdateRuntimeOn: FunctionChange
RecursiveLoop: TERMINATE
SourceKMSKeyArn: arn:aws:kms:us-west-2:987654321098:key/dec86919-7219-4e8d-8871-7f1609df2c7f
DurableConfig:
ExecutionTimeout: 7200
RetentionPeriodInDays: 7
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"Resources": {
"FunctionWithDurableConfig": {
"Properties": {
"Code": {
"S3Bucket": "sam-demo-bucket",
"S3Key": "hello.zip"
},
"DurableConfig": {
"ExecutionTimeout": 3600,
"RetentionPeriodInDays": 45
},
"Handler": "hello.handler",
"Role": {
"Fn::GetAtt": [
"FunctionWithDurableConfigRole",
"Arn"
]
},
"Runtime": "python3.9",
"Tags": [
{
"Key": "lambda:createdBy",
"Value": "SAM"
}
]
},
"Type": "AWS::Lambda::Function"
},
"FunctionWithDurableConfigRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
],
"Tags": [
{
"Key": "lambda:createdBy",
"Value": "SAM"
}
]
},
"Type": "AWS::IAM::Role"
}
}
}
Loading