-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add 'aws_ec2_client_vpn_endpoint.tags' attribute #7619
Conversation
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.
Should be good to go after some minor changes. Thanks, @ewbankkit
@@ -235,6 +237,11 @@ func resourceAwsEc2ClientVpnEndpointRead(d *schema.ResourceData, meta interface{ | |||
return err | |||
} | |||
|
|||
err = d.Set("tags", tagsToMap(result.ClientVpnEndpoints[0].Tags)) | |||
if err != 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.
We should return error context here for operators and code maintainers, e.g.
return err | |
return fmt.Errorf("error setting tags: %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.
I'll also add error context to the previous 2 calls to d.Set()
for authentication_options
and connection_log_options
.
return fmt.Errorf("Error modifying Client VPN endpoint: %s", err) | ||
} | ||
|
||
if err := setTags(conn, d); err != nil { | ||
return err | ||
} else { |
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.
Since the previous conditional calls return
, the else
and nesting are extraneous
aws/tags.go
Outdated
@@ -476,3 +476,17 @@ func tagsMapToRaw(m map[string]string) map[string]interface{} { | |||
|
|||
return raw | |||
} | |||
|
|||
// tagSpecificationsFromMap returns the tag specifications for the given map of data and resource type. | |||
func tagSpecificationsFromMap(m map[string]interface{}, t string) []*ec2.TagSpecification { |
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.
Since the Go package structure is currently flat across all services, this should include ec2 in the function naming. I'd also recommend clarifying what the input parameters are for Go code tooling.
func ec2TagSpecificationsFromMap(tags map[string]interface{}, resourceType string) []*ec2.TagSpecification {
Made suggested changes. $ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsEc2ClientVpnEndpoint_tags'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccAwsEc2ClientVpnEndpoint_tags -timeout 120m
=== RUN TestAccAwsEc2ClientVpnEndpoint_tags
--- PASS: TestAccAwsEc2ClientVpnEndpoint_tags (49.89s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 49.953s |
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 good @ewbankkit, thanks! 🚀
Output from acceptance testing:
--- PASS: TestAccAwsEc2ClientVpnEndpoint_basic (19.12s)
--- PASS: TestAccAwsEc2ClientVpnEndpoint_withDNSServers (27.83s)
--- PASS: TestAccAwsEc2ClientVpnEndpoint_withLogGroup (31.50s)
--- PASS: TestAccAwsEc2ClientVpnEndpoint_tags (36.90s)
--- PASS: TestAccAwsEc2ClientVpnEndpoint_msAD (1787.33s)
@@ -227,12 +229,17 @@ func resourceAwsEc2ClientVpnEndpointRead(d *schema.ResourceData, meta interface{ | |||
|
|||
err = d.Set("authentication_options", flattenAuthOptsConfig(result.ClientVpnEndpoints[0].AuthenticationOptions)) | |||
if err != nil { | |||
return err | |||
return fmt.Errorf("error setting authentication_options: %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.
😍
This has been released in version 2.1.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Fixes #7603.
Acceptance tests: