Advertisement
Guest User

stack

a guest
Jan 13th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. module "vpc-demosubs" {
  2. source = "terraform-aws-modules/vpc/aws"
  3. version = "1.51.0"
  4. name = "vpc-demosubs"
  5. cidr = "10.3.0.0/16"
  6. azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
  7. public_subnets = ["10.3.0.0/24", "10.3.1.0/24", "10.3.2.0/24"]
  8. enable_dns_support = true
  9. enable_dns_hostnames = true
  10.  
  11.  
  12.  
  13. module "sg-demosubs" {
  14. source = "terraform-aws-modules/security-group/aws"
  15. name = "demosubs-security-group"
  16. use_name_prefix = false
  17. description = "Security group for the web instances"
  18. vpc_id = "${module.vpc-demosubs.vpc_id}"
  19.  
  20. ingress_with_cidr_blocks = [
  21. {
  22. rule = "mysql-tcp"
  23. cidr_blocks = "10.1.0.0/24,10.1.1.0/24"
  24. description = "rules to the RDS instance"
  25. },
  26. { rule = "http-80-tcp"
  27. cidr_blocks = "0.0.0.0/0"
  28. description = "Used to access the website"
  29. },
  30. { rule = "https-443-tcp"
  31. cidr_blocks = "0.0.0.0/0"
  32. description = " used to access the website"
  33. },
  34.  
  35.  
  36.  
  37. data "aws_ami" "demosubs_application" {
  38. filter {
  39. name = "name"
  40. values = ["*DEMOSUBS*"]
  41. }
  42. owners = ["self"] # Canonical
  43. }
  44.  
  45.  
  46. module "ec2-demosubs" {
  47. source = "terraform-aws-modules/ec2-instance/aws"
  48. version = "1.12.0"
  49. name = "demosubs-exemple"
  50. ami = "${data.aws_ami.demosubs_application.id}"
  51. instance_type = "t2.micro"
  52. vpc_security_group_ids = ["${module.sg-demosubs.this_security_group_id}"]
  53. subnet_id= "${element(module.vpc-demosubs.public_subnets, 1)}"
  54. associate_public_ip_address = true
  55. tags = {
  56. Name = "demosubs-exemple"
  57. Client = "demosubs"
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement