Skip to content

Commit

Permalink
Merge pull request #2133 from terraform-providers/b-kms-retry-rot
Browse files Browse the repository at this point in the history
r/aws_kms_key: Retry GetKeyRotationStatus on NotFoundException
  • Loading branch information
radeksimko authored Nov 5, 2017
2 parents 7b748c4 + 945c25f commit eb2d576
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions aws/resource_aws_kms_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,17 @@ func updateKmsKeyRotationStatus(conn *kms.KMS, d *schema.ResourceData) error {
Refresh: func() (interface{}, string, error) {
log.Printf("[DEBUG] Checking if KMS key %s rotation status is %t",
d.Id(), shouldEnableRotation)
resp, err := conn.GetKeyRotationStatus(&kms.GetKeyRotationStatusInput{
KeyId: aws.String(d.Id()),

out, err := retryOnAwsCode("NotFoundException", func() (interface{}, error) {
return conn.GetKeyRotationStatus(&kms.GetKeyRotationStatusInput{
KeyId: aws.String(d.Id()),
})
})
if err != nil {
return resp, "FAILED", err
return 42, "", err
}
resp, _ := out.(*kms.GetKeyRotationStatusOutput)

status := fmt.Sprintf("%t", *resp.KeyRotationEnabled)
log.Printf("[DEBUG] KMS key %s rotation status received: %s, retrying", d.Id(), status)

Expand Down

0 comments on commit eb2d576

Please sign in to comment.