Skip to content

Commit 2f9458a

Browse files
authored
chore: release playground on s3. (#13582)
Please read [contributing guidelines](CONTRIBUTING.md) and remove this line.
1 parent a296945 commit 2f9458a

File tree

8 files changed

+2656
-11367
lines changed

8 files changed

+2656
-11367
lines changed

aztec-up/terraform/main.tf

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ data "terraform_remote_state" "aztec2_iac" {
2626
}
2727
}
2828

29-
variable "VERSION" {
30-
description = "The version of the Aztec scripts to upload"
31-
type = string
32-
}
33-
3429
# Create the website S3 bucket
3530
resource "aws_s3_bucket" "install_bucket" {
3631
bucket = "install.aztec.network"
@@ -71,7 +66,7 @@ resource "aws_s3_bucket_policy" "install_bucket_policy" {
7166

7267
resource "aws_cloudfront_distribution" "install" {
7368
origin {
74-
domain_name = aws_s3_bucket.install_bucket.website_endpoint
69+
domain_name = aws_s3_bucket_website_configuration.website_bucket.website_endpoint
7570
origin_id = "S3-install-aztec-network"
7671

7772
custom_origin_config {
@@ -101,9 +96,7 @@ resource "aws_cloudfront_distribution" "install" {
10196
}
10297
}
10398

104-
# TODO: Once new aztec-up script (almost certainly within days of this change), switch to redirect-to-https.
105-
# viewer_protocol_policy = "redirect-to-https"
106-
viewer_protocol_policy = "allow-all"
99+
viewer_protocol_policy = "redirect-to-https"
107100
min_ttl = 0
108101
default_ttl = 3600
109102
max_ttl = 86400

playground/.rebuild_patterns

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
^playground/src/
22
^playground/bootstrap.sh
3+
^playground/vite.config.ts

playground/bootstrap.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function release {
3030
echo_header "playground release"
3131
if [ $(dist_tag) != "latest" ]; then
3232
# TODO attach to github release
33-
do_or_dryrun yarn netlify deploy --site aztec-playground --dir=dist
33+
do_or_dryrun aws s3 sync ./dist s3://play.aztec.network/$REF_NAME
3434
else
35-
do_or_dryrun yarn netlify deploy --site aztec-playground --prod --dir=dist
35+
do_or_dryrun aws s3 sync ./dist s3://play.aztec.network/
3636
fi
3737
}
3838

playground/netlify.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

playground/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"eslint-plugin-react-hooks": "^5.1.0",
5151
"eslint-plugin-react-refresh": "^0.4.18",
5252
"globals": "^15.14.0",
53-
"netlify-cli": "^17.23.0",
5453
"prettier": "^2.8.8",
5554
"typescript": "~5.7.3",
5655
"typescript-eslint": "^8.11.0",

playground/terraform/main.tf

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
terraform {
2+
backend "s3" {
3+
bucket = "aztec-terraform"
4+
region = "eu-west-2"
5+
key = "aztec-playground"
6+
}
7+
required_providers {
8+
aws = {
9+
source = "hashicorp/aws"
10+
version = "5.29.0"
11+
}
12+
}
13+
}
14+
15+
# Define provider and region.
16+
provider "aws" {
17+
region = "eu-west-2"
18+
}
19+
20+
data "terraform_remote_state" "aztec2_iac" {
21+
backend = "s3"
22+
config = {
23+
bucket = "aztec-terraform"
24+
key = "aztec2/iac"
25+
region = "eu-west-2"
26+
}
27+
}
28+
29+
# Create the website S3 bucket
30+
resource "aws_s3_bucket" "playground_bucket" {
31+
bucket = "play.aztec.network"
32+
}
33+
34+
resource "aws_s3_bucket_website_configuration" "website_bucket" {
35+
bucket = aws_s3_bucket.playground_bucket.id
36+
37+
index_document {
38+
suffix = "index.html"
39+
}
40+
}
41+
42+
resource "aws_s3_bucket_public_access_block" "playground_bucket_public_access" {
43+
bucket = aws_s3_bucket.playground_bucket.id
44+
45+
block_public_acls = false
46+
ignore_public_acls = false
47+
block_public_policy = false
48+
restrict_public_buckets = false
49+
}
50+
51+
resource "aws_s3_bucket_policy" "playground_bucket_policy" {
52+
bucket = aws_s3_bucket.playground_bucket.id
53+
54+
policy = jsonencode({
55+
Version = "2012-10-17"
56+
Statement = [
57+
{
58+
Effect = "Allow"
59+
Principal = "*"
60+
Action = "s3:GetObject"
61+
Resource = "arn:aws:s3:::${aws_s3_bucket.playground_bucket.id}/*"
62+
}
63+
]
64+
})
65+
}
66+
67+
resource "aws_cloudfront_function" "coop_coep_headers" {
68+
name = "coop-coep-headers"
69+
runtime = "cloudfront-js-1.0"
70+
code = <<-EOF
71+
function handler(event) {
72+
var response = event.response;
73+
response.headers["cross-origin-embedder-policy"] = { value: "require-corp" };
74+
response.headers["cross-origin-opener-policy"] = { value: "same-origin" };
75+
return response;
76+
}
77+
EOF
78+
comment = "Adds COOP and COEP headers to enable shared memory"
79+
}
80+
81+
resource "aws_cloudfront_distribution" "playground" {
82+
origin {
83+
domain_name = aws_s3_bucket_website_configuration.website_bucket.website_endpoint
84+
origin_id = "S3-play-aztec-network"
85+
86+
custom_origin_config {
87+
http_port = 80
88+
https_port = 443
89+
origin_protocol_policy = "http-only"
90+
origin_ssl_protocols = ["TLSv1.2"]
91+
}
92+
}
93+
94+
enabled = true
95+
is_ipv6_enabled = true
96+
default_root_object = ""
97+
98+
aliases = ["play.aztec.network"]
99+
100+
default_cache_behavior {
101+
allowed_methods = ["GET", "HEAD"]
102+
cached_methods = ["GET", "HEAD"]
103+
target_origin_id = "S3-play-aztec-network"
104+
105+
forwarded_values {
106+
query_string = false
107+
108+
cookies {
109+
forward = "none"
110+
}
111+
}
112+
113+
viewer_protocol_policy = "redirect-to-https"
114+
min_ttl = 0
115+
default_ttl = 3600
116+
max_ttl = 86400
117+
118+
function_association {
119+
event_type = "viewer-response"
120+
function_arn = aws_cloudfront_function.coop_coep_headers.arn
121+
}
122+
}
123+
124+
price_class = "PriceClass_All"
125+
126+
viewer_certificate {
127+
acm_certificate_arn = data.terraform_remote_state.aztec2_iac.outputs.aws_acm_certificate_aztec_network_arn
128+
ssl_support_method = "sni-only"
129+
minimum_protocol_version = "TLSv1.2_2019"
130+
}
131+
132+
restrictions {
133+
geo_restriction {
134+
restriction_type = "none"
135+
}
136+
}
137+
}
138+
139+
resource "aws_route53_record" "playground_record" {
140+
zone_id = data.terraform_remote_state.aztec2_iac.outputs.aws_route53_zone_id
141+
name = "play.aztec.network"
142+
type = "A"
143+
144+
alias {
145+
name = aws_cloudfront_distribution.playground.domain_name
146+
zone_id = aws_cloudfront_distribution.playground.hosted_zone_id
147+
evaluate_target_health = false
148+
}
149+
}
150+
151+
output "cloudfront_distribution_id" {
152+
value = aws_cloudfront_distribution.playground.id
153+
}

playground/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const nodePolyfillsFix = (options?: PolyfillOptions | undefined): Plugin => {
2525
export default defineConfig(({ mode }) => {
2626
const env = loadEnv(mode, process.cwd(), '');
2727
return {
28+
base: './',
2829
logLevel: process.env.CI ? 'error' : undefined,
2930
server: {
3031
// Headers needed for bb WASM to work in multithreaded mode

0 commit comments

Comments
 (0)