Use existing DBUser and DBPassword parameter values when updating stack

Viewed 101

Does anyone know, if there's an option to use some kind of 'existingDBUser' and 'existingDBPassword parameter while describing DBUser and DBPassword in a Cloudformation template?

I don't want to use 'Default' params and when deploying template via cli it asks me for DBUser and DBPassword.

In my case if I specify that and it's different than ones assigned already to DBCluster it creates a new cluster instead of updating existing one.

There's a way to upload the template via AWS Console, where you can check the 'use existing' boxes.

How can I do that from CLI perspective? Thanks for replies.

1 Answers

Yes, this is possible. You don't define this in the template, you specify this when you call the update stack command from the SDK or CLI.

You need to specify the "UsePreviousValue" attribute of the parameter when calling the UpdateStack.

Here is an example of how you would do it on the AWS CLI but the SDKs should also provide a similar functionality:

aws cloudformation update-stack \
   --stack-name mystack \
   --template-url https://s3.amazonaws.com/sample/updated.template \
   --parameters ParameterKey=DBUser,UsePreviousValue=true \
                ParameterKey=DBPassword,UsePreviousValue=true
Related