-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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_vpn_gateway_attachment resource. #7870
Add aws_vpn_gateway_attachment resource. #7870
Conversation
Resolves #7810. Things to do:
|
I had a chat with @stack72 and we need to change the way how state of VPN Gateway is detected in the #7861, it should be corrected e.g., if len(vpnGateway.VpcAttachments) == 0 || *vpnGateway.VpcAttachments[0].State == "detached" || *vpnGateway.State == "deleted" {
d.Set("vpc_id", "")
} else {
d.Set("vpc_id", vpnGateway.VpcAttachments[0].VpcId)
} or vpnGateway := resp.VpnGateways[0]
if vpnGateway == nil || *vpnGateway.State == "deleted" {
d.SetId("")
return nil
} |
@kwilczynski we still need the part that does this |
@stack72 what I am suggesting is either to treat deleted gateway as "gone", and so to adda check here; resource_aws_vpn_gateway.go#L82-L87; or checking for "deleted" state along the VPN attachments (as per resource_aws_vpn_gateway.go#L89-L94, which might not be a good idea as "detached" will also satisfy the condition when the gateway is deleted (as VPN Gateway would return for a brief moment as being both deleted and detached) - this results only in clearing out the VPC ID and might not trigger new resource to be added. What do you think? I will test later to make sure that the logic holds water. |
@stack72 over to you! 🚀 |
Tests are passing:
|
4648a97
to
ed406d2
Compare
@@ -80,7 +81,7 @@ func resourceAwsVpnGatewayRead(d *schema.ResourceData, meta interface{}) error { | |||
} | |||
|
|||
vpnGateway := resp.VpnGateways[0] | |||
if vpnGateway == nil { | |||
if vpnGateway == nil || *vpnGateway.State == "deleted" { |
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.
if we are adding state == "deleted" here, then we should remove it from line 89 :)
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.
@stack72 corrected!
few small nit picks and then we are good to merge! :) |
Hey @kwilczynski Thanks for making the changes here - they look good. On a final run of the acceptance tests, I get an error:
|
@stack72 this is a side-effect of setting the My recommendation would be to change the re-attachment test, so that it would utilise two VPCs, first attach to the first one, then to the second one, and then back to the first one. Confirmation would: attachment still present with the first VPC and the second VPC attachment state would be detached. I will get to it shortly. |
25b0e65
to
4277071
Compare
Updated the test, which is now passing:
|
@stack72 over to you 🚀 |
edfe717
to
2f323ff
Compare
Added new item to do. I want to filter unattached and old VPN attachments, as there is no really a guarantee of any sort that the "attached" state is always under the 0 index in the list in the response. |
This commit adds VPN Gateway attachment resource, and also an initial tests and documentation stubs. Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
2f323ff
to
e06caa9
Compare
ok this now LGTM!
|
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This commit adds VPN Gateway attachment resource, and also an initial tests and documentation stubs.
Signed-off-by: Krzysztof Wilczynski krzysztof.wilczynski@linux.com