Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. data "aws_availability_zones" "available" {}
  2.  
  3. module "vpc" {
  4. source = "terraform-aws-modules/vpc/aws"
  5. version = "2.5.0"
  6. name = "${var.namespace}-vpc"
  7. cidr = "10.0.0.0/16"
  8. azs = data.aws_availability_zones.available.names
  9. private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  10. public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
  11. database_subnets = ["10.0.21.0/24", "10.0.22.0/24", "10.0.23.0/24"]
  12. assign_generated_ipv6_cidr_block = true
  13. create_database_subnet_group = true
  14. enable_nat_gateway = true
  15. single_nat_gateway = true
  16. }
  17.  
  18. module "lb_sg" {
  19. source = "scottwinkler/sg/aws"
  20. vpc_id = module.vpc.vpc_id
  21. ingress_rules = [{
  22. port = 80
  23. cidr_blocks = ["0.0.0.0/0"]
  24. }]
  25. }
  26.  
  27. module "websvr_sg" {
  28. source = "scottwinkler/sg/aws"
  29. vpc_id = module.vpc.vpc_id
  30. ingress_rules = [
  31. {
  32. port = 8080
  33. security_groups = [module.lb_sg.security_group.id]
  34. },
  35. {
  36. port = 22
  37. cidr_blocks = ["10.0.0.0/16"]
  38. }
  39. ]
  40. }
  41.  
  42. module "db_sg" {
  43. source = "scottwinkler/sg/aws"
  44. vpc_id = module.vpc.vpc_id
  45. ingress_rules = [{
  46. port = 3306
  47. security_groups = [module.websvr_sg.security_group.id]
  48. }]
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement