-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from hearchco/as/feat/frontend
feat: frontend infra
- Loading branch information
Showing
84 changed files
with
1,107 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ locals { | |
routes = toset([ | ||
"/search", | ||
"/proxy", | ||
"/healthz" | ||
]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module "hearchco_cdn_certificate" { | ||
source = "../../modules/universal/acm" | ||
domain_name = var.domain_name | ||
hosted_zone_id = data.aws_route53_zone.hearchco_route53.zone_id | ||
|
||
providers = { | ||
aws = aws.us-east-1-cdn | ||
} | ||
} | ||
|
||
module "hearchco_cloudfront" { | ||
source = "../../modules/frontend/cloudfront" | ||
domain_name = var.domain_name | ||
hosted_zone_id = data.aws_route53_zone.hearchco_route53.zone_id | ||
target_domain_name = module.hearchco_s3_assets.bucket_domain_name | ||
oai_id = module.hearchco_s3_assets.oai | ||
lambda_edge_arn = module.hearchco_lambda_edge.invoke_arn | ||
acm_certificate_arn = module.hearchco_cdn_certificate.cert_arn | ||
price_class = "PriceClass_100" | ||
|
||
top_level_assets = module.hearchco_s3_assets.top_level_assets | ||
|
||
paths_cache = { | ||
"/search" = { | ||
min_ttl = 60 // 1 minute | ||
default_ttl = 600 // 10 minutes | ||
max_ttl = 3600 // 1 hour | ||
}, | ||
"/healthz" = { | ||
min_ttl = 0 | ||
default_ttl = 0 | ||
max_ttl = 5 | ||
}, | ||
} | ||
|
||
providers = { | ||
aws = aws.us-east-1-cdn | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module "hearchco_env_injection" { | ||
source = "../../modules/frontend/env_injection" | ||
environment = local.environment | ||
} | ||
|
||
module "hearchco_s3_source_code" { | ||
source = "../../modules/universal/s3_source_code" | ||
bucket_name = "hearchco-ssr-function" | ||
filename = module.hearchco_env_injection.filename | ||
path = module.hearchco_env_injection.path | ||
|
||
depends_on = [module.hearchco_env_injection] | ||
|
||
providers = { | ||
aws = aws.us-east-1-cdn | ||
} | ||
} | ||
|
||
module "lambda_iam" { | ||
source = "../../modules/universal/lambda_iam" | ||
|
||
role_name = "aws-iam-role-exec-hearchco-ssr" | ||
policy_name = "hearchco_ssr_logging" | ||
edge = true | ||
} | ||
|
||
### Lambda@Edge for SSR (us-east-1 for Cloudfront) | ||
module "hearchco_lambda_edge" { | ||
source = "../../modules/frontend/lambda_edge" | ||
role = module.lambda_iam.role_arn | ||
s3_bucket = module.hearchco_s3_source_code.bucket_id | ||
s3_key = module.hearchco_s3_source_code.s3_key | ||
source_code_hash = module.hearchco_s3_source_code.source_code_hash | ||
# environment = local.environment # Not supported by Lambda@Edge | ||
|
||
providers = { | ||
aws = aws.us-east-1-cdn | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
locals { | ||
api_domain_name = "api.${var.domain_name}" | ||
|
||
# Lambda | ||
environment = tomap({ | ||
API_URI = "https://${local.api_domain_name}" | ||
PUBLIC_API_URI = "https://${local.api_domain_name}" | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
terraform { | ||
backend "s3" { | ||
profile = "992382822186_TFStateLock" | ||
region = "eu-central-1" | ||
dynamodb_table = "hearchco-shared-tf-state" | ||
bucket = "hearchco-shared-tf-state" | ||
key = "aws/dev/frontend/terraform.tfstate" | ||
encrypt = "true" | ||
} | ||
} | ||
|
||
provider "aws" { | ||
profile = var.aws_profile | ||
region = "eu-central-1" | ||
} | ||
|
||
# us-east-1 region required for Cloudfront's certificate and Lambda@Edge | ||
provider "aws" { | ||
profile = var.aws_profile | ||
region = "us-east-1" | ||
alias = "us-east-1-cdn" | ||
} | ||
|
||
# Route53 DNS | ||
data "aws_route53_zone" "hearchco_route53" { | ||
name = var.domain_name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module "hearchco_s3_assets" { | ||
source = "../../modules/frontend/s3_assets" | ||
bucket_name = "hearchco-assets" | ||
|
||
providers = { | ||
aws = aws.us-east-1-cdn | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "aws_profile" { | ||
type = string | ||
default = "891377085136_Admin" | ||
} | ||
|
||
variable "domain_name" { | ||
type = string | ||
default = "dev.hearch.co" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,5 +62,5 @@ variable "memory_size" { | |
|
||
variable "timeout" { | ||
type = number | ||
default = 5 | ||
default = 4 | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.