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

Add 'aws_ec2_client_vpn_endpoint.tags' attribute #7619

Merged
merged 2 commits into from
Mar 4, 2019

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Feb 20, 2019

Fixes #7603.
Acceptance tests:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAwsEc2ClientVpnEndpoint_'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws/ -v -parallel 20 -run=TestAccAwsEc2ClientVpnEndpoint_ -timeout 120m
=== RUN   TestAccAwsEc2ClientVpnEndpoint_basic
--- PASS: TestAccAwsEc2ClientVpnEndpoint_basic (24.33s)
=== RUN   TestAccAwsEc2ClientVpnEndpoint_msAD
--- PASS: TestAccAwsEc2ClientVpnEndpoint_msAD (1764.63s)
=== RUN   TestAccAwsEc2ClientVpnEndpoint_withLogGroup
--- PASS: TestAccAwsEc2ClientVpnEndpoint_withLogGroup (37.06s)
=== RUN   TestAccAwsEc2ClientVpnEndpoint_withDNSServers
--- PASS: TestAccAwsEc2ClientVpnEndpoint_withDNSServers (32.11s)
=== RUN   TestAccAwsEc2ClientVpnEndpoint_tags
--- PASS: TestAccAwsEc2ClientVpnEndpoint_tags (44.86s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	1903.023s

@ghost ghost added service/ec2 Issues and PRs that pertain to the ec2 service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. size/L Managed by automation to categorize the size of a PR. labels Feb 20, 2019
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.

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
Copy link
Contributor

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.

Suggested change
return err
return fmt.Errorf("error setting tags: %s", err)

Copy link
Contributor Author

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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 {

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 4, 2019
@ewbankkit
Copy link
Contributor Author

Made suggested changes.
Relevant acceptance test:

$ 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

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 4, 2019
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Mar 4, 2019
@bflad bflad added this to the v2.1.0 milestone Mar 4, 2019
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 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)
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

@bflad bflad merged commit 7feacd2 into hashicorp:master Mar 4, 2019
bflad added a commit that referenced this pull request Mar 4, 2019
@ewbankkit ewbankkit deleted the issue-7603 branch March 4, 2019 21:31
@bflad
Copy link
Contributor

bflad commented Mar 8, 2019

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.

@ghost
Copy link

ghost commented Mar 31, 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 Mar 31, 2020
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. enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service. size/L 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.

r/aws_ec2_client_vpn_endpoint: Add support for resource tags
2 participants