-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Conversation
749bdd6
to
5156d19
Compare
5156d19
to
aaa09e4
Compare
@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 |
Hi @ysz, this PR is ready for review so once this is merged, I can modify aws_cloudfront_distribution resource for key groups. |
There was a problem hiding this 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.
"id": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
}, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
return fmt.Errorf("error creating CloudFront key group: %s", err) | |
return fmt.Errorf("error creating CloudFront Key Group: %w", err) |
|
||
output, err := conn.GetKeyGroup(input) | ||
if err != nil { | ||
if isAWSErr(err, cloudfront.ErrCodeNoSuchResource, "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reference: #16796
if isAWSErr(err, cloudfront.ErrCodeNoSuchResource, "") { | |
if !d.IsNewResource && isAWSErr(err, cloudfront.ErrCodeNoSuchResource, "") { |
d.SetId("") | ||
return nil | ||
} | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return err | |
return fmt.Errorf("error reading CloudFront Key Group (%s): %w", d.Id(), err) |
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(cloudfront.EndpointsID, t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckCloudFrontKeyGroupDestroy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
PreCheck: func() { testAccPreCheck(t); testAccPartitionHasServicePreCheck(cloudfront.EndpointsID, t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckCloudFrontKeyGroupDestroy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newer linting:
```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(), |
There was a problem hiding this comment.
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 Thank you for your review! I believe I've fixed it up so would you review the PR again? |
There was a problem hiding this 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)
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! |
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! |
Community Note
Relates #15912
Release note for CHANGELOG:
Output from acceptance testing:
Thank you for your review! 👍