rhythmic-megabyte-99595
11/28/2023, 6:51 PMconnection_id = ec2.VpcPeeringConnection(
f"vpcPeering-{loca_vpc}->{remote_vpc}",
opts=pulumi.ResourceOptions(provider=local_provider),
vpc_id=local_vpc.id,
peer_vpc_id=remote_vpc_id,
peer_owner_id=local_account_id,
auto_accept=False,
)
and the error is
The vpc ID 'vpc-remote' does not exist
rhythmic-megabyte-99595
11/28/2023, 7:26 PMpeer_owner_id
to remote_account_id
(which diverged from the example here and does not make sense), then the peer_connection works but now the accepter has issues. Following is the code:
connection_id = ec2.VpcPeeringConnection(
f"vpcPeering-{loca_vpc}->{remote_vpc}",
opts=pulumi.ResourceOptions(provider=local_provider),
vpc_id=local_vpc.id,
peer_vpc_id=remote_vpc_id,
peer_owner_id=remote_account_id,
auto_accept=False,
).id
ec2.VpcPeeringConnectionAccepter(
"peer-accepter",
vpc_peering_connection_id=connection_id,
auto_accept=True,
opts=pulumi.ResourceOptions(provider=remote_provider),
)
now it gave me this:
The vpc peering connection identified by <connection_id> already exists
rhythmic-megabyte-99595
11/28/2023, 7:27 PMlocal
and remote
are AWS accounts. The VpcPeeringConnectionAccepter
suppose to 'adopt' the peer-connection as the doc says, but now it says 'peer-connection already exists'.little-cartoon-10569
11/28/2023, 9:44 PMrhythmic-megabyte-99595
11/28/2023, 9:56 PMlittle-cartoon-10569
11/28/2023, 10:02 PMup
? If not, you'll have a very hard time figuring out the issue. VPC peering is a hand-shake-y process, and (I think) you're trying to create code to support that hand shaking. If you're running up
which creates some resources then fails, your next up
is potentially starting part-way through the hand shake. So you may think you've fixed a problem, but actually something in AWS changed state, and you're just avoiding the problem.little-cartoon-10569
11/28/2023, 10:03 PMlittle-cartoon-10569
11/28/2023, 10:04 PMrhythmic-megabyte-99595
11/28/2023, 11:07 PMpulumi up
with the early version of my Pulumi code). For your third question, the vpc-remote is from another stack, I use pulumi.export to firstly export it, and then refer it in _local-vpc_'s stack. cc: @rich-whale-93740little-cartoon-10569
11/28/2023, 11:11 PMrhythmic-megabyte-99595
11/28/2023, 11:12 PMec2.VpcPeeringConnection
, I can actually create a peering-connection from local_vpc to remote_vpc, but it needs me to click 'accept peering' in remote_vpc's console. That's why I introduced VpcPeeringConnectionAccepter
and tried to make it in full-auto. The VpcPeeringConnectionAccepter
suppose to 'adopt' the peering connection (for VpcPeeringConnection
, it creates peering connection on both local_vpc and remote_vpc) on the remote_vpc side, but strangely, it gave me the 'peering connection already exists' error I illustrated before .rhythmic-megabyte-99595
11/28/2023, 11:13 PMlittle-cartoon-10569
11/28/2023, 11:13 PMrhythmic-megabyte-99595
11/28/2023, 11:14 PMlittle-cartoon-10569
11/28/2023, 11:14 PMrhythmic-megabyte-99595
11/28/2023, 11:15 PMpeer_owner_id
to the remote_vpc's account id.little-cartoon-10569
11/28/2023, 11:15 PMrhythmic-megabyte-99595
11/28/2023, 11:16 PMrhythmic-megabyte-99595
11/28/2023, 11:16 PMadopt
the peering connection, but why it throws 'already exists' error?little-cartoon-10569
11/28/2023, 11:17 PMlittle-cartoon-10569
11/28/2023, 11:18 PMlittle-cartoon-10569
11/28/2023, 11:18 PMlittle-cartoon-10569
11/28/2023, 11:20 PMrhythmic-megabyte-99595
11/28/2023, 11:20 PMVpcPeeringConnection
and VpcPeeringConnectionAccepter
, or the entire stack?rhythmic-megabyte-99595
11/28/2023, 11:20 PMlittle-cartoon-10569
11/28/2023, 11:20 PMlittle-cartoon-10569
11/28/2023, 11:21 PMrhythmic-megabyte-99595
11/28/2023, 11:21 PMrhythmic-megabyte-99595
11/29/2023, 12:26 AMlittle-cartoon-10569
11/29/2023, 1:12 AMrhythmic-megabyte-99595
11/29/2023, 1:15 AMlittle-cartoon-10569
11/29/2023, 1:15 AMrhythmic-megabyte-99595
11/29/2023, 1:16 AMrhythmic-megabyte-99595
11/29/2023, 1:16 AMrhythmic-megabyte-99595
11/29/2023, 1:16 AMlittle-cartoon-10569
11/29/2023, 1:17 AMlittle-cartoon-10569
11/29/2023, 1:17 AMrhythmic-megabyte-99595
11/29/2023, 1:17 AMadopt
the existing peering connection request. Instead, it tries to create one, so it throws 'already exist' errorlittle-cartoon-10569
11/29/2023, 1:19 AMrhythmic-megabyte-99595
11/29/2023, 1:20 AMopts=pulumi.ResourceOptions(provider=self._provider)
and opts=pulumi.ResourceOptions(provider=peer_provider)
to separates the operations on two accounts, where self._provider is for the local vpc whereas the peer_provider is for the remote onelittle-cartoon-10569
11/29/2023, 1:20 AMlittle-cartoon-10569
11/29/2023, 1:21 AMrhythmic-megabyte-99595
11/29/2023, 1:21 AMlittle-cartoon-10569
11/29/2023, 1:23 AMrhythmic-megabyte-99595
11/29/2023, 1:26 AMlocal_
prefix indicates things in Account A, while remote_
in Account B:
connection_id = ec2.VpcPeeringConnection(
"vpcPeering-local-to-remote",
opts=pulumi.ResourceOptions(provider=local_provider),
vpc_id=local_vpc_id,
peer_vpc_id=remote_vpc_id,
peer_owner_id=remote_account_id,
auto_accept=False,
tags={
...
},
).id
ec2.VpcPeeringConnectionAccepter(
"peer-accepter-in-remote-vpc-account",
vpc_peering_connection_id=connection_id,
auto_accept=True,
tags={
...
},
opts=pulumi.ResourceOptions(provider=remote_provider),
)
little-cartoon-10569
11/29/2023, 1:35 AMrhythmic-megabyte-99595
11/29/2023, 1:36 AMlittle-cartoon-10569
11/29/2023, 1:37 AMlittle-cartoon-10569
11/29/2023, 1:37 AMrhythmic-megabyte-99595
11/29/2023, 1:40 AMrhythmic-megabyte-99595
11/29/2023, 7:43 PMVpcPeeringConnection
and VpcPeeringConnectionAccepter
, it finally worked. It turned out to be if the tag Tag.NAME
have the different values in VpcPeeringConnection
and VpcPeeringConnectionAccepter
, it comes the 'connection already exist' error. Is it a bug or intentionally design? cc: @little-cartoon-10569rhythmic-megabyte-99595
11/30/2023, 1:42 AMlittle-cartoon-10569
11/30/2023, 1:43 AMlittle-cartoon-10569
11/30/2023, 1:44 AMlittle-cartoon-10569
11/30/2023, 1:46 AMlittle-cartoon-10569
11/30/2023, 1:48 AM