From 1e696c79ff0612c1f93a432105748af93c9cf8c5 Mon Sep 17 00:00:00 2001 From: Katalina Okano Date: Sun, 30 Jan 2022 17:13:57 -0500 Subject: [PATCH] remove interactions from terraform, fix deploy side configs --- .github/workflows/build.yml | 11 +--- .github/workflows/deploy.yml | 2 +- terraform/.terraform.lock.hcl | 57 ++++++++-------- terraform/api.tf | 5 -- terraform/interactions.tf | 120 ---------------------------------- terraform/variables.tf | 10 +-- 6 files changed, 34 insertions(+), 171 deletions(-) delete mode 100644 terraform/interactions.tf diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de6d7ba..d942321 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,7 +42,6 @@ jobs: matrix: worker: - api - - interactions steps: - uses: actions/checkout@master @@ -64,9 +63,6 @@ jobs: && echo ::set-output name=skip::1 \ || echo ::set-output name=skip::0 - - run: npm i -g @cloudflare/wrangler - if: steps.check.outputs.skip == '0' - - name: Get yarn cache directory path if: steps.check.outputs.skip == '0' id: yarn-cache-dir-path @@ -85,17 +81,14 @@ jobs: if: steps.check.outputs.skip == '0' - run: | - wrangler init - echo 'webpack_config = "packages/${{ matrix.worker }}/webpack.config.js"' | tee -a wrangler.toml - wrangler build - mv worker/script.js worker/${{ matrix.worker }}.js + yarn build:api if: steps.check.outputs.skip == '0' - id: upload-file if: github.event_name == 'push' && steps.check.outputs.skip == '0' uses: google-github-actions/upload-cloud-storage@main with: - path: worker/${{ matrix.worker }}.js + path: packages/api/dist/index.mjs destination: roleypoly-artifacts/workers/${{ github.sha }} credentials: ${{ secrets.GCS_TF_KEY }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 512d8f9..a69c505 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -60,7 +60,7 @@ jobs: working-directory: ./terraform run: | echo \ - '{"bot_tag": "${{github.event.inputs.bot_tag}}", "worker_tag": "${{github.event.inputs.worker_tag}}", "api_path_to_worker": "./worker-dist/api.js", "interactions_path_to_worker": "./worker-dist/interactions.js"}' \ + '{"bot_tag": "${{github.event.inputs.bot_tag}}", "worker_tag": "${{github.event.inputs.worker_tag}}", "path_to_worker": "./worker-dist/index.mjs"}' \ | jq . \ | tee tags.auto.tfvars.json diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl index fdf81bb..b0e9008 100644 --- a/terraform/.terraform.lock.hcl +++ b/terraform/.terraform.lock.hcl @@ -2,42 +2,43 @@ # Manual edits may be lost in future updates. provider "registry.terraform.io/cloudflare/cloudflare" { - version = "2.25.0" + version = "3.8.0" constraints = ">= 2.23.0" hashes = [ - "h1:raEhY+rMHKBNMwXBWYZp4DUua3JNDq5frLu6VOl71Zg=", - "zh:0c2e4665615fa732cd7a025599afa788cf980d1e3e89b20127f8dd5198a3e124", - "zh:1d09a74f6ee533ae9db4064a9a6ec466ca7e7f53ed2033f95ce66ff066becc9e", - "zh:21f9c1b5d30dc691909b4d1f4635171dc53009109cd7b15ac3ee9c23d84dcc10", - "zh:332cbf7da45231fda97d4ca9d840d70558055b45fb63247f57717572c09edde4", - "zh:4056c8fd7b6ca9f2b96a583ee11e3ee5e11ec0706a4f5fa1816f2bacda359a31", - "zh:5a6e134331acc5c9833993f98cbe48e05c995b8d09ac5d4a11fe4c1488fa34ed", - "zh:71c30ce22b906f9130b7d1afe6ca5be281f7dda1b46c6565b9acd22ca3e30fcb", - "zh:83e53ed8489a8c65d8e39e43ba5c8298b19eba0dfa30c0d2f99d69e81e6516af", - "zh:89900baa4735eb9c678815689979765653ff639a528ac0bbe3fceee50028bea8", - "zh:8ba0ea263f0e04589ec95de2381913e6a3b71d7b67c2e2ddbdd78a023ce5949f", - "zh:a98c952cda50a7286e8286697b195d1dc8c016090023b4b8cd6f772734b7fd71", - "zh:c670798e60fd4807524bf7d407ad284c5674b32f42e56005f63cd356233a2310", - "zh:dadd6787f390379f7f231e1176d24ff7841ac9c6b1e742c6bf506309492f89e1", + "h1:zAhG5lsZGX9sJUbqoaFVZbVsJnvkb+GUKyEZ+EEnW/w=", + "zh:10b57533c2223e60bff24a74f172e36345b6bbbd32c0d0f088c0e5e87a4bd658", + "zh:422c17906d39ccb00ea12972473c18e42d8f352f4c697feeb898209f5dc462da", + "zh:4c3502ff8c96d7faf31a0dd7f2df2422e36e7278db004360ecd71f5af699a335", + "zh:5900f7fbf739629afeb10017ae9880a6587310d36d0e970adb82c880d5ee9911", + "zh:5a8dc8e6bcd7426a98b82cdc5e84c3fd9be2873cd648537e0a007b912a994df6", + "zh:78c7d3a50901ce101ef5241ac22103f5102dd489fb91f2ceaf56b3639ad572d8", + "zh:a1ac1388c93cde331a648cc773f94f5a3c6f1342ac5f824e5ecbd25ffdeba414", + "zh:c650137d3dbd96ca53da4fbd71b487d4457803715aa06333540df5b0e8ad0430", + "zh:d15d4766a2adddd108d1b1dd929d3a40ad063bee39d143ce82bca702f2951f26", + "zh:d66e301dfa2c021cce9ead73b2565d296bcc36766b4273d01d29729848564271", + "zh:da3a3daa0fbbb0be18c60aff6c5b694ea30cbb7cb55f7f782ec7b46658b167ab", + "zh:e6a09b1914aa34b449fba31e626738b186c3c6d43a120aede431c791ceb42ab0", + "zh:e9a84e74af0c9ada163cad436a6752904865e20536af9a048aa9382c12ed8f00", + "zh:eb586af4ddcef26cef609fca80cdffc0885ec5d5465726e6d1ce98624816aaac", ] } provider "registry.terraform.io/hashicorp/google" { - version = "3.78.0" + version = "4.8.0" constraints = ">= 3.74.0" hashes = [ - "h1:iCyTW8BWdr6Bvd5B89wkxlrB8xLxqHvT1CPmGuKembU=", - "zh:027971c4689b6130619827fe57ce260aaca060db3446817d3a92869dba7cc07f", - "zh:0876dbecc0d441bf2479edd17fe9141d77274b5071ea5f68ac26a2994bff66f3", - "zh:2a5363ed6b1b880f5284e604567cfdabecca809584c30bbe7f19ff568d1ea4cd", - "zh:2f5af69b70654bda91199f6393253e3e479107deebfeddc3fe5850b3a1e83dfb", - "zh:52e6816ef11f5f799a6626dfff384e2153b37450d8320f1ef1eee8f71a2a87b2", - "zh:59ae534607db13db35c0015c06d1ae6d4886f01f7e8fd4e07bc120236a01c494", - "zh:65ab2ed1746ea02d0b1bbd8a22ff3a95d09dc8bdb3841fbc17e45e9feccfb327", - "zh:877a71d24ff65ede3f0c5973168acfeaea0f2fea3757cab5600efcddfd3171d5", - "zh:8b10c9643a4a53148f6758bfd60804b33c2b838482f2c39ed210b729e6b1e2e8", - "zh:ba682648d9f6c11a6d04a250ac79eec39271f615f3ff60c5ae73ebfcc2cdb450", - "zh:e946561921e0279450e9b9f705de9354ce35562ed4cc0d4cd3512aa9eb1f6486", + "h1:2EwEiinufTyL/mQ4eQHu+UOwKaHUQfhhU//aA+CopwQ=", + "zh:08d1fbdaee6f9d615e09ab6244d5f8f1b76fd079fc4193822a9f5ac4344b3738", + "zh:27afa2e26921ca5b96e804b781792296e9a9d4ac533d6f87c3855ae68e28ef80", + "zh:2d1fe33d3c6daa85a9ba6608b99d9710c7fcd61199d249e353e82d5bf1a18280", + "zh:31b2c41dbe458d8b75068069bb05864027bd1b4a3f4c8e8b7cd7b9d1fe47be7b", + "zh:4001c5237a4fb383014b685077c12a0b9cdbac28dce0c707a9a4622d62ef06c9", + "zh:82c9ef3f72fa6a8fba163cff94b0f7fd0572724e991af5c7f389feaaf83298d8", + "zh:9524a6dc9d8b2cbcef53ca2c04e121899bb1947ff8d4f9569c3b01b1cb9f736a", + "zh:a33dcd5d8efef4dafaa331918c79b793be036420fc56c40bb3fb313fdb56db0d", + "zh:aa36241871cb5376c7ba8cb8b2ddbfc488c4231e5c0d10b2f421ffaa14c0b462", + "zh:cd2c1ffbab0c6e154ed2472edc2788bc2cb9db93848325e389a7157ebbb540de", + "zh:f350242dabb33035e2b49cd3e925c88c6bf4b73becfaff298d503e4c64e46271", ] } diff --git a/terraform/api.tf b/terraform/api.tf index 26b6bc6..e6edc0d 100644 --- a/terraform/api.tf +++ b/terraform/api.tf @@ -68,11 +68,6 @@ resource "cloudflare_worker_script" "backend" { name = "ROOT_USERS" text = join(",", var.root_users) } - - secret_text_binding { - name = "INTERACTIONS_SHARED_KEY" - text = random_password.interactions_token.result - } } resource "cloudflare_record" "api" { diff --git a/terraform/interactions.tf b/terraform/interactions.tf deleted file mode 100644 index 692a261..0000000 --- a/terraform/interactions.tf +++ /dev/null @@ -1,120 +0,0 @@ -locals { - internalTestingGuilds = toset([ - "386659935687147521" - ]) -} - -resource "random_password" "interactions_token" { - length = 64 - keepers = { - "worker_tag" = var.worker_tag - } -} - -resource "discord-interactions_guild_command" "hello-world" { - for_each = local.internalTestingGuilds - guild_id = each.value - - name = "hello-world" - description = "Say hello!" -} - -resource "discord-interactions_global_command" "roleypoly" { - name = "roleypoly" - description = "Sends you a link to pick your roles in your browser" -} - -resource "discord-interactions_global_command" "pick-role" { - name = "pick-role" - description = "Pick a role! (See which ones can be picked with /pickable-roles)" - - option { - name = "role" - description = "The role you want" - type = 8 - required = true - } -} - -resource "discord-interactions_guild_command" "pick-role" { - for_each = local.internalTestingGuilds - guild_id = each.value - - name = "pick-role" - description = "**[TEST]** Pick a role! (See which ones can be picked with /pickable-roles)" - - - option { - name = "role" - description = "The role you want" - type = 8 - required = true - } -} - -resource "discord-interactions_guild_command" "remove-role" { - for_each = local.internalTestingGuilds - guild_id = each.value - - name = "remove-role" - description = "**[TEST]** Pick a role to remove (See which ones can be removed with /pickable-roles)" - - option { - name = "role" - description = "The role you want to remove" - type = 8 - required = true - } -} - -resource "discord-interactions_global_command" "pickable-roles" { - name = "pickable-roles" - description = "See all the roles you can pick with /pick-roles" -} - -resource "discord-interactions_guild_command" "pickable-roles" { - for_each = local.internalTestingGuilds - guild_id = each.value - - name = "pickable-roles" - description = "See all the roles you can pick with /pick-roles" -} - -resource "cloudflare_worker_script" "interactions" { - name = "roleypoly-interactions-${var.environment_tag}" - content = file("${path.module}/${var.interactions_path_to_worker}") - - secret_text_binding { - name = "DISCORD_PUBLIC_KEY" - text = var.discord_public_key - } - - secret_text_binding { - name = "INTERACTIONS_SHARED_KEY" - text = random_password.interactions_token.result - } - - plain_text_binding { - name = "UI_PUBLIC_URI" - text = var.ui_public_uri - } - - plain_text_binding { - name = "API_PUBLIC_URI" - text = var.api_public_uri - } -} - -resource "cloudflare_record" "interactions" { - zone_id = var.cloudflare_zone_id - name = "interactions-${var.environment_tag}" - type = "AAAA" - value = "100::" - proxied = true -} - -resource "cloudflare_worker_route" "interactions" { - zone_id = var.cloudflare_zone_id - pattern = "interactions-${var.environment_tag}.roleypoly.com/*" - script_name = cloudflare_worker_script.interactions.name -} diff --git a/terraform/variables.tf b/terraform/variables.tf index 4efee8b..c2a4902 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -57,16 +57,10 @@ variable "api_public_uri" { description = "API Public Base Path" } -variable "api_path_to_worker" { +variable "path_to_worker" { type = string description = "Path to API worker JS, relative to this file/terraform folder." - default = "worker-dist/api.js" -} - -variable "interactions_path_to_worker" { - type = string - description = "Path to interactions worker JS, relative to this file/terraform folder." - default = "worker-dist/interactions.js" + default = "worker-dist/index.mjs" } variable "root_users" {