Skip to content

Commit db46d4e

Browse files
committed
add dependent module
1 parent 080d3d8 commit db46d4e

File tree

6 files changed

+170
-24
lines changed

6 files changed

+170
-24
lines changed

terragrunt/accounts/legacy/rustc-ci-prod/.terraform.lock.hcl

+40-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terragrunt/modules/gha-iam-user/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
github = {
44
source = "integrations/github"
5-
version = "~> 6.2.3"
5+
version = "~> 6.2"
66
}
77
}
88
}

terragrunt/modules/rustc-ci/artifacts.tf

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
locals {
2-
bucket_name = "rust-lang-ci2"
3-
42
rustc_builds = "rustc-builds"
53
rustc_builds_alt = "rustc-builds-alt"
64
iam_prefix = "rustc-ci--rust-lang--rust"
@@ -49,11 +47,11 @@ locals {
4947
import {
5048
to = aws_s3_bucket.artifacts
5149
# id retrieved with `terraform state show`.
52-
id = local.bucket_name
50+
id = "rust-lang-ci2"
5351
}
5452

5553
resource "aws_s3_bucket" "artifacts" {
56-
bucket = local.bucket_name
54+
bucket = "rust-lang-ci2"
5755

5856
}
5957

@@ -128,14 +126,14 @@ resource "aws_s3_bucket_acl" "artifacts" {
128126
}
129127

130128
module "artifacts_cdn" {
131-
source = "../../shared/modules/static-website"
129+
source = "../static-website"
132130
providers = {
133131
aws = aws.east1
134132
}
135133

136134
domain_name = "ci-artifacts.rust-lang.org"
137135
origin_domain_name = aws_s3_bucket.artifacts.bucket_regional_domain_name
138-
response_policy_id = var.response_policy_id
136+
response_policy_id = data.terraform_remote_state.shared.outputs.mdbook_response_policy
139137
}
140138

141139
data "aws_s3_bucket" "inventories" {
+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = ">= 5.64"
6+
}
7+
}
8+
}
9+
10+
module "certificate" {
11+
source = "../acm-certificate"
12+
legacy = true
13+
14+
domains = [
15+
var.domain_name,
16+
]
17+
}
18+
19+
data "aws_cloudfront_cache_policy" "cache" {
20+
name = "Managed-CachingOptimized"
21+
}
22+
23+
resource "aws_cloudfront_distribution" "website" {
24+
comment = "static website ${var.domain_name}"
25+
26+
enabled = true
27+
wait_for_deployment = false
28+
is_ipv6_enabled = true
29+
default_root_object = "index.html"
30+
price_class = "PriceClass_All"
31+
http_version = "http2and3"
32+
33+
aliases = [var.domain_name]
34+
viewer_certificate {
35+
acm_certificate_arn = module.certificate.arn
36+
minimum_protocol_version = "TLSv1.2_2021"
37+
ssl_support_method = "sni-only"
38+
}
39+
40+
default_cache_behavior {
41+
target_origin_id = "main"
42+
allowed_methods = ["GET", "HEAD"]
43+
cached_methods = ["GET", "HEAD"]
44+
compress = true
45+
viewer_protocol_policy = "redirect-to-https"
46+
47+
cache_policy_id = data.aws_cloudfront_cache_policy.cache.id
48+
response_headers_policy_id = var.response_policy_id
49+
}
50+
51+
dynamic "origin" {
52+
for_each = var.origin_access_identity == null ? toset([true]) : toset([])
53+
content {
54+
origin_id = "main"
55+
domain_name = var.origin_domain_name
56+
origin_path = var.origin_path
57+
custom_origin_config {
58+
http_port = 80
59+
https_port = 443
60+
origin_ssl_protocols = ["TLSv1.2"]
61+
origin_protocol_policy = "https-only"
62+
}
63+
}
64+
}
65+
dynamic "origin" {
66+
for_each = var.origin_access_identity != null ? toset([true]) : toset([])
67+
content {
68+
origin_id = "main"
69+
domain_name = var.origin_domain_name
70+
71+
s3_origin_config {
72+
origin_access_identity = var.origin_access_identity
73+
}
74+
}
75+
}
76+
77+
restrictions {
78+
geo_restriction {
79+
restriction_type = "none"
80+
}
81+
}
82+
}
83+
84+
data "aws_route53_zone" "zone" {
85+
// Convert foo.bar.baz into bar.baz
86+
name = join(".", reverse(slice(reverse(split(".", var.domain_name)), 0, 2)))
87+
}
88+
89+
resource "aws_route53_record" "website" {
90+
zone_id = data.aws_route53_zone.zone.id
91+
name = var.domain_name
92+
type = "CNAME"
93+
ttl = 300
94+
records = [aws_cloudfront_distribution.website.domain_name]
95+
}
96+
97+
output "distribution_arn" {
98+
value = aws_cloudfront_distribution.website.arn
99+
}

terragrunt/modules/static-website/outputs.tf

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
variable "domain_name" {
2+
type = string
3+
description = "Domain name of the CloudFront distribution"
4+
}
5+
6+
variable "origin_domain_name" {
7+
type = string
8+
description = "Domain name of the origin"
9+
}
10+
11+
variable "origin_path" {
12+
type = string
13+
default = null
14+
description = "Root path in the origin"
15+
}
16+
17+
variable "origin_access_identity" {
18+
type = string
19+
default = null
20+
description = "Origin Access Identity to use to fetch contents from S3"
21+
}
22+
23+
variable "response_policy_id" {
24+
type = string
25+
description = "CloudFront response headers policy ID"
26+
}

0 commit comments

Comments
 (0)