-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r/aws_backup_plan: Correctly handle changes to recovery_point_tags #10641
Conversation
… before testing 'recovery_point_tags' attribute.
$ make testacc TEST=./aws TESTARGS='-run=TestAccAwsBackupPlan_' ==> Checking that code complies with gofmt requirements... TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAwsBackupPlan_ -timeout 120m === RUN TestAccAwsBackupPlan_basic === PAUSE TestAccAwsBackupPlan_basic === RUN TestAccAwsBackupPlan_withTags === PAUSE TestAccAwsBackupPlan_withTags === RUN TestAccAwsBackupPlan_withRules === PAUSE TestAccAwsBackupPlan_withRules === RUN TestAccAwsBackupPlan_withLifecycle === PAUSE TestAccAwsBackupPlan_withLifecycle === RUN TestAccAwsBackupPlan_withRecoveryPointTags === PAUSE TestAccAwsBackupPlan_withRecoveryPointTags === RUN TestAccAwsBackupPlan_disappears === PAUSE TestAccAwsBackupPlan_disappears === CONT TestAccAwsBackupPlan_basic === CONT TestAccAwsBackupPlan_withRecoveryPointTags === CONT TestAccAwsBackupPlan_disappears === CONT TestAccAwsBackupPlan_withRules === CONT TestAccAwsBackupPlan_withLifecycle === CONT TestAccAwsBackupPlan_withTags --- PASS: TestAccAwsBackupPlan_disappears (19.33s) --- PASS: TestAccAwsBackupPlan_basic (20.82s) --- FAIL: TestAccAwsBackupPlan_withRecoveryPointTags (26.61s) testing.go:569: Step 1 error: errors during apply: Error: error updating Backup Plan (1104fa3b-5714-4c2e-9776-78660300ee6b): InvalidParameter: 2 validation error(s) found. - missing required field, UpdateBackupPlanInput.BackupPlan.Rules[0].RuleName. - missing required field, UpdateBackupPlanInput.BackupPlan.Rules[0].TargetBackupVaultName. on /tmp/tf-test417192270/main.tf line 6: (source code not available) --- PASS: TestAccAwsBackupPlan_withRules (47.10s) --- PASS: TestAccAwsBackupPlan_withTags (47.82s) --- PASS: TestAccAwsBackupPlan_withLifecycle (60.07s) FAIL FAIL github.com/terraform-providers/terraform-provider-aws/aws 60.128s FAIL GNUmakefile:24: recipe for target 'testacc' failed make: *** [testacc] Error 1
BackupPlanName: aws.String(d.Get("name").(string)), | ||
Rules: expandBackupPlanRules(d.Get("rule").(*schema.Set)), | ||
}, | ||
BackupPlanTags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().BackupTags(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use keyvaluetags
.
} | ||
|
||
rule := &schema.Set{F: resourceAwsPlanRuleHash} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor to flattenBackupPlanRules()
.
return fmt.Errorf("error setting rule: %s", err) | ||
} | ||
|
||
tagsOutput, err := conn.ListTags(&backup.ListTagsInput{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use keyvaluetags
.
BackupPlanId: aws.String(d.Id()), | ||
BackupPlan: plan, | ||
} | ||
if d.HasChange("rule") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only update if there's actually a change...
} | ||
|
||
if d.HasChange("tags") { | ||
resourceArn := d.Get("arn").(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use keyvaluetags
.
if vRuleName, ok := mRule["rule_name"].(string); ok && vRuleName != "" { | ||
rule.RuleName = aws.String(vRuleName) | ||
} else { | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same scenario as commented on here: https://github.com/terraform-providers/terraform-provider-aws/pull/6095/files#r226842239.
if v, ok := m["start_window"]; ok { | ||
buf.WriteString(fmt.Sprintf("%d-", v.(interface{}))) | ||
if vRecoveryPointTags, ok := mRule["recovery_point_tags"].(map[string]interface{}); ok && len(vRecoveryPointTags) > 0 { | ||
buf.WriteString(fmt.Sprintf("%d-", tagsMapToHash(vRecoveryPointTags))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stable has value (not strictly necessary after Go 1.12).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @ewbankkit, LGTM
--- PASS: TestAccAwsBackupPlan_disappears (9.31s)
--- PASS: TestAccAwsBackupPlan_basic (9.48s)
--- PASS: TestAccAwsBackupPlan_withRules (19.28s)
--- PASS: TestAccAwsBackupPlan_withRecoveryPointTags (19.40s)
--- PASS: TestAccAwsBackupPlan_withTags (19.97s)
--- PASS: TestAccAwsBackupPlan_withLifecycle (24.67s)
This has been released in version 2.34.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Closes #8431,
Closes #9502.
Closes #8193.
Closes #8737.
Release note for CHANGELOG:
Output from acceptance testing: