Amazon CloudFormation resources generated when AWS::Serverless::WebFunction is specified
When you specify an AWS::Serverless::WebFunction, Amazon Serverless Application Model (Amazon SAM) generates
the following base Amazon CloudFormation resources.
AWS::Lambda::WebFunction-
LogicalId:<webfunction‑LogicalId>Referenceable property: N/A (you must use the
LogicalIdto reference this Amazon CloudFormation resource) AWS::Lambda::WebFunctionRevision-
LogicalId:<webfunction‑LogicalId>RevisionReferenceable property: N/A (you must use the
LogicalIdto reference this Amazon CloudFormation resource)Resource attributes:
UpdateReplacePolicy: RetainEvery property of a revision is create-only, so a change to the function's code or configuration replaces the revision. Amazon SAM sets
UpdateReplacePolicy: Retainso that Amazon CloudFormation keeps the replaced revision instead of deleting it. An endpoint can still route traffic to it throughRevisionWeights, and Lambda doesn't delete a revision that an endpoint uses. The replaced revision is no longer part of the stack. Deleting the function deletes all of its revisions.The revision created by an update that fails and rolls back is also kept.
To override this, set
UpdateReplacePolicyon theAWS::Serverless::WebFunction. Amazon SAM then applies your value to every resource that it generates, including the Web Function endpoint. AWS::Lambda::WebFunctionEndpoint-
LogicalId:<webfunction‑LogicalId>EndpointReferenceable property: N/A (you must use the
LogicalIdto reference this Amazon CloudFormation resource)
All three resources use the same function name. If you don't specify the
FunctionName property, Amazon SAM generates a name of the form
,
where <webfunction‑LogicalId>-<stack-id-prefix>stack-id-prefix is the first 8 characters of the stack ID's
unique identifier. Amazon SAM shortens the logical ID if needed so that the name is at most 64
characters.
In addition to these Amazon CloudFormation resources, when AWS::Serverless::WebFunction is
specified, Amazon SAM also generates Amazon CloudFormation resources for the following scenarios:
ExecutionRoleArn property is not specified
When you don't specify the ExecutionRoleArn property of an AWS::Serverless::WebFunction,
Amazon SAM generates an AWS::IAM::Role
Amazon CloudFormation resource with the AWSLambdaBasicExecutionRole Amazon managed policy attached.
The role trust policy allows the lambda.amazonaws.com service principal to assume the role.
AWS::IAM::Role-
LogicalId:<webfunction‑LogicalId>Role