Created
March 11, 2020 18:56
-
-
Save Ghilteras/e55d83985d9f1e105988f72223250181 to your computer and use it in GitHub Desktop.
Localstack region is always null in getAccepterVpcInfo after vpc peering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
//get 2 different EC2 clients one per region | |
AmazonEC2 awsClient = LocalStackClients.getLocalStackEC2lient(Regions.US_EAST_1); | |
AmazonEC2 awsClientDiffRegion = LocalStackClients.getLocalStackEC2lient(Regions.AP_SOUTHEAST_1); | |
Vpc peerMe = awsClient.createVpc(new CreateVpcRequest().withCidrBlock("192.168.0.0/24")).getVpc(); | |
Vpc xRegionVPC = awsClientDiffRegion.createVpc(new CreateVpcRequest().withCidrBlock("192.168.0.1/24")).getVpc(); | |
VpcPeeringConnection crossRegion = awsClient.createVpcPeeringConnection(new CreateVpcPeeringConnectionRequest() | |
.withPeerOwnerId("000000000000") | |
.withVpcId(peerMe.getVpcId()) | |
.withPeerVpcId(xRegionVPC.getVpcId()) | |
.withPeerRegion(Regions.AP_SOUTHEAST_1.getName())) | |
.getVpcPeeringConnection(); | |
awsClientDiffRegion.acceptVpcPeeringConnection(new AcceptVpcPeeringConnectionRequest() | |
.withVpcPeeringConnectionId(crossRegion.getVpcPeeringConnectionId())); | |
String region = awsClient.describeVpcPeeringConnections(new DescribeVpcPeeringConnectionsRequest().withVpcPeeringConnectionIds(crossRegion.getVpcPeeringConnectionId())).getVpcPeeringConnections().get(0).getAccepterVpcInfo().getRegion(); | |
String region2 = awsClientDiffRegion.describeVpcPeeringConnections(new DescribeVpcPeeringConnectionsRequest().withVpcPeeringConnectionIds(crossRegion.getVpcPeeringConnectionId())).getVpcPeeringConnections().get(0).getAccepterVpcInfo().getRegion(); | |
// these are always null but they should not | |
System.out.println(region); | |
System.out.println(region2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment