vpcs_and_subnets.tf 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. ###############################################
  2. # DO NOT EDIT THIS FILE
  3. #
  4. # This file is generated through 'make all'.
  5. # If you need to make changes, make your changes
  6. # to the corresponding .j file and then rerun
  7. # make all
  8. ###############################################
  9. ###########
  10. # Create a VPC with an Internet gateway for everybody to play in
  11. resource "aws_vpc" "vpc_primary" {
  12. cidr_block = "${var.VPC-Subnet}"
  13. enable_dns_support = true
  14. enable_dns_hostnames = true
  15. tags {
  16. Name = "Primary VPC"
  17. }
  18. }
  19. resource "aws_internet_gateway" "gw_primary" {
  20. vpc_id = "${aws_vpc.vpc_primary.id}"
  21. tags {
  22. Name = "Primary Gateway"
  23. }
  24. }
  25. ###########
  26. # Create public and private subnets in two different az's
  27. data "aws_availability_zones" "available" {}
  28. resource "aws_subnet" "subnet_public_a" {
  29. vpc_id = "${aws_vpc.vpc_primary.id}"
  30. cidr_block = "${var.Public-Subnet-A}"
  31. availability_zone = "${data.aws_availability_zones.available.names[0]}"
  32. map_public_ip_on_launch = true
  33. tags {
  34. Name = "Public Subnet A"
  35. }
  36. }
  37. #resource "aws_subnet" "subnet_public_b" {
  38. # vpc_id = "${aws_vpc.vpc_primary.id}"
  39. # cidr_block = "${var.Public-Subnet-B}"
  40. # availability_zone = "${data.aws_availability_zones.available.names[1]}"
  41. # map_public_ip_on_launch = true
  42. # tags {
  43. # Name = "Public Subnet B"
  44. # }
  45. #}
  46. #resource "aws_subnet" "subnet_private_a" {
  47. # vpc_id = "${aws_vpc.vpc_primary.id}"
  48. # cidr_block = "${var.Private-Subnet-A}"
  49. # availability_zone = "${data.aws_availability_zones.available.names[0]}"
  50. # map_public_ip_on_launch = true
  51. # tags {
  52. # Name = "Private Subnet A"
  53. # }
  54. #}
  55. #resource "aws_subnet" "subnet_private_b" {
  56. # vpc_id = "${aws_vpc.vpc_primary.id}"
  57. # cidr_block = "${var.Private-Subnet-B}"
  58. # availability_zone = "${data.aws_availability_zones.available.names[1]}"
  59. # map_public_ip_on_launch = true
  60. # tags {
  61. # Name = "Private Subnet B"
  62. # }
  63. #}
  64. ##########
  65. # Routing
  66. resource "aws_route_table" "r" {
  67. vpc_id = "${aws_vpc.vpc_primary.id}"
  68. route {
  69. cidr_block = "0.0.0.0/0"
  70. gateway_id = "${aws_internet_gateway.gw_primary.id}"
  71. }
  72. tags {
  73. Name = "Primary Route Table"
  74. }
  75. }
  76. resource "aws_route_table_association" "rt_public_a" {
  77. subnet_id = "${aws_subnet.subnet_public_a.id}"
  78. route_table_id = "${aws_route_table.r.id}"
  79. }
  80. #resource "aws_route_table_association" "rt_public_b" {
  81. # subnet_id = "${aws_subnet.subnet_public_b.id}"
  82. # route_table_id = "${aws_route_table.r.id}"
  83. #}
  84. #resource "aws_route_table_association" "rt_private_a" {
  85. # subnet_id = "${aws_subnet.subnet_private_a.id}"
  86. # route_table_id = "${aws_route_table.r.id}"
  87. #}
  88. #resource "aws_route_table_association" "rt_private_b" {
  89. # subnet_id = "${aws_subnet.subnet_private_b.id}"
  90. # route_table_id = "${aws_route_table.r.id}"
  91. #}