Skip to content
Open
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 @@ -119,6 +119,7 @@ ignore_templates:
- tests/translator/output/**/webfunction_with_all_properties.json # New AWS::Lambda::WebFunction* types cfn-lint does not recognize; DependsOn is intentional (W3005)
- tests/translator/output/**/webfunction_multiregion.json # New AWS::Lambda::WebFunction* types cfn-lint does not recognize; DependsOn is intentional (W3005)
- tests/translator/output/**/webfunction_globals.json # New AWS::Lambda::WebFunction* types cfn-lint does not recognize; DependsOn is intentional (W3005)
- tests/translator/output/**/webfunction_update_replace_policy.json # New AWS::Lambda::WebFunction* types cfn-lint does not recognize; DependsOn is intentional (W3005)
- tests/translator/output/**/network_connector_with_compute_types.json # cfn-lint's published AWS::Lambda::NetworkConnector schema enum for AssociatedComputeResourceTypes still lists only MicroVm; the preview WebFunction compute type trips E3030
- tests/translator/output/**/graphqlapi_api_cache.json # pre-existing: fixture uses placeholder ApiCachingBehavior/Type values ('somebehaviour'/'mytype') that a cfn-lint registry-schema update now rejects (E3030); unrelated to this change
- tests/translator/output/**/basic_function.json # W1030: fixture uses Ref for VpcConfig SubnetIds, which cannot match the subnet-id pattern
Expand Down
8 changes: 5 additions & 3 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2132,9 +2132,11 @@ def _construct_lambda_webfunction(self) -> LambdaWebFunction:
return function

def _construct_revision(self, execution_role_arn: Any) -> LambdaWebFunctionRevision:
revision = LambdaWebFunctionRevision(
f"{self.logical_id}Revision", attributes=self.get_passthrough_resource_attributes()
)
attributes = self.get_passthrough_resource_attributes()
# Keep a replaced revision: endpoints may still route to it, and deleting it would fail and be retried.
# Deleting the function deletes its revisions. Endpoints aren't retained.
attributes.setdefault("UpdateReplacePolicy", "Retain")
revision = LambdaWebFunctionRevision(f"{self.logical_id}Revision", attributes=attributes)
# Ref the function (its ARN) instead of repeating the name, like AWS::Lambda::Version does, so a
# FunctionName change only has to be made on the AWS::Lambda::WebFunction.
revision.FunctionName = ref(self.logical_id)
Expand Down
11 changes: 11 additions & 0 deletions tests/translator/input/webfunction_update_replace_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Resources:
# An explicit UpdateReplacePolicy replaces the revision's default (Retain)
MyWebFunction:
Type: AWS::Serverless::WebFunction
UpdateReplacePolicy: Delete
Properties:
Runtime: nodejs24.x
AuthType: IamAuth
CodeUri: s3://sam-demo-bucket/webfunc.zip
Metadata:
SamTransformTest: true
3 changes: 2 additions & 1 deletion tests/translator/output/aws-cn/webfunction_basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"TimeoutSeconds": 30
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"MyWebFunctionRole": {
"Properties": {
Expand Down
6 changes: 4 additions & 2 deletions tests/translator/output/aws-cn/webfunction_globals.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
"TimeoutSeconds": 30
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"WebFunctionOneRole": {
"Properties": {
Expand Down Expand Up @@ -260,7 +261,8 @@
"TimeoutSeconds": 60
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"WebFunctionTwoRole": {
"Properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"TimeoutSeconds": 30
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"MyWebFunctionRole": {
"Properties": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"Metadata": {
"SamTransformTest": true
},
"Resources": {
"MyWebFunction": {
"Properties": {
"FunctionName": {
"Fn::Sub": [
"MyWebFunction-${StackIdSuffix}",
{
"StackIdSuffix": {
"Fn::Select": [
0,
{
"Fn::Split": [
"-",
{
"Fn::Select": [
2,
{
"Fn::Split": [
"/",
{
"Ref": "AWS::StackId"
}
]
}
]
}
]
}
]
}
}
]
},
"Tags": [
{
"Key": "lambda:createdBy",
"Value": "SAM"
}
]
},
"Type": "AWS::Lambda::WebFunction",
"UpdateReplacePolicy": "Delete"
},
"MyWebFunctionEndpoint": {
"DependsOn": [
"MyWebFunction",
"MyWebFunctionRevision"
],
"Properties": {
"AuthType": "IamAuth",
"EndpointName": "prod",
"EndpointType": "HomeRegion",
"FunctionName": {
"Ref": "MyWebFunction"
},
"RevisionWeights": [
{
"RevisionId": {
"Fn::GetAtt": [
"MyWebFunctionRevision",
"RevisionId"
]
},
"Weight": 100
}
]
},
"Type": "AWS::Lambda::WebFunctionEndpoint",
"UpdateReplacePolicy": "Delete"
},
"MyWebFunctionRevision": {
"DependsOn": [
"MyWebFunction"
],
"Properties": {
"BuildConfig": {
"CodeConfig": {
"S3Object": {
"Bucket": "sam-demo-bucket",
"Key": "webfunc.zip"
}
},
"RuntimeConfig": {
"Runtime": "nodejs24.x"
}
},
"FunctionName": {
"Ref": "MyWebFunction"
},
"ServiceConfig": {
"ExecutionRoleArn": {
"Fn::GetAtt": [
"MyWebFunctionRole",
"Arn"
]
},
"TimeoutSeconds": 30
}
},
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Delete"
},
"MyWebFunctionRole": {
"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",
"UpdateReplacePolicy": "Delete"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
"TimeoutSeconds": 120
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"MyWebFunctionRole": {
"Properties": {
Expand Down
3 changes: 2 additions & 1 deletion tests/translator/output/aws-us-gov/webfunction_basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
"TimeoutSeconds": 30
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"MyWebFunctionRole": {
"Properties": {
Expand Down
6 changes: 4 additions & 2 deletions tests/translator/output/aws-us-gov/webfunction_globals.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
"TimeoutSeconds": 30
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"WebFunctionOneRole": {
"Properties": {
Expand Down Expand Up @@ -260,7 +261,8 @@
"TimeoutSeconds": 60
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"WebFunctionTwoRole": {
"Properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"TimeoutSeconds": 30
}
},
"Type": "AWS::Lambda::WebFunctionRevision"
"Type": "AWS::Lambda::WebFunctionRevision",
"UpdateReplacePolicy": "Retain"
},
"MyWebFunctionRole": {
"Properties": {
Expand Down
Loading
Loading