aws: Fix CloudFormation update for parameters & capabilities if not modified

This commit is contained in:
Oleg Chunikhin 2016-03-12 22:22:28 +00:00 committed by Radek Simko
parent 8612cc3373
commit 25383ad5a3
1 changed files with 10 additions and 5 deletions

View File

@ -268,7 +268,7 @@ func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface
StackName: aws.String(d.Get("name").(string)),
}
// Either TemplateBody or TemplateURL are required for each change
// Either TemplateBody, TemplateURL or UsePreviousTemplate are required
if v, ok := d.GetOk("template_url"); ok {
input.TemplateURL = aws.String(v.(string))
}
@ -276,15 +276,20 @@ func resourceAwsCloudFormationStackUpdate(d *schema.ResourceData, meta interface
input.TemplateBody = aws.String(normalizeJson(v.(string)))
}
if d.HasChange("capabilities") {
input.Capabilities = expandStringList(d.Get("capabilities").(*schema.Set).List())
// Capabilities must be present whether they are changed or not
if v, ok := d.GetOk("capabilities"); ok {
input.Capabilities = expandStringList(v.(*schema.Set).List())
}
if d.HasChange("notification_arns") {
input.NotificationARNs = expandStringList(d.Get("notification_arns").(*schema.Set).List())
}
if d.HasChange("parameters") {
input.Parameters = expandCloudFormationParameters(d.Get("parameters").(map[string]interface{}))
// Parameters must be present whether they are changed or not
if v, ok := d.GetOk("parameters"); ok {
input.Parameters = expandCloudFormationParameters(v.(map[string]interface{}))
}
if d.HasChange("policy_body") {
input.StackPolicyBody = aws.String(normalizeJson(d.Get("policy_body").(string)))
}