I have a SAM application and a CodePipeline setup to deploy it. I want to pass parameters down from my Pipeline into the SAM's YAML file. I tried using ParameterOverrides
but seem to still get:
Parameters: [AppName] must have values (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError; Request ID: 46d1dfd6-9a9a-11e7-a59d-999618d6a174)
My sam.yml
parameters definations
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
AppName:
Type: String
Description: Prefix for resources
The part defining the parameters overrides:
- Name: ExecuteChangeSet
Actions:
- Name: Lambda
ActionTypeId:
Category: Deploy
Owner: AWS
Version: 1
Provider: CloudFormation
Configuration:
ActionMode: CHANGE_SET_EXECUTE
ChangeSetName: !Sub
- '${PipelineName}-lambda'
- {PipelineName: !Ref PipelineName}
StackName: !Sub
- '${PipelineName}-lambda'
- {PipelineName: !Ref PipelineName}
ParameterOverrides: !Sub '{"AppName": "${PipelineName}-lambda"}'
Whats is wrong with this?
It appears that you're attempting to apply the ParameterOverrides
during a CHANGE_SET_EXECUTE
action mode. If I'm not mistaken, under the hood, this maps down to CloudFormations ExecuteChangeSet action, which does not have a Parameters property.
The solution to this is to apply the Parameters when you create the change set. This will be done in CodePipeline with a CHANGE_SET_REPLACE
action mode. Alternatively, you could look into the CREATE_UPDATE
. Check out AWS CloudFormation Configuration Properties for more details.
Here's a sample that creates, then executes the change set
- Name: CreateChangeSet
Actions:
- Name: Lambda
ActionTypeId:
Category: Deploy
Owner: AWS
Version: 1
Provider: CloudFormation
InputArtifacts:
- Name: BuildOutputArtifact
Configuration:
ActionMode: CHANGE_SET_REPLACE
ChangeSetName: !Sub
- '${PipelineName}-lambda'
- {PipelineName: !Ref PipelineName}
StackName: !Sub
- '${PipelineName}-lambda'
- {PipelineName: !Ref PipelineName}
ParameterOverrides: !Ref ProjectParameterOverrides
TemplatePath: BuildOutputArtifact::SamDeploymentTemplate.yaml
- Name: ExecuteChangeSet
Actions:
- Name: Lambda
ActionTypeId:
Category: Deploy
Owner: AWS
Version: 1
Provider: CloudFormation
Configuration:
ActionMode: CHANGE_SET_EXECUTE
ChangeSetName: !Sub
- '${PipelineName}-lambda'
- {PipelineName: !Ref PipelineName}
StackName: !Sub
- '${PipelineName}-lambda'
- {PipelineName: !Ref PipelineName}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With