After deleting the default vpc, is there a cloudformation template that can recreate it?
Is there a particular flag that signifies that it is a default vpc?
when creating via cli aws ec2 create-default-vpc
the returned json contains a "IsDefault": true,"InstanceTenancy": "default"
, can this be used in a CF template to flag the creation as well, assuming the "CidrBlock": "172.31.0.0/16",
is set as well?
No, there is no way to create a default VPC through a pure CloudFormation template.
To create a default VPC, you need to invoke the CreateDefaultVpc API. You can do this in CloudFormation with a custom resource that allows you to run custom provisioning logic in a Lambda function.
Note: you cannot have multiple default VPCs per account/region. You can determine if you have a default VPC by calling the DescribeAccountAttributes API. It will provide the following attribute in the response: