forked from macneib/devops-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
44 lines (36 loc) · 1 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Ideally the terraform state should be remotely stored.
# terraform {
# required_version = ">=0.12"
# backend "s3" {
# bucket = "ecomp-bucket"
# key = "devops-challenge/state.tfstate"
# region = "us-east-2"
# }
# }
provider "aws" {
region = "us-east-2"
}
# vpc module from terraform public registry
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "ecomp-vpc"
cidr = var.vpc_cidr_block
azs = [var.avail_zone]
public_subnets = [var.subnet_cidr_block]
public_subnet_tags = { Name = "${var.env_prefix}-subnet-1" }
tags = {
Name = "${var.env_prefix}-vpc"
}
}
# local module for EC2 instance webserver
module "ecomp-server" {
source = "./modules/webserver"
vpc_id = module.vpc.vpc_id
my_ip = var.my_ip
image_name = var.image_name
public_key_location = var.public_key_location
instance_type = var.instance_type
subnet_id = module.vpc.public_subnets[0]
avail_zone = var.avail_zone
env_prefix = var.env_prefix
}