vpcs_and_subnets.j 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. {% import 'variables.include' as var %}
  2. ###########
  3. # Create a VPC with an Internet gateway for everybody to play in
  4. resource "aws_vpc" "vpc_primary" {
  5. cidr_block = "${var.VPC-Subnet}"
  6. enable_dns_support = true
  7. enable_dns_hostnames = true
  8. tags {
  9. Name = "Primary VPC"
  10. }
  11. }
  12. resource "aws_internet_gateway" "gw_primary" {
  13. vpc_id = "${aws_vpc.vpc_primary.id}"
  14. tags {
  15. Name = "Primary Gateway"
  16. }
  17. }
  18. ###########
  19. # Create honeypot and splunk subnets in an AZ
  20. data "aws_availability_zones" "available" {}
  21. resource "aws_subnet" "subnet_Honeypot" {
  22. vpc_id = "${aws_vpc.vpc_primary.id}"
  23. cidr_block = "${var.Honeypot-Subnet}"
  24. availability_zone = "${data.aws_availability_zones.available.names[0]}"
  25. map_public_ip_on_launch = true
  26. tags {
  27. Name = "HoneyPot"
  28. }
  29. }
  30. resource "aws_subnet" "subnet_Splunk" {
  31. vpc_id = "${aws_vpc.vpc_primary.id}"
  32. cidr_block = "${var.Splunk-Subnet}"
  33. availability_zone = "${data.aws_availability_zones.available.names[0]}"
  34. map_public_ip_on_launch = true
  35. tags {
  36. Name = "Splunk Subnet"
  37. }
  38. }
  39. ##########
  40. # Routing
  41. resource "aws_route_table" "r" {
  42. vpc_id = "${aws_vpc.vpc_primary.id}"
  43. route {
  44. cidr_block = "0.0.0.0/0"
  45. gateway_id = "${aws_internet_gateway.gw_primary.id}"
  46. }
  47. tags {
  48. Name = "Primary Route Table"
  49. }
  50. }
  51. resource "aws_route_table_association" "rt_public_a" {
  52. subnet_id = "${aws_subnet.subnet_Honeypot.id}"
  53. route_table_id = "${aws_route_table.r.id}"
  54. }
  55. resource "aws_route_table_association" "rt_public_b" {
  56. subnet_id = "${aws_subnet.subnet_Splunk.id}"
  57. route_table_id = "${aws_route_table.r.id}"
  58. }
  59. #resource "aws_route_table_association" "rt_private_a" {
  60. # subnet_id = "${aws_subnet.subnet_private_a.id}"
  61. # route_table_id = "${aws_route_table.r.id}"
  62. #}
  63. #resource "aws_route_table_association" "rt_private_b" {
  64. # subnet_id = "${aws_subnet.subnet_private_b.id}"
  65. # route_table_id = "${aws_route_table.r.id}"
  66. #}