Created
July 16, 2022 07:29
-
-
Save lioneltchami/6317e4ea26aa17d6b7e1645ee86e1baa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module "ec2_instance_A" { | |
| source = "terraform-aws-modules/ec2-instance/aws" | |
| version = "~> 3.0" | |
| name = "ec2_instance_A" | |
| ami = "ami-ebd02392" | |
| instance_type = "t2.micro" | |
| key_name = "user1" | |
| monitoring = true | |
| vpc_security_group_ids = [module.ec2_instance_A_sg.id] | |
| subnet_id = "subnet-eddcdzz4" | |
| tags = { | |
| Terraform = "true" | |
| Environment = "dev" | |
| } | |
| } | |
| module "ec2_instance_B" { | |
| source = "terraform-aws-modules/ec2-instance/aws" | |
| version = "~> 3.0" | |
| name = "ec2_instance_B" | |
| ami = "ami-ebd02392" | |
| instance_type = "t2.micro" | |
| key_name = "user1" | |
| monitoring = true | |
| vpc_security_group_ids = [module.ec2_instance_B_sg.id] | |
| subnet_id = "subnet-eddcdzz4" | |
| tags = { | |
| Terraform = "true" | |
| Environment = "dev" | |
| } | |
| } | |
| module "ec2_instance_A_sg" { | |
| source = "terraform-aws-modules/security-group/aws" | |
| name = "ec2_instance_A_sg" | |
| description = "Security group for web-server with HTTP ports open within VPC" | |
| vpc_id = "vpc-12345678" | |
| security_group_id = module.ec2_instance_A_sg.id | |
| ingress_with_source_security_group_id = [ | |
| { | |
| description = "http from service two" | |
| rule = "http-80-tcp" | |
| source_security_group_id = module.ec2_instance_B_sg.id | |
| }, | |
| ] | |
| } | |
| module "ec2_instance_B_sg" { | |
| source = "terraform-aws-modules/security-group/aws" | |
| name = "ec2_instance_B_sg" | |
| description = "Security group for web-server with HTTP ports open within VPC" | |
| vpc_id = "vpc-12345678" | |
| security_group_id = module.ec2_instance_B_sg.id | |
| ingress_with_source_security_group_id = [ | |
| { | |
| description = "http from service one" | |
| rule = "http-80-tcp" | |
| source_security_group_id = module.ec2_instance_A_sg.id | |
| }, | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment