Skip to content

Commit

Permalink
Merge pull request #1854 from terraform-providers/b-kms-key-retry-get…
Browse files Browse the repository at this point in the history
…-policy

r/kms_key: Retry getting key policy
  • Loading branch information
radeksimko authored Oct 10, 2017
2 parents 3e31e4f + 61ae786 commit 6f1f9c2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions aws/resource_aws_kms_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,17 @@ func resourceAwsKmsKeyRead(d *schema.ResourceData, meta interface{}) error {
d.Set("key_usage", metadata.KeyUsage)
d.Set("is_enabled", metadata.Enabled)

p, err := conn.GetKeyPolicy(&kms.GetKeyPolicyInput{
KeyId: metadata.KeyId,
PolicyName: aws.String("default"),
pOut, err := retryOnAwsCode("NotFoundException", func() (interface{}, error) {
return conn.GetKeyPolicy(&kms.GetKeyPolicyInput{
KeyId: metadata.KeyId,
PolicyName: aws.String("default"),
})
})
if err != nil {
return err
}

p := pOut.(*kms.GetKeyPolicyOutput)
policy, err := normalizeJsonString(*p.Policy)
if err != nil {
return errwrap.Wrapf("policy contains an invalid JSON: {{err}}", err)
Expand Down

0 comments on commit 6f1f9c2

Please sign in to comment.