Skip to content

Instantly share code, notes, and snippets.

@phact
Created August 5, 2020 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phact/5b3268c762291945caf25e0d89fcd154 to your computer and use it in GitHub Desktop.
Save phact/5b3268c762291945caf25e0d89fcd154 to your computer and use it in GitHub Desktop.
#!/bin/bash
PEERING_CONNECTION_ID=
REGION=
RECEIVER_VPC_ROUTE_TABLE_ID=
aws ec2 accept-vpc-peering-connection --vpc-peering-connection-id "$PEERING_CONNECTION_ID" --region "$REGION"
DEST_CIDR=$(aws ec2 describe-vpc-peering-connections --vpc-peering-connection-ids "$PEERING_CONNECTION_ID" --region "$REGION" | jq -r ".VpcPeeringConnections[].RequesterVpcInfo.CidrBlock")
aws ec2 create-route --route-table-id "$RECEIVER_VPC_ROUTE_TABLE_ID" --destination-cidr-block "$DEST_CIDR" --vpc-peering-connection-id "$PEERING_CONNECTION_ID" --region "$REGION"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment