chef-boneyard / chef-provisioning-aws

AWS driver and resources for Chef that uses the AWS SDK
Apache License 2.0
142 stars 121 forks source link

example for NAT_gateway provisioning #485

Open ayon0110 opened 8 years ago

ayon0110 commented 8 years ago

this is ideally not an issue. sorry, am no developer; so was wondering if one could present an example for launching a NAT gateway within a public subnet in a VPC similar to multiple others that have been presented in docs/examples.

Thank you.

JeroenAP commented 7 years ago

I think it might be something like this:

aws_vpc 'production-vpc' do
  cidr_block '10.0.0.0/16'
  internet_gateway true
  main_routes '0.0.0.0/0' => :internet_gateway
  aws_tags({'Name' => 'production-vpc', 'Company' => 'company'})
end

aws_subnet 'public-subnet-a' do
  vpc 'production-vpc'
  cidr_block '10.0.0.0/24'
  availability_zone 'eu-west-1a'
  map_public_ip_on_launch false
end

aws_subnet 'public-subnet-b' do
  vpc 'production-vpc'
  cidr_block '10.0.1.0/24'
  availability_zone 'eu-west-1b'
  map_public_ip_on_launch false
end

aws_subnet 'private-subnet-a' do
  vpc 'production-vpc'
  cidr_block '10.0.2.0/24'
  availability_zone 'eu-west-1a'
  map_public_ip_on_launch false
end

aws_subnet 'private-subnet-b' do
  vpc 'production-vpc'
  cidr_block '10.0.3.0/24'
  availability_zone 'eu-west-1b'
  map_public_ip_on_launch false
end

aws_eip_address 'eip-nat-gateway'

aws_nat_gateway 'nat-gateway' do
  vpc 'production-vpc'
  subnet 'subnet-a'
  eip_address 'eip-nat-gateway'
end

aws_route_table 'public-route-table' do
  vpc 'production-vpc'
  routes '0.0.0.0/0' => :internet_gateway
end

aws_route_table 'private-route-table' do
  vpc 'production-vpc'
  routes '0.0.0.0/0' => :nat_gateway
end

Maybe someone can check this and add corrections?