AWS CloudFormation
User Guide (API Version 2010-05-15)

Using Parameter Override Functions with AWS CodePipeline Pipelines

In an AWS CodePipeline stage, you can specify parameter overrides for AWS CloudFormation actions. Parameter overrides let you specify template parameter values that override values in a template configuration file. AWS CloudFormation provides functions to help you to specify dynamic values (values that are unknown until the pipeline runs).


The Fn::GetArtifactAtt function retrieves the value of an attribute from an input artifact, such as the S3 bucket name where the artifact is stored. Use this function to specify attributes of an artifact, such as its filename or S3 bucket name.

When you run a pipeline, AWS CodePipeline copies and writes files to the pipeline's artifact store (an S3 bucket). AWS CodePipeline generates the filenames in the artifact store. These filenames are unknown before you run the pipeline.

For example, in your pipeline, you might have a source stage where AWS CodePipeline copies your AWS Lambda function source code to the artifact store. In the next stage, you have an AWS CloudFormation template that creates the Lambda function, but AWS CloudFormation requires the filename to create the function. You must use the Fn::GetArtifactAtt function to pass the exact S3 bucket and file names.


Use the following syntax to retrieve an attribute value of an artifact.

{ "Fn::GetArtifactAtt" : [ "artifactName", "attributeName" ] }

The name of the input artifact. You must declare this artifact as input for the associated action.


The name of the artifact attribute whose value you want to retrieve. For details about each artifact attribute, see the following Attributes section.


The following parameter overrides specify the BucketName and ObjectKey parameters by retrieving the S3 bucket name and filename of the LambdaFunctionSource artifact. This example assumes that AWS CodePipeline copied Lambda function source code and saved it as an artifact, for example, as part of a source stage.

{ "BucketName" : { "Fn::GetArtifactAtt" : ["LambdaFunctionSource", "BucketName"]}, "ObjectKey" : { "Fn::GetArtifactAtt" : ["LambdaFunctionSource", "ObjectKey"]} }


You can retrieve the following attributes for an artifact.


The name of the S3 bucket where the artifact is stored.


The name of the .zip file that contains the artifact that is generated by AWS CodePipeline, such as


The Amazon Simple Storage Service (Amazon S3) URL of the artifact, such as


The Fn::GetParam function returns a value from a key-value pair in a JSON-formatted file. The JSON file must be included in an artifact.

Use this function to retrieve output values from an AWS CloudFormation stack and use them as input for another action. For example, if you specify an output filename for an AWS CloudFormation action, AWS CodePipeline saves the output in a JSON file and then adds it to the output artifact's .zip file. Use the Fn::GetParam function to retrieve the output value, and use it as input for another action.


Use the following syntax to retrieve a value from a key-value pair.

{ "Fn::GetParam" : [ "artifactName", "JSONFileName", "keyName" ] }

The name of the artifact, which must be included as an input artifact for the associated action.


The name of a JSON file that is contained in the artifact.


The name of the key whose value you want to retrieve.


The following examples demonstrate how to use the Fn::GetParam function in a parameter override.


The following parameter override specifies the WebSiteURL parameter by retrieving the value of the URL key from the stack-output.json file that is in the WebStackOutput artifact.

{ "WebSiteURL" : { "Fn::GetParam" : ["WebStackOutput", "stack-output.json", "URL"]} }

AWS CloudFormation Template Snippets

The following AWS CloudFormation template snippets, from an AWS CodePipeline pipeline, demonstrate how to pass stack outputs. These snippets show two stages of pipeline definition. The first stage creates a stack and save its outputs in the TestOutput.json file in the StackAOutput artifact. These values are specified by the OutputFileName and OutputArtifacts properties.

Create Stack A Stage

- Name: CreateTestStackA Actions: - Name: CloudFormationCreate ActionTypeId: Category: Deploy Owner: AWS Provider: CloudFormation Version: '1' Configuration: ActionMode: CREATE_UPDATE Capabilities: CAPABILITY_IAM OutputFileName: TestOutput.json RoleArn: !GetAtt [CFNRole, Arn] StackName: StackA TemplateConfiguration: TemplateSource::test-configuration.json TemplatePath: TemplateSource::teststackA.yaml InputArtifacts: - Name: TemplateSourceA OutputArtifacts: - Name: StackAOutput RunOrder: '1'

In a subsequent stage, stack B uses the outputs from stack A. In the ParameterOverrides property, the example uses the Fn::GetParam function to specify the StackBInputParam parameter. The resulting value is the value associated with the StackAOutputName key.

Create Stack B Stage

- Name: CreateTestStackB Actions: - Name: CloudFormationCreate ActionTypeId: Category: Deploy Owner: AWS Provider: CloudFormation Version: '1' Configuration: ActionMode: CREATE_UPDATE Capabilities: CAPABILITY_IAM RoleArn: !GetAtt [CFNRole, Arn] StackName: StackB TemplateConfiguration: TemplateSource::test-configuration.json TemplatePath: TemplateSource::teststackB.yaml ParameterOverrides: { "StackBInputParam" : { "Fn::GetParam" : ["StackAOutput", "TestOutput.json", "StackAOutputName"]} } InputArtifacts: - Name: TemplateSourceB - Name: StackAOutput RunOrder: '1'