AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Template with unnecessary service role Resources: Function: Type: AWS::Serverless::Function Properties: Handler: lambda.lambda_handler Role: arn:aws:iam::123456789999:role/lambda-role Runtime: python3.7 CodeUri: s3://bucket/key AutoPublishAlias: live DeploymentPreference: Type: Linear10PercentEvery1Minute Role: arn:aws:iam::123456789999:role/custom-codedeploy-servicerole Hooks: PreTraffic: !Ref preTrafficHook Events: Api: Type: Api Properties: Path: /test Method: get preTrafficHook: Type: AWS::Serverless::Function Properties: Handler: hook.lambda_handler Role: arn:aws:iam::123456789999:role/lambda-role Runtime: python3.7 CodeUri: s3://bucket/key FunctionName: 'CodeDeployHook_preTrafficHook' AutoPublishAlias: live DeploymentPreference: Enabled: false Role: arn:aws:iam::123456789999:role/custom-codedeploy-servicerole Type: Linear10PercentEvery1Minute Timeout: 5 Environment: Variables: NewVersion: !Ref Function.Version