-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
executable file
·119 lines (94 loc) · 2.91 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#================================================================================================
##
## Intialization
##
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
}
provider "aws" {
region = "us-west-1"
access_key = var.aws_access_key
secret_key = var.aws_secret_key
}
data "terraform_remote_state" "this" {
backend = "remote"
config = {
organization = "trevors-projects"
workspaces = {
name = "file-explorer-infra"
}
}
}
#================================================================================================
module "vpc" {
source = "./modules/vpc"
aws_access_key = var.aws_access_key
aws_secret_key = var.aws_secret_key
# resources of vpc will have -vpc, -subnet, -xxx added to the name
vpc_name = var.project_name
vpc_region = var.region
vpc_cidr = "10.0.0.0/16"
deploy_nat_gateway = false
}
module "s3Bucket" {
source = "./modules/s3Bucket"
aws_access_key = var.aws_access_key
aws_secret_key = var.aws_secret_key
bucket_name = var.project_name
bucket_force_destroy = true
s3_bucket_policy_principals = ["*"]
region = var.region
}
module "amplify_app" {
source = "./modules/amplify_app"
region = var.region
aws_access_key = var.aws_access_key
aws_secret_key = var.aws_secret_key
name = var.project_name
domain_name = "trevorlichfield.com"
main_branch = "main"
main_branch_prefix = "files"
# Dev & Stage Branches to build & Deploy (Main is built by default)
auto_branch_creation = false
development_branches = ["dev"]
staging_branches = []
# Repository & Build Settings
repository = var.frontend_repository_url
repository_token = var.github_token
environment_variables = {
"VITE_API_URL" = "https://explorer.trevorlichfield.com"
}
# build_spec = var.build_spec
}
#================================================================================================
##
## EC2 Instance with K3s
##
resource "aws_instance" "k3s" {
ami = "ami-038bba9a164eb3dc1"
instance_type = "t3.medium"
key_name = "low-security"
vpc_security_group_ids = [module.vpc.vpc_ids.vpc.security_groups.public.id]
subnet_id = module.vpc.vpc_ids.vpc.subnets.public1.id
associate_public_ip_address = true
tags = {
Name = "k3s-server"
}
}
resource "aws_instance" "k3s-worker" {
ami = "ami-038bba9a164eb3dc1"
instance_type = "t3.small"
key_name = "low-security"
vpc_security_group_ids = [module.vpc.vpc_ids.vpc.security_groups.public.id]
subnet_id = module.vpc.vpc_ids.vpc.subnets.public1.id
associate_public_ip_address = true
tags = {
Name = "k3s-worker"
}
}