Skip to content
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

ses: Improve diffs for policies #28861

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/28861.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_ses_identity_policy: Improve refresh to avoid unnecessary diffs in `policy`
```
12 changes: 5 additions & 7 deletions internal/service/ses/identity_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ func ResourceIdentityPolicy() *schema.Resource {
),
},
"policy": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsJSON,
DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs,
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringIsJSON,
DiffSuppressFunc: verify.SuppressEquivalentPolicyDiffs,
DiffSuppressOnRefresh: true,
StateFunc: func(v interface{}) string {
json, _ := structure.NormalizeJsonString(v)
return json
Expand All @@ -61,7 +62,6 @@ func resourceIdentityPolicyCreate(d *schema.ResourceData, meta interface{}) erro
policyName := d.Get("name").(string)

policy, err := structure.NormalizeJsonString(d.Get("policy").(string))

if err != nil {
return fmt.Errorf("policy (%s) is invalid JSON: %w", d.Get("policy").(string), err)
}
Expand Down Expand Up @@ -91,7 +91,6 @@ func resourceIdentityPolicyUpdate(d *schema.ResourceData, meta interface{}) erro
}

policy, err := structure.NormalizeJsonString(d.Get("policy").(string))

if err != nil {
return fmt.Errorf("policy (%s) is invalid JSON: %w", d.Get("policy").(string), err)
}
Expand Down Expand Up @@ -150,7 +149,6 @@ func resourceIdentityPolicyRead(d *schema.ResourceData, meta interface{}) error
d.Set("name", policyName)

policyToSet, err := verify.PolicyToSet(d.Get("policy").(string), aws.StringValue(policy))

if err != nil {
return err
}
Expand Down