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_cloudfront_key_group - new resource #17041

Merged
merged 9 commits into from
Apr 5, 2021

Conversation

shuheiktgw
Copy link
Collaborator

@shuheiktgw shuheiktgw commented Jan 10, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #15912

Release note for CHANGELOG:

* **New Resource:** `aws_cloudfront_key_group `

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSCloudFrontKeyGroup_*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSCloudFrontKeyGroup_* -timeout 120m
=== RUN   TestAccAWSCloudFrontKeyGroup_basic
=== PAUSE TestAccAWSCloudFrontKeyGroup_basic
=== RUN   TestAccAWSCloudFrontKeyGroup_disappears
=== PAUSE TestAccAWSCloudFrontKeyGroup_disappears
=== RUN   TestAccAWSCloudFrontKeyGroup_Comment
=== PAUSE TestAccAWSCloudFrontKeyGroup_Comment
=== RUN   TestAccAWSCloudFrontKeyGroup_Items
=== PAUSE TestAccAWSCloudFrontKeyGroup_Items
=== CONT  TestAccAWSCloudFrontKeyGroup_basic
=== CONT  TestAccAWSCloudFrontKeyGroup_Items
=== CONT  TestAccAWSCloudFrontKeyGroup_Comment
=== CONT  TestAccAWSCloudFrontKeyGroup_disappears
--- PASS: TestAccAWSCloudFrontKeyGroup_disappears (38.58s)
--- PASS: TestAccAWSCloudFrontKeyGroup_basic (46.54s)
--- PASS: TestAccAWSCloudFrontKeyGroup_Items (78.10s)
--- PASS: TestAccAWSCloudFrontKeyGroup_Comment (84.76s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	86.753s

Thank you for your review! 👍

@shuheiktgw shuheiktgw requested a review from a team as a code owner January 10, 2021 08:00
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. provider Pertains to the provider itself, rather than any interaction with AWS. service/cloudfront Issues and PRs that pertain to the cloudfront service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 10, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 10, 2021
@shuheiktgw shuheiktgw changed the title wip resource/aws_cloudfront_key_group - new resource Jan 10, 2021
@shuheiktgw shuheiktgw marked this pull request as draft January 10, 2021 08:01
@shuheiktgw shuheiktgw force-pushed the add_aws_cloudfront_key_group branch from 749bdd6 to 5156d19 Compare January 10, 2021 11:00
@ghost ghost added the documentation Introduces or discusses updates to documentation. label Jan 10, 2021
@shuheiktgw shuheiktgw marked this pull request as ready for review January 10, 2021 23:15
@shuheiktgw shuheiktgw force-pushed the add_aws_cloudfront_key_group branch from 5156d19 to aaa09e4 Compare January 17, 2021 00:24
Base automatically changed from master to main January 23, 2021 01:00
@ghost
Copy link

ghost commented Mar 3, 2021

@shuheiktgw it does not look that this PR could be cherry picked, it incomplete isn't it, how much work left to modify aws_cloudfront_distribution for key groups? I want to help

@shuheiktgw
Copy link
Collaborator Author

Hi @ysz, this PR is ready for review so once this is merged, I can modify aws_cloudfront_distribution resource for key groups.

@bflad bflad added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 31, 2021
@bflad bflad self-assigned this Mar 31, 2021
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Hi @shuheiktgw 👋 Thank you for submitting this. Overall looking pretty good. Please reach out if you have any questions.

Comment on lines 31 to 34
"id": {
Type: schema.TypeString,
Computed: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

A computed id attribute is implicitly handled by the Terraform Plugin SDK, which is why you do not see it typically implemented in resource schemas. 👍


output, err := conn.CreateKeyGroup(input)
if err != nil {
return fmt.Errorf("error creating CloudFront key group: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: To help with some future static analysis we'll be enabling

Suggested change
return fmt.Errorf("error creating CloudFront key group: %s", err)
return fmt.Errorf("error creating CloudFront Key Group: %w", err)

aws/resource_aws_cloudfront_key_group.go Show resolved Hide resolved

output, err := conn.GetKeyGroup(input)
if err != nil {
if isAWSErr(err, cloudfront.ErrCodeNoSuchResource, "") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Reference: #16796

Suggested change
if isAWSErr(err, cloudfront.ErrCodeNoSuchResource, "") {
if !d.IsNewResource && isAWSErr(err, cloudfront.ErrCodeNoSuchResource, "") {

d.SetId("")
return nil
}
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return err
return fmt.Errorf("error reading CloudFront Key Group (%s): %w", d.Id(), err)

Comment on lines 130 to 132
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(cloudfront.EndpointsID, t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudFrontKeyGroupDestroy,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(cloudfront.EndpointsID, t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudFrontKeyGroupDestroy,
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(cloudfront.EndpointsID, t) },
ErrorCheck: testAccErrorCheck(t, cloudfront.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudFrontKeyGroupDestroy,

Comment on lines 106 to 108
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(cloudfront.EndpointsID, t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudFrontKeyGroupDestroy,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(cloudfront.EndpointsID, t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudFrontKeyGroupDestroy,
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(cloudfront.EndpointsID, t) },
ErrorCheck: testAccErrorCheck(t, cloudfront.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudFrontKeyGroupDestroy,

items = [aws_cloudfront_public_key.test.id, aws_cloudfront_public_key.test2.id]
name = "tf-acc-test-%d"
}
`, rInt, rInt)
Copy link
Contributor

Choose a reason for hiding this comment

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

Go's fmt package supports indexed verbs, such as %[1]d that allow you not repeat parameters.


The following example below creates a CloudFront key group.

```hcl
Copy link
Contributor

Choose a reason for hiding this comment

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

Newer linting:

Suggested change
```hcl
```terraform

@@ -483,6 +483,7 @@ func Provider() *schema.Provider {
"aws_cloudformation_stack_set": resourceAwsCloudFormationStackSet(),
"aws_cloudformation_stack_set_instance": resourceAwsCloudFormationStackSetInstance(),
"aws_cloudfront_distribution": resourceAwsCloudFrontDistribution(),
"aws_cloudfront_key_group": resourceAwsCloudFrontKeyGroup(),
Copy link
Contributor

Choose a reason for hiding this comment

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

We can changelog this by adding a .changelog/17041.txt file with contents such as:

```release-note:new-resource
aws_cloudfront_key_group
```

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 31, 2021
@shuheiktgw
Copy link
Collaborator Author

$ make testacc TESTARGS='-run=TestAccAWSCloudFrontKeyGroup_'
=== RUN   TestAccAWSCloudFrontKeyGroup_Comment
=== PAUSE TestAccAWSCloudFrontKeyGroup_Comment
=== RUN   TestAccAWSCloudFrontKeyGroup_Items
=== PAUSE TestAccAWSCloudFrontKeyGroup_Items
=== CONT  TestAccAWSCloudFrontKeyGroup_basic
=== CONT  TestAccAWSCloudFrontKeyGroup_disappears
=== CONT  TestAccAWSCloudFrontKeyGroup_Items
=== CONT  TestAccAWSCloudFrontKeyGroup_Comment
--- PASS: TestAccAWSCloudFrontKeyGroup_disappears (49.65s)
--- PASS: TestAccAWSCloudFrontKeyGroup_basic (56.78s)
--- PASS: TestAccAWSCloudFrontKeyGroup_Comment (88.34s)
--- PASS: TestAccAWSCloudFrontKeyGroup_Items (90.59s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       92.640sq

@shuheiktgw
Copy link
Collaborator Author

@bflad Thank you for your review! I believe I've fixed it up so would you review the PR again?

@shuheiktgw shuheiktgw requested a review from bflad April 4, 2021 00:24
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Looks great, thank you, @shuheiktgw 🚀

Output from acceptance testing in AWS Commercial:

--- PASS: TestAccAWSCloudFrontKeyGroup_disappears (10.83s)
--- PASS: TestAccAWSCloudFrontKeyGroup_basic (12.39s)
--- PASS: TestAccAWSCloudFrontKeyGroup_Comment (19.26s)
--- PASS: TestAccAWSCloudFrontKeyGroup_Items (19.63s)

Output from acceptance testing in AWS GovCloud (US):

--- SKIP: TestAccAWSCloudFrontKeyGroup_basic (1.33s)
--- SKIP: TestAccAWSCloudFrontKeyGroup_disappears (1.33s)
--- SKIP: TestAccAWSCloudFrontKeyGroup_Comment (1.33s)
--- SKIP: TestAccAWSCloudFrontKeyGroup_Items (1.33s)

@bflad bflad merged commit 29c750a into hashicorp:main Apr 5, 2021
@github-actions github-actions bot added this to the v3.36.0 milestone Apr 5, 2021
@ghost
Copy link

ghost commented Apr 9, 2021

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented May 5, 2021

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 as resolved and limited conversation to collaborators May 5, 2021
@breathingdust breathingdust removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-resource Introduces a new resource. provider Pertains to the provider itself, rather than any interaction with AWS. service/cloudfront Issues and PRs that pertain to the cloudfront service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants