integration/resources/templates/combination/function_with_custom_code_deploy.yaml (56 lines of code) (raw):
Parameters:
DeployConfigName:
Type: String
# Just one function with a deployment preference
Resources:
MyLambdaFunction:
DependsOn: CustomDeploymentConfig
Type: AWS::Serverless::Function
Properties:
CodeUri: ${codeuri}
Handler: index.handler
Runtime: python3.11
AutoPublishAlias: Live
DeploymentPreference:
Type:
Ref: CustomDeploymentConfig
Role:
Fn::GetAtt: [DeploymentRole, Arn]
DeploymentRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- codedeploy.amazonaws.com
Policies:
- PolicyName: root
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Resource: '*'
Action:
- cloudwatch:DescribeAlarms
- lambda:UpdateAlias
- lambda:GetAlias
- lambda:InvokeFunction
- s3:Get*
- sns:Publish
CustomDeploymentConfig:
Type: AWS::CodeDeploy::DeploymentConfig
Properties:
DeploymentConfigName:
Ref: DeployConfigName
ComputePlatform: Lambda
TrafficRoutingConfig:
Type: TimeBasedLinear
TimeBasedLinear:
LinearInterval: 1
LinearPercentage: 50
Metadata:
SamTransformTest: true