0

GCP is so much better than aws in this regard. In GCP I can have a "default" vpc/network and have all my custom settings for it. I want the same thing for aws.

I have stuff in many regions. I dont need complex networking just VPCs with my own cidrs in many regions. Would be nice to have these be the "default" so I dont need to worry about hardcoding VPC IDs and subnet IDs in all my deployment automation

Is this possible?

red888
  • 4,183
  • 18
  • 64
  • 111

1 Answers1

1

AWS has a default VPC in every region, but you can't customise it. The default VPC is somewhat permissive, made to be easy to get started for beginners, so I use automation to delete it.

The best option for you might be to write a simple CloudFormation template and have parameters so you can customise to each region. I haven't tested this but it should be pretty close at least.

VPC (docs and example here). Change this template to customise as you like. Alternately find a VPC template that's fully written, AWS has plenty scattered across their website, or there are some here. You may just need to parameterise them for the CIDR block and VPC name.

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  VPCCIDR:
    Description: CIDR for the VPC
    Type: String
  VPCName:
    Description: Namefor the VPC
    Type: String

Resources:
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Ref VPCCIDR
      Tags:
       - Key: Name
         Value: !Ref VPCName

You'll have to add subnets to the template, I haven't done that for you, but look here it should be easy. If you want an internet gateway you'll need to add that too.

Parameters file (has to be json, one per region, choose a different CIDR block)

[
  {
    "ParameterKey": "VPCCIDR",
    "ParameterValue": "10.1.0.0/16"
  }, 
  {
    "ParameterKey": "VPCName",
    "ParameterValue": "Ohio VPC"
  }
]

Then run it in a few regions

aws cloudformation create-stack --profile --stack-name vpc-ohio --region us-east-2 --template-body file://vpc.yaml --parameters file://vpc-ohio.json
aws cloudformation create-stack --profile --stack-name --region ap-southeast-2 vpc-sydney --template-body file://vpc.yaml --parameters file://vpc-sydney.json

If you want to change your VPC

Tim
  • 31,888
  • 7
  • 52
  • 78