Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

aws cloudformation use previous value stack parameter

Adam Whiteland January 19, 2022

I have the need to update a cloudformation stack with some new parameters. I would like to do that using the aws cloudformation pipe like this:

script:
  - pipe: atlassian/aws-cloudformation-deploy:0.13.0
    variables:
      AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
      AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
      AWS_DEFAULT_REGION: 'us-east-1'
      STACK_NAME: 'my-stack-name'
      TEMPLATE: 'https://s3.amazonaws.com/cfn-deploy-pipe/cfn-template.json'
      STACK_PARAMETERS: >
          [{
            "ParameterKey": "KeyName",
            "ParameterValue": "mykey"
          },
          {
            "ParameterKey": "DBUser",
            "ParameterValue": "mydbuser"
          },
          {
            "ParameterKey": "DBPassword",
            "ParameterValue": $DB_PASSWORD

But I also have parameters that I won't define in my pipeline and simply use what the previous value was for the parameter, which I would have setup manually through the aws console. This is how I would do it using the aws cli:

aws cloudformation update-stack --stack-name stack-name --use-previous-template --parameters ParameterKey=KeyName,ParameterValue=mykey ParameterKey=DBPassword,UsePreviousValue=true

 Does the aws cloudformation pipe support the use of previous values in the STACK_PARAMETERS option?

1 answer

0 votes
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 21, 2022

@Adam Whiteland hi. Thanks for your question.

You should use extra parameters:

script:
  - pipe: atlassian/aws-cloudformation-deploy:0.13.0
    variables:
      AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
      AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
      AWS_DEFAULT_REGION: 'us-east-1'
      STACK_NAME: 'my-stack-name'
      TEMPLATE: 'https://s3.amazonaws.com/cfn-deploy-pipe/cfn-template.json'
      STACK_PARAMETERS: >
          [{
            "ParameterKey": "KeyName",
            "ParameterValue": "mykey"
          },
          {
            "ParameterKey": "DBUser",
            "ParameterValue": "mydbuser"
          },
          {
            "ParameterKey": "DBPassword",
            "ParameterValue": $DB_PASSWORD
}]
EXTRA_PARAMETERS: > { "UsePreviousTemplate": true
}

Regards, Igor

Ashish Kataria
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 12, 2022

I don't think UsePreviousTemplate (for a stack) and UsePreviousValue (for a stack param) are the same.

This is how they are different:

You don't need to specify the template if you use UsePreviousTemplate.

You don't need to specify the parameter value if you use UsePreviousValue.

 

I couldn't find any doc on the cloudformation pipe which clearly says that UsePreviousValue is supported.

 

Can you please specify some link to a doc to verify this?

Like Adam Whiteland likes this
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 13, 2022

@Ashish Kataria hi. Our pipe based on boto3 implementation.
Here is link to boto3 cloudformation update stack.
In pipe it should work something like this:

      EXTRA_PARAMETERS: >
        {
            "UsePreviousTemplate": true,
"Parameters":[ { 'ParameterKey': 'string', 'ParameterValue': 'string', 'UsePreviousValue': True|False, 'ResolvedValue': 'string' } ]
}

Also link to amazon guide

Regards, Igor

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events