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

r/aws_ec2_client_vpn_endpoint_network_association: Adding option to apply additional security groups to target network #7500

Closed

Conversation

slapula
Copy link
Contributor

@slapula slapula commented Feb 11, 2019

Fixes #7495

Changes proposed in this pull request:

  • Making vpc_id and security_groups actual parameters so we can use those values to add additional security groups to a target network.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAwsEc2ClientVpnNetworkAssociation_securityGroups'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAwsEc2ClientVpnNetworkAssociation_securityGroups -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAwsEc2ClientVpnNetworkAssociation_securityGroups
=== PAUSE TestAccAwsEc2ClientVpnNetworkAssociation_securityGroups
=== CONT  TestAccAwsEc2ClientVpnNetworkAssociation_securityGroups
--- PASS: TestAccAwsEc2ClientVpnNetworkAssociation_securityGroups (455.51s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	455.527s

@ghost ghost added size/L Managed by automation to categorize the size of a PR. 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. labels Feb 11, 2019
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Feb 12, 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.

Hey @slapula 👋Thanks for submitting this. Left some initial review items below. Please reach out if you have any questions or do not have time to implement the feedback.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 12, 2019
@slapula
Copy link
Contributor Author

slapula commented Feb 12, 2019

@bflad Thanks again for your feedback. I believe I've addressed all of your comments.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Feb 12, 2019
testAccCheckAwsEc2ClientVpnNetworkAssociationExists("aws_ec2_client_vpn_network_association.test", &assoc1),
resource.TestCheckResourceAttr("aws_ec2_client_vpn_network_association.test", "security_groups.#", "2"),
),
},
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 include another TestStep here that performs some form of update 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One thing I'm noticing with the Update function is that ApplySecurityGroupsToClientVpnTargetNetwork call doesn't zero out security_groups it just replaces ones that are already there. Going from 2 security groups to zero means that the call ignores the empty request and leaves the security groups untouched. Weird, but not unmanageable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry that was what I was trying to say in #7500 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I think I see what you are saying. See my latest commit. I was able to get the behavior I'm looking for by making security_groups a required parameter (to account for the API adding the default VPC security group in the absence of custom groups). Not ideal but it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Scratch that, Travis doesn't like the Required + Computed part.

@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Feb 13, 2019
subnet_id = "${aws_subnet.example.id}"
client_vpn_endpoint_id = "${aws_ec2_client_vpn_endpoint.example.id}"
subnet_id = "${aws_subnet.example.id}"
security_groups = [""]
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be omitted in this case.

@@ -26,12 +37,13 @@ The following arguments are supported:

* `client_vpn_endpoint_id` - (Required) The ID of the Client VPN endpoint.
* `subnet_id` - (Required) The ID of the subnet to associate with the Client VPN endpoint.
* `security_groups` - (Required) A list of up to five custom security groups to apply to the target network. Not populating this parameter will result in the subnet inheriting the default VPC security group. Regardless of what you choose, you must define this parameter due to the AWS API automatically assigning the default VPC security group if no other groups are included in the call.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be updated back to Optional.

Suggested change
* `security_groups` - (Required) A list of up to five custom security groups to apply to the target network. Not populating this parameter will result in the subnet inheriting the default VPC security group. Regardless of what you choose, you must define this parameter due to the AWS API automatically assigning the default VPC security group if no other groups are included in the call.
* `security_groups` - (Optional) A list of up to five custom VPC security groups to apply to the target network. Not populating this parameter will result in the subnet inheriting the default VPC security group. To remove all custom VPC security groups, this list must be configured to contain only the default VPC security group.

@slapula
Copy link
Contributor Author

slapula commented Feb 14, 2019

@bflad I did a lot of thinking about how all these parts work together around the VPN endpoint and I think it makes sense to consolidate network associations into the endpoint resource (See #7564). I have pulled in the changes made here into that PR. Take a look and let me know what you think. If that's the preferred route, then we can probably close this out.

@bryanlikes
Copy link

Is this PR being abandoned in favor of #7564? It would be great to get this functionality in since client vpn still requires manual configuration of ingress authorization, securitygroups, routes.

@slapula
Copy link
Contributor Author

slapula commented May 30, 2019

@bryanlikes That is my intention, but I've been waiting on more movement with my other PR before closing out this one.

@connor-tyndall
Copy link
Contributor

+1

@gdavison gdavison self-assigned this Jun 25, 2020
@gdavison gdavison added this to the v3.0.0 milestone Jul 10, 2020
@slapula slapula requested a review from a team July 21, 2020 18:26
@bflad bflad modified the milestones: v3.0.0, v3.1.0 Jul 30, 2020
@bflad bflad removed this from the v3.1.0 milestone Aug 7, 2020
@bflad bflad added this to the v3.2.0 milestone Aug 7, 2020
@gdavison gdavison modified the milestones: v3.2.0, v3.3.0 Aug 14, 2020
@bflad bflad closed this in #14146 Aug 20, 2020
@bflad
Copy link
Contributor

bflad commented Aug 20, 2020

These commits were merged as part of #14146 and will release with version 3.3.0, later today. 👍

@ghost
Copy link

ghost commented Aug 20, 2020

This has been released in version 3.3.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 Sep 19, 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 Sep 19, 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/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.

Client VPN Endpoint - Allow Custom Security Groups
5 participants