-
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
provider/aws: Implementing vpc_peering_connection_accept
#6843
Conversation
Status
|
vpc_peering_connection_accept
vpc_peering_connection_accept
What happens then? |
Currently an operator has to manually accept the peering connection in the target account, usually in the AWS console. This resource would enable us to fully automate cross-account VPC peering, using aliased AWS providers in TF. |
Err, @catsby... Sorry autocorrect on mobile |
Ah, I see.. so we solve this with the current resource with |
@catsby exactly, |
That's correct @catsby. I updated the original overview. |
75bf0ed
to
4316878
Compare
vpc_peering_connection_accept
vpc_peering_connection_accept
@catsby ready for review |
e6e6877
to
5b7ca87
Compare
@catsby any word on review? |
Any update on this? would love to see something like this implemented. I know that CloudFormation doesn't even support this natively. I solved it in CloudFormation using a |
Hi @BSick7! Thanks for the pull request and the clarifications. Sorry this has taken us a while to get around to, but someone will give it some attention shortly and get it merged. We're in the process of making some changes to the test framework to allow for cross account testing which will make it possible to run acceptance tests on this during the nightly build. Probably @stack72 will pick this up and land it once those changes are in. |
@BSick7, Could you please add tag support to the PR? |
} | ||
d.Set("accept_status", status) | ||
|
||
// TODO: should we poll until this resolves? VpcPeeringConnectionStateReasonCodePendingAcceptance |
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.
Yes, it didn't work for me until after I added:
stateConf := &resource.StateChangeConf{
Pending: []string{"pending-acceptance"},
Target: []string{"active"},
Refresh: resourceAwsVPCPeeringConnectionStateRefreshFunc(conn, d.Id()),
Timeout: 1 * time.Minute,
}
if _, err := stateConf.WaitForState(); err != nil {
return errwrap.Wrapf(fmt.Sprintf(
"Error waiting for VPC Peering Connection Accept (%s) to become available: {{err}}",
d.Id()), err)
}
return nil | ||
} | ||
|
||
status, err := resourceVPCPeeringConnectionAccept(conn, d.Id()) |
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.
The d.Id() was not immediately available for me, I had to assign it explicitly:
d.SetId(d.Get("peering_connection_id").(string))
The documentation mentions ownership of both VPCs for aws_vpc_peering_connection auto_accept to work but if both VPC are in separate accounts it does not matter if both account are owned or not. In hashicorp#6843 its stated that aws_vpc_peering_connection only works if both VPC are in the same AWS account. The documentation fails to mention that peeing of two VPCs in two different regions is not supported by AWS.
I suggest to add language to the docs of both commands that points out that aws_vpc_peering_connection in multi account setups requires vpc_peering_connection_accept |
The documentation mentions ownership of both VPCs for aws_vpc_peering_connection auto_accept to work but if both VPC are in separate accounts it does not matter if both account are owned or not. In #6843 its stated that aws_vpc_peering_connection only works if both VPC are in the same AWS account. The documentation fails to mention that peeing of two VPCs in two different regions is not supported by AWS.
The documentation mentions ownership of both VPCs for aws_vpc_peering_connection auto_accept to work but if both VPC are in separate accounts it does not matter if both account are owned or not. In hashicorp#6843 its stated that aws_vpc_peering_connection only works if both VPC are in the same AWS account. The documentation fails to mention that peeing of two VPCs in two different regions is not supported by AWS.
Hey there –
Unfortunately, without access to 2 accounts in the test, I don't believe the test is really testing this new resource. Alternatively, what do you think about adding a |
+1 to adding Account A (requester):
Account B (accepter):
|
+1 This would be very useful. |
I merged #11505, which included this one. 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 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. |
Problem
Currently
aws_vpc_peering_connection
provides a way toauto_accept
a peering connection. This works great until you have a peering connection between 2 VPCs that are in different aws accounts. If you specifyauto_accept = true
to automate the peering connection accept, aws will error during a terraform apply that you are not authorized to accept.Solution
The solution is to utilize provider aliases to execute the accept under different aws account credentials. See example below.