Created
May 19, 2024 02:48
-
-
Save shaikkhajaibrahim/6912bab4ffd687893fd0d371bf873e61 to your computer and use it in GitHub Desktop.
This file contains 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
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "5.49.0" | |
} | |
} | |
} | |
provider "aws" { | |
region = "ap-south-1" | |
default_tags { | |
tags = { | |
CreatedBy = "Terraform" | |
Environment = "Dev" | |
} | |
} | |
} | |
module "vpc" { | |
source = "github.com/asquarezone/TerraformZone//May24/aws/modules/vpc" | |
network_info = { | |
name = "ntier-primary" | |
cidr = "10.0.0.0/16" | |
} | |
public_subnets = [{ | |
name = "web-1" | |
az = "ap-south-1a" | |
cidr = "10.0.0.0/24" | |
}] | |
private_subnets = [{ | |
name = "db-1" | |
az = "ap-south-1a" | |
cidr = "10.0.50.0/24" | |
}, { | |
name = "db-2" | |
az = "ap-south-1b" | |
cidr = "10.0.51.0/24" | |
}] | |
} | |
# create web security group | |
module "web_security_group" { | |
source = "github.com/asquarezone/TerraformZone//May24/aws/modules/security_group" | |
security_group_info = { | |
name = "web-sg" | |
description = "web security group" | |
vpc_id = module.vpc.vpcid | |
inbound_rules = [{ | |
cidr = "0.0.0.0/0" | |
port = 22 | |
protocol = "tcp" | |
description = "open ssh" | |
}, | |
{ | |
cidr = "0.0.0.0/0" | |
port = 80 | |
protocol = "tcp" | |
description = "open http" | |
} | |
] | |
outbound_rules = [] | |
allow_all_egress = true | |
} | |
depends_on = [module.vpc] | |
} | |
# create a db security group to open 3306 port with in vpc | |
module "db_security_group" { | |
source = "github.com/asquarezone/TerraformZone//May24/aws/modules/security_group" | |
security_group_info = { | |
name = "mysql-db-sg" | |
description = "open mysql port within vpc" | |
vpc_id = module.vpc.vpcid | |
allow_all_egress = true | |
outbound_rules = [] | |
inbound_rules = [{ | |
cidr = "10.0.0.0/16" | |
port = 3306 | |
protocol = "tcp" | |
description = "open mysql port" | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment