This commit is contained in:
13
main.tf
13
main.tf
@@ -1,5 +1,5 @@
|
||||
provider "aws" {
|
||||
region = local.region
|
||||
region = local.region
|
||||
}
|
||||
|
||||
locals {
|
||||
@@ -28,12 +28,15 @@ module "vpc" {
|
||||
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
|
||||
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
|
||||
|
||||
|
||||
enable_nat_gateway = true
|
||||
single_nat_gateway = true
|
||||
|
||||
enable_dns_hostnames = true
|
||||
enable_dns_support = true
|
||||
|
||||
enable_flow_log = true
|
||||
|
||||
tags = {
|
||||
terraform = "true"
|
||||
environment = "test"
|
||||
@@ -45,7 +48,7 @@ module "vpc" {
|
||||
module "web_server_sg" {
|
||||
source = "terraform-aws-modules/security-group/aws//modules/http-80"
|
||||
name = "${local.name}-web-server-sg"
|
||||
description = "Security group for web server of ${local.name}"
|
||||
description = "Security group for web server of ${local.name}"
|
||||
vpc_id = module.vpc.vpc_id
|
||||
ingress_cidr_blocks = ["0.0.0.0/0"]
|
||||
ingress_rules = ["http-80-tcp", "https-443-tcp", "ssh-tcp"]
|
||||
@@ -56,14 +59,14 @@ module "web_server_sg" {
|
||||
### create an ec2 instance
|
||||
module "ec2_instance" {
|
||||
source = "terraform-aws-modules/ec2-instance/aws"
|
||||
name = "${local.name}-web-server"
|
||||
name = "${local.name}-web-server"
|
||||
|
||||
instance_type = "t2.micro"
|
||||
key_name = module.key_pair.key_pair_name
|
||||
monitoring = true
|
||||
vpc_security_group_ids = [ module.web_server_sg.security_group_id ]
|
||||
vpc_security_group_ids = [module.web_server_sg.security_group_id]
|
||||
subnet_id = module.vpc.public_subnets[0]
|
||||
user_data = file("userdata.sh")
|
||||
user_data = file("userdata.sh")
|
||||
|
||||
tags = {
|
||||
Terraform = "true"
|
||||
|
Reference in New Issue
Block a user