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_policy: Ensure description is properly read during creation #5884

Merged
merged 1 commit into from Sep 14, 2018

Conversation

bflad
Copy link
Member

@bflad bflad commented Sep 14, 2018

Found via acceptance testing after merging #5815

This resource was previously not following best practices of calling the read function after creation. Now it will read back information from the API, which tangentially fixes the description not being available in the CreatePolicy response and the resource always calling d.Set("description", "").

Changes:

  • Create separate acceptance tests for all arguments (fixing the naming to TestAccAWSIAMPolicy_)
  • Call read function after create and update functions
  • Create testAccCheckResourceAttrGlobalARN for checking global ARN attributes
  • Remove extraneous aws/import_aws_iam_policy_test.go

Previously (before code updates):

=== RUN   TestAccAWSIAMPolicy_basic
--- PASS: TestAccAWSIAMPolicy_basic (10.15s)
=== RUN   TestAccAWSIAMPolicy_description
--- FAIL: TestAccAWSIAMPolicy_description (5.06s)
    testing.go:527: Step 0 error: Check failed: Check 2/2 error: aws_iam_policy.test: Attribute 'description' expected "description1", got ""
=== RUN   TestAccAWSIAMPolicy_namePrefix
--- PASS: TestAccAWSIAMPolicy_namePrefix (9.72s)
=== RUN   TestAccAWSIAMPolicy_path
--- PASS: TestAccAWSIAMPolicy_path (9.85s)
=== RUN   TestAccAWSIAMPolicy_policy
--- PASS: TestAccAWSIAMPolicy_policy (13.49s)

Now:

=== RUN   TestAccAWSIAMPolicy_basic
--- PASS: TestAccAWSIAMPolicy_basic (10.29s)
=== RUN   TestAccAWSIAMPolicy_description
--- PASS: TestAccAWSIAMPolicy_description (8.00s)
=== RUN   TestAccAWSIAMPolicy_namePrefix
--- PASS: TestAccAWSIAMPolicy_namePrefix (9.15s)
=== RUN   TestAccAWSIAMPolicy_path
--- PASS: TestAccAWSIAMPolicy_path (9.25s)
=== RUN   TestAccAWSIAMPolicy_policy
--- PASS: TestAccAWSIAMPolicy_policy (15.21s)

…reation

This resource was previously not following best practices of calling the read function after creation. Now it will read back information from the API, which tangentally fixes the description not being available in the CreatePolicy response.

Changes:
* Create separate acceptance tests for all arguments
* Call read function after create and update functions
* Create `testAccCheckResourceAttrGlobalARN` for checking global ARN attributes
* Remove extraneous aws/import_aws_iam_policy_test.go

Previously (before code updates):

```
=== RUN   TestAccAWSIAMPolicy_basic
--- PASS: TestAccAWSIAMPolicy_basic (10.15s)
=== RUN   TestAccAWSIAMPolicy_description
--- FAIL: TestAccAWSIAMPolicy_description (5.06s)
    testing.go:527: Step 0 error: Check failed: Check 2/2 error: aws_iam_policy.test: Attribute 'description' expected "description1", got ""
=== RUN   TestAccAWSIAMPolicy_namePrefix
--- PASS: TestAccAWSIAMPolicy_namePrefix (9.72s)
=== RUN   TestAccAWSIAMPolicy_path
--- PASS: TestAccAWSIAMPolicy_path (9.85s)
=== RUN   TestAccAWSIAMPolicy_policy
--- PASS: TestAccAWSIAMPolicy_policy (13.49s)
```

Now:

```
=== RUN   TestAccAWSIAMPolicy_basic
--- PASS: TestAccAWSIAMPolicy_basic (10.29s)
=== RUN   TestAccAWSIAMPolicy_description
--- PASS: TestAccAWSIAMPolicy_description (8.00s)
=== RUN   TestAccAWSIAMPolicy_namePrefix
--- PASS: TestAccAWSIAMPolicy_namePrefix (9.15s)
=== RUN   TestAccAWSIAMPolicy_path
--- PASS: TestAccAWSIAMPolicy_path (9.25s)
=== RUN   TestAccAWSIAMPolicy_policy
--- PASS: TestAccAWSIAMPolicy_policy (15.21s)
```
@bflad bflad added bug Addresses a defect in current functionality. service/iam Issues and PRs that pertain to the iam service. labels Sep 14, 2018
@bflad bflad requested a review from a team September 14, 2018 16:53
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Sep 14, 2018
Copy link
Contributor

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

LGTM 👌

@bflad bflad added this to the v1.37.0 milestone Sep 14, 2018
@bflad bflad merged commit ba4ed34 into master Sep 14, 2018
@bflad bflad deleted the b-aws_iam_policy-description-on-creation branch September 14, 2018 17:55
bflad added a commit that referenced this pull request Sep 14, 2018
@bflad
Copy link
Member Author

bflad commented Sep 19, 2018

This has been released in version 1.37.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 3, 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!

@hashicorp hashicorp locked and limited conversation to collaborators Apr 3, 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. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants