Attempting to update a single key/value of a parameter in an existing Cloudformation template.
...
svc := cloudformation.New(AWSSession)
// Add parameters. Used in AWS CreateStack/UpdateStack call
var params []*cloudformation.Parameter
for key, val := range cfnparamsOverrides {
log.Printf("Adding parameter key-> %v value-> %v", key, val)
param := &cloudformation.Parameter{}
param.ParameterKey = aws.String(key)
param.ParameterValue = aws.String(val)
params = append(params, param)
}
CreateChangeSetInput := &cloudformation.CreateChangeSetInput{
StackName: aws.String(stackARN), // required field.
ChangeSetName: aws.String(ChangeSetName), // must be a unique value
ChangeSetType: aws.String("UPDATE"),
// TemplateBody: aws.String(templateBody),
UsePreviousTemplate: aws.Bool(true),
Parameters: params}
// Issue AWS CreateChangeSet API call
log.Println("Issuing AWS CreateChangeSet() API call")
_, errCreateChangeSet := svc.CreateChangeSet(CreateChangeSetInput)
if errCreateChangeSet != nil {
return false, fmt.Errorf("Got error on CreateChangeSet: %v", errCreateChangeSet.Error())
}
only 1 value is being set, but cloudformation template validation throws the following: ValidationError: Parameters: [Key1, Key2, Key3, ...] must have values
It seems to be requiring key/value for all the cloudformation paramters existing in the template. Is there a way to only provide the new/existing key/value pair I need updated?
Within the golang aws documentation I discovered the *cloudformation.Parameter struct has a UsePreviousValue for each value. However I don't see the use of this other than to avoid modifying the existing value, it still requires I provide the same paramaters keys in the deployed cfn template.
Am I missing something? It seems like a relatively straight forward approach to update an existing value in a deployed environment.
Wondering how others are going about this. Should I be querying the existing environment to read in all the parameters key/values, modify the 1 I need, and then submit changeset?