-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwww.tf
54 lines (44 loc) · 1.67 KB
/
www.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
/* @fileoverview This Terraform configuration file sets up an AWS API Gateway REST API
* for the app subdomain. The app subdomain is intended for GET requests that are
* meant to be viewed in the browser, as opposed to an API for data manipulation.
*/
# API Gateway REST API definition
resource "aws_api_gateway_rest_api" "www" {
name = "datalayer-storage-app-pages"
description = "${local.config.AWS_PROFILE} app pages"
}
resource "aws_api_gateway_stage" "production_www" {
deployment_id = aws_api_gateway_deployment.production_www_deployment.id
rest_api_id = aws_api_gateway_rest_api.www.id
stage_name = "prod"
}
resource "aws_api_gateway_deployment" "production_www_deployment" {
rest_api_id = aws_api_gateway_rest_api.www.id
description = "${local.config.AWS_PROFILE}:: API Gateway deployment for WWW pages"
triggers = {
redeployment = sha1(timestamp())
}
lifecycle {
create_before_destroy = true
}
depends_on = [
aws_api_gateway_rest_api.www,
module.service-subscriptions
]
}
resource "aws_api_gateway_usage_plan" "www-usage-plan" {
name = "${local.config.AWS_PROFILE}-www-usage-plan"
api_stages {
api_id = aws_api_gateway_rest_api.www.id
stage = aws_api_gateway_stage.production_www.stage_name
}
}
resource "aws_api_gateway_domain_name" "app-subdomain" {
domain_name = "app.${local.config.SERVICE_DOMAIN}"
certificate_arn = aws_acm_certificate.wildcard-domain.arn
}
resource "aws_api_gateway_base_path_mapping" "app-base-path-mapping" {
api_id = aws_api_gateway_rest_api.www.id
stage_name = aws_api_gateway_stage.production_www.stage_name
domain_name = aws_api_gateway_domain_name.app-subdomain.domain_name
}