vpc.tf 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. resource "aws_vpc" "main" {
  2. cidr_block = "172.16.0.0/16"
  3. enable_dns_hostnames = true
  4. tags = {
  5. name = "monkeybox_emr_lab"
  6. project = "monkeybox_emr_lab"
  7. }
  8. }
  9. resource "aws_vpc_endpoint_route_table_association" "example" {
  10. route_table_id = aws_route_table.r.id
  11. vpc_endpoint_id = aws_vpc_endpoint.s3.id
  12. }
  13. resource "aws_subnet" "main" {
  14. vpc_id = aws_vpc.main.id
  15. cidr_block = "172.16.0.0/20"
  16. # tfsec:ignore:aws-ec2-no-public-ip-subnet We allow public IPs in the lab
  17. map_public_ip_on_launch = true
  18. tags = {
  19. name = "monkeybox_emr_lab"
  20. project = "monkeybox_emr_lab"
  21. }
  22. }
  23. resource "aws_internet_gateway" "gw" {
  24. vpc_id = aws_vpc.main.id
  25. }
  26. resource "aws_vpc_endpoint" "s3" {
  27. vpc_id = aws_vpc.main.id
  28. service_name = "com.amazonaws.us-east-2.s3"
  29. tags = {
  30. project = "monkeybox_emr_lab"
  31. }
  32. }
  33. resource "aws_route_table" "r" {
  34. vpc_id = aws_vpc.main.id
  35. route {
  36. cidr_block = "0.0.0.0/0"
  37. gateway_id = aws_internet_gateway.gw.id
  38. }
  39. }
  40. resource "aws_main_route_table_association" "a" {
  41. vpc_id = aws_vpc.main.id
  42. route_table_id = aws_route_table.r.id
  43. }