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

resource/aws_iam_user_policy: Fix updates with generated policy names and validate JSON #3031

Merged
merged 2 commits into from
Jan 18, 2018

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jan 17, 2018

Replaces bugfix portions of #2450
Closes #781

This also refactors the acceptance testing to check attributes, test policy updates for name/name_prefix/generated names, and starts to reuse test configurations where possible (e.g testAccAWSUserConfig from aws_iam_user tests).

make testacc TEST=./aws TESTARGS='-run=TestAccAWSIAMUserPolicy'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSIAMUserPolicy -timeout 120m
=== RUN   TestAccAWSIAMUserPolicy_basic
--- PASS: TestAccAWSIAMUserPolicy_basic (14.98s)
=== RUN   TestAccAWSIAMUserPolicy_namePrefix
--- PASS: TestAccAWSIAMUserPolicy_namePrefix (15.72s)
=== RUN   TestAccAWSIAMUserPolicy_generatedName
--- PASS: TestAccAWSIAMUserPolicy_generatedName (13.47s)
=== RUN   TestAccAWSIAMUserPolicy_multiplePolicies
--- PASS: TestAccAWSIAMUserPolicy_multiplePolicies (25.55s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	69.761s

… and validate JSON

This also refactors the acceptance testing to check attributes and reuse test configurations.
@@ -57,7 +59,9 @@ func resourceAwsIamUserPolicyPut(d *schema.ResourceData, meta interface{}) error
}

var policyName string
if v, ok := d.GetOk("name"); ok {
if d.Id() != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: For folks who're not familiar with the significance of ID so using !d.IsNewResource() may be easier to understand for the reader here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly easier to grok! Works like a charm 🚀

make testacc TEST=./aws TESTARGS='-run=TestAccAWSIAMUserPolicy'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSIAMUserPolicy -timeout 120m
=== RUN   TestAccAWSIAMUserPolicy_basic
--- PASS: TestAccAWSIAMUserPolicy_basic (15.01s)
=== RUN   TestAccAWSIAMUserPolicy_namePrefix
--- PASS: TestAccAWSIAMUserPolicy_namePrefix (15.87s)
=== RUN   TestAccAWSIAMUserPolicy_generatedName
--- PASS: TestAccAWSIAMUserPolicy_generatedName (12.56s)
=== RUN   TestAccAWSIAMUserPolicy_multiplePolicies
--- PASS: TestAccAWSIAMUserPolicy_multiplePolicies (26.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	69.492s

@bflad bflad merged commit 9f55bc4 into master Jan 18, 2018
@bflad bflad deleted the b-aws_iam_user_policy-multiple-fixes branch January 18, 2018 13:18
bflad added a commit that referenced this pull request Jan 18, 2018
@bflad
Copy link
Contributor Author

bflad commented Jan 22, 2018

This has been released in terraform-provider-aws version 1.7.1. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

drewsonne pushed a commit to drewsonne/terraform-provider-aws that referenced this pull request Mar 3, 2018
@ghost
Copy link

ghost commented Apr 8, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/iam Issues and PRs that pertain to the iam service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating a aws_iam_user_policy causes multiple policies to be attached to an IAM user.
2 participants