-
Notifications
You must be signed in to change notification settings - Fork 35
/
aws.tf
158 lines (129 loc) · 3.67 KB
/
aws.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
terraform {
backend "remote" {
hostname = "app.terraform.io"
organization = "VargasArts"
workspaces {
name = "roam-js-extensions"
}
}
required_providers {
github = {
source = "integrations/github"
}
}
}
variable "secret" {
type = string
}
provider "aws" {
region = "us-east-1"
}
module "aws_static_site" {
source = "dvargas92495/static-site/aws"
version = "2.3.6"
domain = "roamjs.com"
redirects = ["roam.davidvargas.me"]
secret = var.secret
allowed_origins = ["https://roamresearch.com"]
tags = {
Application = "Roam JS Extensions"
}
providers = {
aws.us-east-1 = aws
}
}
module "aws_email" {
source = "dvargas92495/email/aws"
version = "2.0.3"
domain = "roamjs.com"
zone_id = module.aws_static_site.route53_zone_id
}
resource "aws_route53_record" "google-verifu" {
zone_id = module.aws_static_site.route53_zone_id
name = "roamjs.com"
type = "TXT"
ttl = "300"
records = ["google-site-verification=A9q11tN2qoTRaIdwMmlNqvbjgX4UQOj1okRat6CHtyE"]
}
resource "aws_dynamodb_table" "auth" {
name = "RoamJSAuth"
billing_mode = "PAY_PER_REQUEST"
hash_key = "id"
attribute {
name = "id"
type = "S"
}
tags = {
Application = "Roam JS Extensions"
}
}
resource "aws_api_gateway_rest_api" "lambda_api" {
name = "roamjs-extensions"
endpoint_configuration {
types = ["REGIONAL"]
}
binary_media_types = [
"multipart/form-data",
"application/octet-stream"
]
tags = {
Application = "Roam JS Extensions"
}
}
resource "aws_acm_certificate" "api" {
domain_name = "lambda.roamjs.com"
validation_method = "DNS"
tags = {
Application = "Roam JS Extensions"
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_route53_record" "api_cert" {
name = tolist(aws_acm_certificate.api.domain_validation_options)[0].resource_record_name
type = tolist(aws_acm_certificate.api.domain_validation_options)[0].resource_record_type
zone_id = module.aws_static_site.route53_zone_id
records = [tolist(aws_acm_certificate.api.domain_validation_options)[0].resource_record_value]
ttl = 60
}
resource "aws_acm_certificate_validation" "api" {
certificate_arn = aws_acm_certificate.api.arn
validation_record_fqdns = [aws_route53_record.api_cert.fqdn]
}
resource "aws_api_gateway_domain_name" "api" {
certificate_arn = aws_acm_certificate_validation.api.certificate_arn
domain_name = "lambda.roamjs.com"
}
resource "aws_route53_record" "api" {
name = aws_api_gateway_domain_name.api.domain_name
type = "A"
zone_id = module.aws_static_site.route53_zone_id
alias {
evaluate_target_health = true
name = aws_api_gateway_domain_name.api.cloudfront_domain_name
zone_id = aws_api_gateway_domain_name.api.cloudfront_zone_id
}
}
resource "aws_api_gateway_deployment" "production" {
rest_api_id = aws_api_gateway_rest_api.lambda_api.id
stage_name = "production"
}
resource "aws_api_gateway_base_path_mapping" "api" {
api_id = aws_api_gateway_rest_api.lambda_api.id
stage_name = aws_api_gateway_deployment.production.stage_name
domain_name = aws_api_gateway_domain_name.api.domain_name
}
provider "github" {
owner = "dvargas92495"
}
resource "github_actions_secret" "deploy_aws_access_key" {
repository = "roamjs-com"
secret_name = "DEPLOY_AWS_ACCESS_KEY"
plaintext_value = module.aws_static_site.deploy-id
}
resource "github_actions_secret" "deploy_aws_access_secret" {
repository = "roamjs-com"
secret_name = "DEPLOY_AWS_ACCESS_SECRET"
plaintext_value = module.aws_static_site.deploy-secret
}