-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
67 lines (59 loc) · 1.36 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.74.0"
}
}
}
provider "aws" {
region = var.region
}
locals {
common_tags = {
Name = "${var.name_tag_value}"
Owner = "${var.owner_tag_value}"
Project = "${var.project_tag_value}"
}
}
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "vpc"
}
}
resource "aws_subnet" "subnet" {
vpc_id = aws_vpc.vpc.id
cidr_block = "10.0.1.0/24"
availability_zone = var.availability_zone
tags = {
Name = "subnet"
}
}
resource "aws_instance" "instance" {
# Using Ubuntu Server 20.04 LTS (HVM), SSD Volume Type (64-bit x86)
ami = "ami-0493936afbe820b28"
instance_type = "t2.micro"
availability_zone = var.availability_zone
key_name = var.key_pair
tags = local.common_tags
}
module "bucket" {
source = "./modules/bucket"
bucket_prefix = var.bucket_prefix
package_name = "server.zip"
}
module "lambda" {
source = "./modules/lambda"
bucket_id = module.bucket.bucket_id
s3_key = "server.zip"
function_name = "server-lambda"
depends_on = [
module.bucket
]
}
module "apigw" {
source = "./modules/apigw"
uri = module.lambda.invoke_arn
lambda_function_name = module.lambda.function_name
}