From 58c9d6001ee047377fba8fea9978292154fd271d Mon Sep 17 00:00:00 2001 From: Philex Date: Fri, 11 Oct 2024 02:18:19 -0700 Subject: [PATCH 1/3] add VITE_CLERK_PUBLISHABLE_KEY and refine terraform code --- .env.production | 1 + terraform/Amplify/main.tf | 31 ++++++++++++++++++++++++++++++- terraform/Amplify/output.tf | 8 ++++++++ terraform/Amplify/var.tf | 6 ++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 terraform/Amplify/output.tf create mode 100644 terraform/Amplify/var.tf diff --git a/.env.production b/.env.production index 49ab2996..ace57421 100644 --- a/.env.production +++ b/.env.production @@ -1,2 +1,3 @@ VITE_API_BASE_URL=https://api.restaking.info +VITE_CLERK_PUBLISHABLE_KEY=pk_test_b3B0aW1hbC1jaGlja2VuLTU3LmNsZXJrLmFjY291bnRzLmRldiQ VITE_LOG_LEVEL=info diff --git a/terraform/Amplify/main.tf b/terraform/Amplify/main.tf index 2daed176..8fb6edf0 100644 --- a/terraform/Amplify/main.tf +++ b/terraform/Amplify/main.tf @@ -1,5 +1,5 @@ resource "aws_amplify_app" "main" { - name = "restaking-dashboard" + name = "restaking-dashboard-app" repository = "https://github.com/NethermindEth/restaking-dashboard" environment_variables = { @@ -16,11 +16,23 @@ resource "aws_amplify_app" "main" { status = "200" target = "/index.html" } + # It is required when first time to deploy the app + # oauth_token = var.github_oauth_token + } resource "aws_amplify_branch" "main" { app_id = aws_amplify_app.main.id branch_name = "main" + stage = "DEVELOPMENT" + + enable_auto_build = false +} + +# Release branch for production environment +resource "aws_amplify_branch" "release" { + app_id = aws_amplify_app.main.id + branch_name = "release/v0.1.0" stage = "PRODUCTION" enable_auto_build = false @@ -37,6 +49,17 @@ resource "aws_amplify_domain_association" "main" { branch_name = aws_amplify_branch.main.branch_name prefix = "stage" } + + sub_domain { + branch_name = aws_amplify_branch.release.branch_name + prefix = "prod" + } + +# sub_domain { +# branch_name = aws_amplify_branch.release.branch_name +# prefix = "" +# } + } @@ -46,3 +69,9 @@ resource "aws_amplify_webhook" "stage" { description = "stage" } + +resource "aws_amplify_webhook" "release" { + app_id = aws_amplify_app.main.id + branch_name = aws_amplify_branch.release.branch_name + description = "release" +} diff --git a/terraform/Amplify/output.tf b/terraform/Amplify/output.tf new file mode 100644 index 00000000..467073b5 --- /dev/null +++ b/terraform/Amplify/output.tf @@ -0,0 +1,8 @@ + +output "aws_amplify_domain_association" { + value = aws_amplify_domain_association.main.sub_domain +} + +output "aws_amplify_webhook"{ +value = aws_amplify_webhook.stage.url +} diff --git a/terraform/Amplify/var.tf b/terraform/Amplify/var.tf new file mode 100644 index 00000000..34712876 --- /dev/null +++ b/terraform/Amplify/var.tf @@ -0,0 +1,6 @@ +#When tHe first time to deploy, github Oauth token is required +#variable "github_oauth_token" { +# description = "GitHub OAuth Token for Amplify" +# type = string +# sensitive = true +#} From 6ad281f2264dedcb5c9a0c78095fdcd2054416b6 Mon Sep 17 00:00:00 2001 From: Philex Date: Sun, 13 Oct 2024 22:34:59 -0700 Subject: [PATCH 2/3] add VITE_CLERK_PUBLISHABLE_KEY and refine terraform code add domain for production env. --- terraform/Amplify/main.tf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/terraform/Amplify/main.tf b/terraform/Amplify/main.tf index 8fb6edf0..347cfd0a 100644 --- a/terraform/Amplify/main.tf +++ b/terraform/Amplify/main.tf @@ -50,15 +50,19 @@ resource "aws_amplify_domain_association" "main" { prefix = "stage" } + # add this for pre-production domain + # https://prod.restaking.info sub_domain { branch_name = aws_amplify_branch.release.branch_name prefix = "prod" } -# sub_domain { -# branch_name = aws_amplify_branch.release.branch_name -# prefix = "" -# } + # add this for production domain + # https://restaking.info + sub_domain { + branch_name = aws_amplify_branch.release.branch_name + prefix = "" + } } From 7f77695bb470bd00635108ee8678a9a4a0860cd7 Mon Sep 17 00:00:00 2001 From: Philex Date: Sun, 13 Oct 2024 22:38:50 -0700 Subject: [PATCH 3/3] remove comments and delete unnecessary file. --- terraform/Amplify/main.tf | 2 -- terraform/Amplify/var.tf | 6 ------ 2 files changed, 8 deletions(-) delete mode 100644 terraform/Amplify/var.tf diff --git a/terraform/Amplify/main.tf b/terraform/Amplify/main.tf index 347cfd0a..1ed102b9 100644 --- a/terraform/Amplify/main.tf +++ b/terraform/Amplify/main.tf @@ -16,8 +16,6 @@ resource "aws_amplify_app" "main" { status = "200" target = "/index.html" } - # It is required when first time to deploy the app - # oauth_token = var.github_oauth_token } diff --git a/terraform/Amplify/var.tf b/terraform/Amplify/var.tf deleted file mode 100644 index 34712876..00000000 --- a/terraform/Amplify/var.tf +++ /dev/null @@ -1,6 +0,0 @@ -#When tHe first time to deploy, github Oauth token is required -#variable "github_oauth_token" { -# description = "GitHub OAuth Token for Amplify" -# type = string -# sensitive = true -#}