From 2d128b530e5b741f770fc9da24d349b23a026412 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Thu, 5 Oct 2023 09:07:53 -0400 Subject: [PATCH 1/8] Add cloudflare pages, first cut * Copied from https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/pages_project --- bankless-community/cloudflare/pages.tf | 81 ++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 bankless-community/cloudflare/pages.tf diff --git a/bankless-community/cloudflare/pages.tf b/bankless-community/cloudflare/pages.tf new file mode 100644 index 0000000..3e6125d --- /dev/null +++ b/bankless-community/cloudflare/pages.tf @@ -0,0 +1,81 @@ +resource "cloudflare_pages_project" "deployment_configs" { + account_id = "f037e56e89293a057740de681ac9abbe" + name = "this-is-my-project-01" + production_branch = "main" + + source { + type = "github" + config { + owner = "cloudflare" + repo_name = "ninjakittens" + production_branch = "main" + pr_comments_enabled = true + deployments_enabled = true + production_deployment_enabled = true + preview_deployment_setting = "custom" + preview_branch_includes = ["dev", "preview"] + preview_branch_excludes = ["main", "prod"] + } + } + + build_config { + build_command = "npm run build" + destination_dir = "build" + root_dir = "" + web_analytics_tag = "cee1c73f6e4743d0b5e6bb1a0bcaabcc" + web_analytics_token = "021e1057c18547eca7b79f2516f06o7x" + } + + deployment_configs { + preview { + environment_variables = { + ENVIRONMENT = "preview" + } + secrets = { + TURNSTILE_SECRET = "1x0000000000000000000000000000000AA" + } + kv_namespaces = { + KV_BINDING = "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + durable_object_namespaces = { + DO_BINDING = "5eb63bbbe01eeed093cb22bb8f5acdc3" + } + r2_buckets = { + R2_BINDING = "some-bucket" + } + d1_databases = { + D1_BINDING = "445e2955-951a-4358-a35b-a4d0c813f63" + } + compatibility_date = "2022-08-15" + compatibility_flags = ["nodejs_compat"] + } + production { + environment_variables = { + ENVIRONMENT = "production" + OTHER_VALUE = "other value" + } + secrets = { + TURNSTILE_SECRET = "1x0000000000000000000000000000000AA" + TURNSTILE_INVIS_SECRET = "2x0000000000000000000000000000000AA" + } + kv_namespaces = { + KV_BINDING_1 = "5eb63bbbe01eeed093cb22bb8f5acdc3" + KV_BINDING_2 = "3cdca5f8bb22bc390deee10ebbb36be5" + } + durable_object_namespaces = { + DO_BINDING_1 = "5eb63bbbe01eeed093cb22bb8f5acdc3" + DO_BINDING_2 = "3cdca5f8bb22bc390deee10ebbb36be5" + } + r2_buckets = { + R2_BINDING_1 = "some-bucket" + R2_BINDING_2 = "other-bucket" + } + d1_databases = { + D1_BINDING_1 = "445e2955-951a-4358-a35b-a4d0c813f63" + D1_BINDING_2 = "a399414b-c697-409a-a688-377db6433cd9" + } + compatibility_date = "2022-08-16" + compatibility_flags = ["nodejs_compat", "streams_enable_constructors"] + } + } +} \ No newline at end of file From 6788f999db5592e67a58e017fc7f030b0364711c Mon Sep 17 00:00:00 2001 From: MantisClone Date: Thu, 5 Oct 2023 09:31:55 -0400 Subject: [PATCH 2/8] Fix cloudflare pages config --- bankless-community/cloudflare/pages.tf | 64 +++++++------------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/bankless-community/cloudflare/pages.tf b/bankless-community/cloudflare/pages.tf index 3e6125d..dcb27cb 100644 --- a/bankless-community/cloudflare/pages.tf +++ b/bankless-community/cloudflare/pages.tf @@ -1,29 +1,25 @@ resource "cloudflare_pages_project" "deployment_configs" { - account_id = "f037e56e89293a057740de681ac9abbe" - name = "this-is-my-project-01" + account_id = local.cloudflare_account_id + name = local.cloudflare_account_name production_branch = "main" source { type = "github" config { - owner = "cloudflare" - repo_name = "ninjakittens" + owner = local.cloudflare_account_name + repo_name = "bankless-website" production_branch = "main" pr_comments_enabled = true deployments_enabled = true production_deployment_enabled = true - preview_deployment_setting = "custom" - preview_branch_includes = ["dev", "preview"] - preview_branch_excludes = ["main", "prod"] + preview_deployment_setting = "all" } } build_config { - build_command = "npm run build" - destination_dir = "build" + build_command = "npx next build" + destination_dir = "out" root_dir = "" - web_analytics_tag = "cee1c73f6e4743d0b5e6bb1a0bcaabcc" - web_analytics_token = "021e1057c18547eca7b79f2516f06o7x" } deployment_configs { @@ -32,50 +28,24 @@ resource "cloudflare_pages_project" "deployment_configs" { ENVIRONMENT = "preview" } secrets = { - TURNSTILE_SECRET = "1x0000000000000000000000000000000AA" + NEXT_PUBLIC_ALCHEMY_API_KEY = "xoSmxF5VP5yJq0zV-MedaxZUCYSt7DUN" + NEXT_PUBLIC_BLOCKNATIVE_API_KEY = "9176eee3-12fa-431c-93c5-27d1f40d4c91" + NEXT_PUBLIC_INFURA_PROJECT_ID = "9344a875cace468ca6c8029147cda56a" + NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = "e1726502f108ccc7845fc598e1a605f3" } - kv_namespaces = { - KV_BINDING = "5eb63bbbe01eeed093cb22bb8f5acdc3" - } - durable_object_namespaces = { - DO_BINDING = "5eb63bbbe01eeed093cb22bb8f5acdc3" - } - r2_buckets = { - R2_BINDING = "some-bucket" - } - d1_databases = { - D1_BINDING = "445e2955-951a-4358-a35b-a4d0c813f63" - } - compatibility_date = "2022-08-15" - compatibility_flags = ["nodejs_compat"] + always_use_latest_compatibility_date = true } production { environment_variables = { ENVIRONMENT = "production" - OTHER_VALUE = "other value" } secrets = { - TURNSTILE_SECRET = "1x0000000000000000000000000000000AA" - TURNSTILE_INVIS_SECRET = "2x0000000000000000000000000000000AA" - } - kv_namespaces = { - KV_BINDING_1 = "5eb63bbbe01eeed093cb22bb8f5acdc3" - KV_BINDING_2 = "3cdca5f8bb22bc390deee10ebbb36be5" - } - durable_object_namespaces = { - DO_BINDING_1 = "5eb63bbbe01eeed093cb22bb8f5acdc3" - DO_BINDING_2 = "3cdca5f8bb22bc390deee10ebbb36be5" - } - r2_buckets = { - R2_BINDING_1 = "some-bucket" - R2_BINDING_2 = "other-bucket" - } - d1_databases = { - D1_BINDING_1 = "445e2955-951a-4358-a35b-a4d0c813f63" - D1_BINDING_2 = "a399414b-c697-409a-a688-377db6433cd9" + NEXT_PUBLIC_ALCHEMY_API_KEY = "xoSmxF5VP5yJq0zV-MedaxZUCYSt7DUN" + NEXT_PUBLIC_BLOCKNATIVE_API_KEY = "9176eee3-12fa-431c-93c5-27d1f40d4c91" + NEXT_PUBLIC_INFURA_PROJECT_ID = "9344a875cace468ca6c8029147cda56a" + NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = "e1726502f108ccc7845fc598e1a605f3" } - compatibility_date = "2022-08-16" - compatibility_flags = ["nodejs_compat", "streams_enable_constructors"] + always_use_latest_compatibility_date = true } } } \ No newline at end of file From 7d38486752be77e85c99e0c49512f1299afaf436 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Thu, 5 Oct 2023 10:00:36 -0400 Subject: [PATCH 3/8] Fix README (there is no Makefile so `make` doesn't work) --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fdbd3c6..146d64e 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,21 @@ We're currently using Root First structure, meaning each folder contains a compl ├──── cloudflare # Contains DNS Records for BanklessCard.xyz └── README.md +## Prerequisites + +* [Terraform](https://www.terraform.io/downloads.html) +* [pre-commit](https://pre-commit.com/) + +Make sure you have `pre-commit`, and `terraform` in your `$PATH`. + ## Terraform Cloud All infrastructure changes will automatically plan but require approval from infosec.bankless.community memeber. ## pre-commit -This repo uses Yelp's [pre-commit](https://pre-commit.com/) to manage some pre-commit hooks automatically. -In order to use the hooks, make sure you have `pre-commit`, and `terraform` in your `$PATH`. -Once in your path you should run `make` in order to configure it. If you push commits that fail pre-commit, your PR will -not pass tests +Configure pre-commit hooks before making changes. +If you push commits that fail pre-commit, your PR will not pass tests. + +```bash +pre-commit install +``` From 407f19407238e5c77385945c22c32887076248b1 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Thu, 5 Oct 2023 10:01:02 -0400 Subject: [PATCH 4/8] Ignore python venv --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 00237ad..ac9ada7 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ override.tf.json # IDE dirs .idea/ + +# python +venv/ From 6ddc0c2b65f85f6e160e07f7f7d3919b19adc342 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Thu, 5 Oct 2023 10:01:38 -0400 Subject: [PATCH 5/8] Fix cloudflare pages formatting using pre-commit --- bankless-community/cloudflare/pages.tf | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bankless-community/cloudflare/pages.tf b/bankless-community/cloudflare/pages.tf index dcb27cb..eb10217 100644 --- a/bankless-community/cloudflare/pages.tf +++ b/bankless-community/cloudflare/pages.tf @@ -17,9 +17,9 @@ resource "cloudflare_pages_project" "deployment_configs" { } build_config { - build_command = "npx next build" - destination_dir = "out" - root_dir = "" + build_command = "npx next build" + destination_dir = "out" + root_dir = "" } deployment_configs { @@ -28,9 +28,9 @@ resource "cloudflare_pages_project" "deployment_configs" { ENVIRONMENT = "preview" } secrets = { - NEXT_PUBLIC_ALCHEMY_API_KEY = "xoSmxF5VP5yJq0zV-MedaxZUCYSt7DUN" - NEXT_PUBLIC_BLOCKNATIVE_API_KEY = "9176eee3-12fa-431c-93c5-27d1f40d4c91" - NEXT_PUBLIC_INFURA_PROJECT_ID = "9344a875cace468ca6c8029147cda56a" + NEXT_PUBLIC_ALCHEMY_API_KEY = "xoSmxF5VP5yJq0zV-MedaxZUCYSt7DUN" + NEXT_PUBLIC_BLOCKNATIVE_API_KEY = "9176eee3-12fa-431c-93c5-27d1f40d4c91" + NEXT_PUBLIC_INFURA_PROJECT_ID = "9344a875cace468ca6c8029147cda56a" NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = "e1726502f108ccc7845fc598e1a605f3" } always_use_latest_compatibility_date = true @@ -40,12 +40,12 @@ resource "cloudflare_pages_project" "deployment_configs" { ENVIRONMENT = "production" } secrets = { - NEXT_PUBLIC_ALCHEMY_API_KEY = "xoSmxF5VP5yJq0zV-MedaxZUCYSt7DUN" - NEXT_PUBLIC_BLOCKNATIVE_API_KEY = "9176eee3-12fa-431c-93c5-27d1f40d4c91" - NEXT_PUBLIC_INFURA_PROJECT_ID = "9344a875cace468ca6c8029147cda56a" + NEXT_PUBLIC_ALCHEMY_API_KEY = "xoSmxF5VP5yJq0zV-MedaxZUCYSt7DUN" + NEXT_PUBLIC_BLOCKNATIVE_API_KEY = "9176eee3-12fa-431c-93c5-27d1f40d4c91" + NEXT_PUBLIC_INFURA_PROJECT_ID = "9344a875cace468ca6c8029147cda56a" NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = "e1726502f108ccc7845fc598e1a605f3" } always_use_latest_compatibility_date = true } } -} \ No newline at end of file +} From c58019839cf40a7c9b8f50d4dbb68e678d4af33e Mon Sep 17 00:00:00 2001 From: MantisClone Date: Thu, 5 Oct 2023 10:36:12 -0400 Subject: [PATCH 6/8] Convert plaintext secrets to senstive variables --- bankless-community/cloudflare/pages.tf | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bankless-community/cloudflare/pages.tf b/bankless-community/cloudflare/pages.tf index eb10217..74288ed 100644 --- a/bankless-community/cloudflare/pages.tf +++ b/bankless-community/cloudflare/pages.tf @@ -1,3 +1,8 @@ +variable "alchemy_api_key" { sensitive = true } +variable "blocknative_api_key" { sensitive = true } +variable "infura_project_id" { sensitive = true } +variable "walletconnect_project_id" { sensitive = true } + resource "cloudflare_pages_project" "deployment_configs" { account_id = local.cloudflare_account_id name = local.cloudflare_account_name @@ -28,10 +33,10 @@ resource "cloudflare_pages_project" "deployment_configs" { ENVIRONMENT = "preview" } secrets = { - NEXT_PUBLIC_ALCHEMY_API_KEY = "xoSmxF5VP5yJq0zV-MedaxZUCYSt7DUN" - NEXT_PUBLIC_BLOCKNATIVE_API_KEY = "9176eee3-12fa-431c-93c5-27d1f40d4c91" - NEXT_PUBLIC_INFURA_PROJECT_ID = "9344a875cace468ca6c8029147cda56a" - NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = "e1726502f108ccc7845fc598e1a605f3" + NEXT_PUBLIC_ALCHEMY_API_KEY = alchemy_api_key + NEXT_PUBLIC_BLOCKNATIVE_API_KEY = blocknative_api_key + NEXT_PUBLIC_INFURA_PROJECT_ID = infura_project_id + NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = walletconnect_project_id } always_use_latest_compatibility_date = true } @@ -40,10 +45,10 @@ resource "cloudflare_pages_project" "deployment_configs" { ENVIRONMENT = "production" } secrets = { - NEXT_PUBLIC_ALCHEMY_API_KEY = "xoSmxF5VP5yJq0zV-MedaxZUCYSt7DUN" - NEXT_PUBLIC_BLOCKNATIVE_API_KEY = "9176eee3-12fa-431c-93c5-27d1f40d4c91" - NEXT_PUBLIC_INFURA_PROJECT_ID = "9344a875cace468ca6c8029147cda56a" - NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = "e1726502f108ccc7845fc598e1a605f3" + NEXT_PUBLIC_ALCHEMY_API_KEY = alchemy_api_key + NEXT_PUBLIC_BLOCKNATIVE_API_KEY = blocknative_api_key + NEXT_PUBLIC_INFURA_PROJECT_ID = infura_project_id + NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = walletconnect_project_id } always_use_latest_compatibility_date = true } From 0a40316effcbf1d46ccae132654c400f76fc5bd9 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Mon, 16 Oct 2023 20:58:53 -0400 Subject: [PATCH 7/8] Move variables to variable.tf --- bankless-community/cloudflare/pages.tf | 5 ----- bankless-community/cloudflare/variables.tf | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bankless-community/cloudflare/pages.tf b/bankless-community/cloudflare/pages.tf index 74288ed..8ab0a27 100644 --- a/bankless-community/cloudflare/pages.tf +++ b/bankless-community/cloudflare/pages.tf @@ -1,8 +1,3 @@ -variable "alchemy_api_key" { sensitive = true } -variable "blocknative_api_key" { sensitive = true } -variable "infura_project_id" { sensitive = true } -variable "walletconnect_project_id" { sensitive = true } - resource "cloudflare_pages_project" "deployment_configs" { account_id = local.cloudflare_account_id name = local.cloudflare_account_name diff --git a/bankless-community/cloudflare/variables.tf b/bankless-community/cloudflare/variables.tf index 0838897..b0009e4 100644 --- a/bankless-community/cloudflare/variables.tf +++ b/bankless-community/cloudflare/variables.tf @@ -1,3 +1,7 @@ variable "cloudflare_api_token" { sensitive = true } +variable "alchemy_api_key" { sensitive = true } +variable "blocknative_api_key" { sensitive = true } +variable "infura_project_id" { sensitive = true } +variable "walletconnect_project_id" { sensitive = true } From 988bc586db0ebb5a599bab19f365ba9d97eced19 Mon Sep 17 00:00:00 2001 From: MantisClone Date: Tue, 24 Oct 2023 15:16:42 -0400 Subject: [PATCH 8/8] Fix variable invocation to `var.var_name` instead of `var_name`. --- bankless-community/cloudflare/pages.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bankless-community/cloudflare/pages.tf b/bankless-community/cloudflare/pages.tf index 8ab0a27..c78379e 100644 --- a/bankless-community/cloudflare/pages.tf +++ b/bankless-community/cloudflare/pages.tf @@ -28,10 +28,10 @@ resource "cloudflare_pages_project" "deployment_configs" { ENVIRONMENT = "preview" } secrets = { - NEXT_PUBLIC_ALCHEMY_API_KEY = alchemy_api_key - NEXT_PUBLIC_BLOCKNATIVE_API_KEY = blocknative_api_key - NEXT_PUBLIC_INFURA_PROJECT_ID = infura_project_id - NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = walletconnect_project_id + NEXT_PUBLIC_ALCHEMY_API_KEY = var.alchemy_api_key + NEXT_PUBLIC_BLOCKNATIVE_API_KEY = var.blocknative_api_key + NEXT_PUBLIC_INFURA_PROJECT_ID = var.infura_project_id + NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID = var.walletconnect_project_id } always_use_latest_compatibility_date = true }