-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
42 lines (34 loc) · 989 Bytes
/
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
#configure remote backend tfstate to s3bucket
terraform {
required_version = ">= 0.12"
backend "s3" {
bucket = "myapp-bucket-johnk"
key = "myapp/state.tfstate"
region = "eu-central-1"
}
}
provider "aws" {
region = "eu-central-1"
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
name = "my-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"
}
}
module "myapp-server" {
source ="./modules/webserver"
vpc_id = module.vpc.vpc_id
my_ip = var.my_ip
env_prefix = var.env_prefix
image_name = var.image_name
my_public_key = var.my_public_key
instance_type = var.instance_type
subnet_id = module.vpc.public_subnets[0] #get first element of subnets array
avail_zone = var.avail_zone
}