From 031ab06870f33fad195f4592de2c2eef446e794e Mon Sep 17 00:00:00 2001 From: alexraskin Date: Wed, 10 Apr 2024 19:54:33 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Remove=20unnecessary=20Terraform=20?= =?UTF-8?q?initialization=20step.=20add=20docker=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-publish.yaml | 48 +++++ .github/workflows/terraform.yaml | 33 ---- .pre-commit-config.yaml | 22 --- .terraform-docs.yml | 42 ----- .tool-versions | 2 - Dockerfile | 9 +- Makefile | 8 - example-files/terraform.tfvars.example | 62 ------- .../terraform/bot/.terraform.lock.hcl | 165 ------------------ infrastructure/terraform/bot/README.md | 93 ---------- infrastructure/terraform/bot/data.tf | 7 - infrastructure/terraform/bot/main.tf | 9 - infrastructure/terraform/bot/mongodb.tf | 39 ----- infrastructure/terraform/bot/outputs.tf | 4 - infrastructure/terraform/bot/railway.tf | 40 ----- infrastructure/terraform/bot/s3.tf | 99 ----------- infrastructure/terraform/bot/sentry.tf | 16 -- infrastructure/terraform/bot/shared-envs.tf | 23 --- infrastructure/terraform/bot/variables.tf | 144 --------------- infrastructure/terraform/bot/versions.tf | 25 --- runtime.txt | 1 - 21 files changed, 52 insertions(+), 839 deletions(-) create mode 100644 .github/workflows/build-publish.yaml delete mode 100644 .github/workflows/terraform.yaml delete mode 100644 .pre-commit-config.yaml delete mode 100644 .terraform-docs.yml delete mode 100644 .tool-versions delete mode 100644 example-files/terraform.tfvars.example delete mode 100644 infrastructure/terraform/bot/.terraform.lock.hcl delete mode 100644 infrastructure/terraform/bot/README.md delete mode 100644 infrastructure/terraform/bot/data.tf delete mode 100644 infrastructure/terraform/bot/main.tf delete mode 100644 infrastructure/terraform/bot/mongodb.tf delete mode 100644 infrastructure/terraform/bot/outputs.tf delete mode 100644 infrastructure/terraform/bot/railway.tf delete mode 100644 infrastructure/terraform/bot/s3.tf delete mode 100644 infrastructure/terraform/bot/sentry.tf delete mode 100644 infrastructure/terraform/bot/shared-envs.tf delete mode 100644 infrastructure/terraform/bot/variables.tf delete mode 100644 infrastructure/terraform/bot/versions.tf delete mode 100644 runtime.txt diff --git a/.github/workflows/build-publish.yaml b/.github/workflows/build-publish.yaml new file mode 100644 index 0000000..e8bcb4a --- /dev/null +++ b/.github/workflows/build-publish.yaml @@ -0,0 +1,48 @@ +# +name: Create and publish a Docker image + +# Configures this workflow to run every time a change is pushed to the branch called `release`. +on: + release: + types: [published] + +# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. +jobs: + build-and-push-image: + runs-on: ubuntu-latest + # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. + permissions: + contents: read + packages: write + # + steps: + - name: Checkout repository + uses: actions/checkout@v4 + # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. + # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. + # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/terraform.yaml b/.github/workflows/terraform.yaml deleted file mode 100644 index 5abf6f1..0000000 --- a/.github/workflows/terraform.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: Terraform Checks - -on: [push] - -jobs: - terraform-checks: - runs-on: ubuntu-latest - container: smartrent/terraform-ci:1.0.11 - steps: - - name: Clone Local Repo - uses: actions/checkout@v2 - with: - path: infrastructure/terraform/ - - - name: Terraform init - run: | - terraform init -input=false - - - name: Verify Terraform version - run: | - terraform --version - - - name: terraform format - run: | - terraform fmt -check -recursive - - - name: tflint - run: | - tflint - - - name: Terraform validation - run: | - terraform validate \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 8394068..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 - hooks: - # Security - - id: detect-aws-credentials - args: ['--allow-missing-credentials'] - - id: detect-private-key - -- repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.60.0 - hooks: - # Terraform - - id: terraform_fmt - args: - - --args=-write - - --args=-recursive - - --args=-diff - - id: terraform_docs - args: - - --hook-config=--add-to-existing-file=true - - --hook-config=--create-file-if-not-exist=true \ No newline at end of file diff --git a/.terraform-docs.yml b/.terraform-docs.yml deleted file mode 100644 index 835f0c6..0000000 --- a/.terraform-docs.yml +++ /dev/null @@ -1,42 +0,0 @@ -formatter: "markdown" # this is required - -version: "v0.16.0" - -header-from: main.tf -footer-from: "" - -recursive: - enabled: true - path: modules - -sections: - hide: [] - show: [] - -content: "" - -output: - file: "README.md" - mode: inject - template: |- - - {{ .Content }} - -sort: - enabled: true - by: name - -settings: - anchor: true - color: true - default: true - description: true - escape: true - hide-empty: false - html: true - indent: 2 - lockfile: true - read-comments: true - required: true - sensitive: true - type: true \ No newline at end of file diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index 72d1b3b..0000000 --- a/.tool-versions +++ /dev/null @@ -1,2 +0,0 @@ -pre-commit 2.16.0 -terraform-docs v0.16.0 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index f574ded..fc39d61 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,14 @@ -FROM python:3.10.8 +FROM python:3.10.8-alpine WORKDIR /usr/src/app -RUN apt-get update && \ - apt-get install -y git && \ - rm -rf /var/lib/apt/lists/* +RUN apk update \ +&& apk --no-cache --update add libffi-dev gcc musl-dev linux-headers python3-dev git make automake g++ subversion COPY . . RUN pip install --no-cache-dir -r requirements.txt -EXPOSE 8000 +EXPOSE 8080 CMD ["python", "bot/bot.py"] diff --git a/Makefile b/Makefile index 009fa84..25d8307 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,6 @@ .PHONY: run .PHONY: install .PHONY: test -.PHONY: terraform-fmt -.PHONY: pre-commit style: black . @@ -12,11 +10,5 @@ style: run: bash run.sh -terraform-fmt: - terraform fmt -recursive - -pre-commit: - pre-commit run --all - export: pip3 freeze > requirements.txt \ No newline at end of file diff --git a/example-files/terraform.tfvars.example b/example-files/terraform.tfvars.example deleted file mode 100644 index ff9a2e4..0000000 --- a/example-files/terraform.tfvars.example +++ /dev/null @@ -1,62 +0,0 @@ -railway_token = - -aws_profile = - -aws_region = - -enviorment_vars = { - "BOT_NAME" = - "BOT_PREFIX" = - "BOT_VERSION" = - "BOT_TOKEN" = - "DATABASE_URL" = - "APPLICATION_ID" = - "SENTRY_DSN" = - "MAIN_GUILD" = - "OWNERS" = - "SUPERUSERS" = - "ADMIN_ROLES" = - "GIPHY_API_KEY" = - "AWS_ACCESS_KEY" = - "AWS_SECRET_ACCESS_KEY" = - "AWS_REGION" = - "S3_BUCKET_NAME" = - "TWITCH_CLIENT_ID" = - "TWITCH_CLIENT_SECRET" = - "OPENAI_API_KEY" = - "TWIZY_API_KEY" = -} - -mongodbatlas_public_key = - -mongodbatlas_private_key = - -mongodb_region = - -database_user = - -database_password = - -mongodb_cluster_name = - -mongo_database_name = - -mongodb_project_id = - -mongo_auth_database_name = - -sentry_token = - -sentry_team_name = - -sentry_project_name = - -sentry_slug = - -sentry_organization = - -lh_bot_s3_bot_config_bucket = - -lh_bot_s3_terraform_state_bucket = - -lh_bot_reports_s3_bucket = \ No newline at end of file diff --git a/infrastructure/terraform/bot/.terraform.lock.hcl b/infrastructure/terraform/bot/.terraform.lock.hcl deleted file mode 100644 index 3782608..0000000 --- a/infrastructure/terraform/bot/.terraform.lock.hcl +++ /dev/null @@ -1,165 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/aws" { - version = "4.44.0" - constraints = "~> 4.42" - hashes = [ - "h1:IicMBt+WvFATiN4j/oaJYB4Kvk6LCxxpnokv2PXo1ag=", - "h1:fwOG8IE3AiHdUBo841jC2p4rIF45pWYettgBshcMyJI=", - "zh:08da139140530900ebb07baedd9044b5002f0296f5f160d96783e72080158326", - "zh:2d677b9e4f195481098cec843d0138f3a198f1f93be42c1d1654b71438e2f5ab", - "zh:3cdf4e06b9b8f30f6652a4519d586febc4ab92168a39df2610f06e04a8e6dda7", - "zh:677933957d1de40c8b5ae252c5cd369617af4cb7a26e8f750ad6f175fef4f767", - "zh:6a266ae5488d6daa53bbe6c2cb8368833381eacd9de7f05f059f5100535a0cb2", - "zh:6cdccaab0a444314b10246c8d58b0ffb84d32ddac70e36a12b45eb518e0ae065", - "zh:6ed49c7680298761416d408bc91cd137ae7cff38181fc143b1dfab1a32b44516", - "zh:8403a0fbf439009b3b0c77969c560cf426aeb3d99a78fdd27afbf4694ca0f3e7", - "zh:8ddfd85c6789bca7c66346da1f3488488c20bc4d773cd26669059c437cfbabd6", - "zh:941455d0fa54b0451387cfd611d63766f4b18cb24038f25ee0794097755e654d", - "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:bc01398c714d621ad9f4e81863446cd8e1135a63a5ff7c36d3fb01ab27e96439", - "zh:ce3b39a43b9c5b34a62047fe2a395b72a62cc0b5dc7e8a5be0f778159ac486d2", - "zh:d5891b82511af25570287578318aaee4fa86e05599cc8c81d44ea9e094f4a728", - "zh:df5329c186545d273f9abaeeb39251d6cfcc446bccc44e27d1d7d02ebf145e2f", - ] -} - -provider "registry.terraform.io/hashicorp/http" { - version = "3.2.1" - hashes = [ - "h1:DfxMa1zM/0NCFWN5PAxivSHJMNkOAFZvDYQkO72ZQmw=", - "h1:Q2YQZzEhHQVlkQCQVpMzFVs0Gg+eXzISbOwaOYqpflc=", - "zh:088b3b3128034485e11dff8da16e857d316fbefeaaf5bef24cceda34c6980641", - "zh:09ed1f2462ea4590b112e048c4af556f0b6eafc7cf2c75bb2ac21cd87ca59377", - "zh:39c6b0b4d3f0f65e783c467d3f634e2394820b8aef907fcc24493f21dcf73ca3", - "zh:47aab45327daecd33158a36c1a36004180a518bf1620cdd5cfc5e1fe77d5a86f", - "zh:4d70a990aa48116ab6f194eef393082c21cf58bece933b63575c63c1d2b66818", - "zh:65470c43fda950c7e9ac89417303c470146de984201fff6ef84299ea29e02d30", - "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", - "zh:842b4dd63e438f5cd5fdfba1c09b8fdf268e8766e6690988ee24e8b25bfd9e8d", - "zh:a167a057f7e2d80c78d4b4057538588131fceb983d5c93b07675ad9eb1aa5790", - "zh:d0ba69b62b6db788cfe3cf8f7dc6e9a0eabe2927dc119d7fe3fe6573ee559e66", - "zh:e28d24c1d5ff24b1d1cc6f0074a1f41a6974f473f4ff7a37e55c7b6dca68308a", - "zh:fde8a50554960e5366fd0e1ca330a7c1d24ae6bbb2888137a5c83d83ce14fd18", - ] -} - -provider "registry.terraform.io/heroku/heroku" { - version = "5.1.6" - constraints = "~> 5.1" - hashes = [ - "h1:6pmxW7Ol8E1M1Chls0AIEVGRj6m2RPsjqys2JmTxLzY=", - "h1:cAg6b2muSc4ThDGWrRhoOyoPMJE2pWqa2i77wjQGXVU=", - "zh:3790c0c0802baa60df779837be1e058251c5fb3eba3ff9f5b2ad5d274468193f", - "zh:3d1be4522dc3ecddb6d2f28fcbea17732c21b6ab8a43c4ad4e4022042d6d133a", - "zh:645dfce325977a10c1f9c2abc1ee1a19bc523056b41a9bf256ed3f9fd9105b61", - "zh:646c501316b58bd9e587ee30658684c9d4bc74a1209f74bab06c3db8ec81389e", - "zh:6be502b6b453b95a017fe9c168b63a66a289f5492b940e6e480e37386c664787", - "zh:7137995c833a222cab850ca6024e2e7632585da9e77315dd47572c6928d9307b", - "zh:729d0d715a7ce2cf35b3ba7a658a77d8c6877291797b5b78310505a055e5d8ee", - "zh:8677660ac5329b433e5c92d245bef59ec71ccb2a9b65bdd0cc06a266474fc974", - "zh:9538bce27b578c46647a10ddd47ae3f0e627fc86fec183255e237fe444d35f66", - "zh:99cfaae30ff22a526a8fe379d8bc466955cd1d5f4942e939b1d15aa5d20b199e", - "zh:a95f92731374a81967b066dc1788c18e1fe0c6bec1d3bae28d45b0f37c0462f4", - "zh:c6bf64a5ba75aea0b33be682bca167eec1bbe3643516bb866b481da2ababe671", - "zh:c967925823497269111cbb1f2dd348db94c3fb3d978c83cd0e0e91c29409a971", - "zh:e9e0f6b9eb2db3c13f5a1b8b7d0b48f52d7bd42430144601d9303e2b03f5bde0", - "zh:f3ddf070342998531f48f8fd827ba45cd52cca8541f02df8caf0f265773b507e", - "zh:fb7ab5fe3f41e1a5845c8abd1812104757cc0c8aa27cf5cd920555cffae0ea20", - ] -} - -provider "registry.terraform.io/integrations/github" { - version = "5.3.0" - constraints = "~> 5.3.0" - hashes = [ - "h1:DVgl7G+BOUt0tBLW3LwCuJh7FmliwG4Y+KiELX4gN9U=", - "h1:gkuLk40s4v+hfzRbVbDEByYUyg4HE22XDtCjACqYYTc=", - "h1:pFsKVGjnvAUu9Scqkk3W0EdjEXtgkTz2qxKYMMA/Bww=", - "zh:1ad22c2d5b02f16ff6281e471be93d9e33f102020e7d88b2a86fd97b7f2c3728", - "zh:1d3968417f7cd87678d505afd12d8d753e692dd90c6ba0f52e7b150c69649eaf", - "zh:1fd5c610488671e7685ebd9b4afaf6fb86f5540f4a9df03a6ef4d449aec761c2", - "zh:2d494a769e8c5f9ac1cbb115117d4eba8dccf1f5524264ee010d67d92c43a639", - "zh:53642cbb984f9cb7a1f5a4a2bab274d11690411c8e0fa58e9a521588c15f6fc1", - "zh:5a62005caf307169feb457a89f53530221b04cd18ffa6862109ef1cf19972ec6", - "zh:64cbffbc2cea25892defc75e53c01bd0d3f51537b892869101fad5109c9ba80e", - "zh:653ed9b6f8b81ad6c0dd7428ac1cd6a90608db44d12d92c3e68ffb2da7abda4b", - "zh:6e197a456605392c501b662006a7c175c32cadabebe93671f7dc1d8e8c3b635b", - "zh:7bc207b8363f404f8b40f90329b04eb480ba09e7581408d7158edc4282daa86d", - "zh:80504cbf6f7214949ac3a43d652c8e8bf8059446174f30338f106bcc5f7b3070", - "zh:c8d2d65d9d89cb34bd63e6b2f48774469b9f8862e364e92c4f64db33930b60fb", - "zh:e2a81619918d92e16c461ea5e68ffec1b2860d1e80742018690a325c3b5da5db", - "zh:f0077fbaee5580650c9e09cc558620194478406998b1c4e875f91016ea543fc4", - ] -} - -provider "registry.terraform.io/jianyuan/sentry" { - version = "0.10.0" - constraints = "~> 0.9" - hashes = [ - "h1:1KJnNreoVw0Y/swohxuvpEqbmqvDB8Ynz1pARZ3pBnE=", - "h1:Ijp/3fMi17gC7MuIlx1+EMUCTbd9cEyu6W66fh8J+hQ=", - "zh:0b98c58194bf607c26688aae7d8e5e22a0a513fa04d295b6246607d9525fb98d", - "zh:0fa82a384b25a58b65523e0ea4768fa1212b1f5cfc0c9379d31162454fedcc9d", - "zh:247e59373632e244bf425d89b66edfe22c8023af3e1ff2013c3add3f127a97a3", - "zh:4189548960ce1ec6186b155d6b1e9962890d8094b7d2becf290868f011368242", - "zh:490d75f9b03b13626e3cb767cb89b1aa1bdf0969a9829b9da0649065bb235ccd", - "zh:50d48eeccf0653c975e72674c45870687a89767372271c9b3600df7a4d6bbcf3", - "zh:50d91ad80752ca0eec5877c54c990bf3db4fe61b919644e30b0727d58086d9d8", - "zh:665b445282ef13d036bf1a2b425488438dc50fd6057d029eb603ae1912baa01d", - "zh:6ce0af6c1ba9da3f3ffe158c42fae603eb37cc72a536855253a869fcc4aeb9c9", - "zh:6d5a9e67cca1c9b0129d49f00ae2f5bdb90f2d4990ad45805f75fcf88573e6ea", - "zh:9903ec3ecda8312fc11e585ec2c362deb3d41cd8542a8d39eb381177d7a99b7f", - "zh:990590b58ebc038d908af25db620b4a9f781956f6cc48e47a54f9399412a5885", - "zh:a37118f509b320cdc0cfc95ba844ef1fb285ef2be6e0474af7d244c629a1d75e", - "zh:cb58d2c1247ab0aadb7d86f96205fd9e7a70b9941525aaf59a79da10f600f0bc", - "zh:f36c6c165a1067cd4ec6805fe6c36b5cf480b12a8d128e3c50ea243c1e0dbe20", - ] -} - -provider "registry.terraform.io/mongodb/mongodbatlas" { - version = "1.6.0" - constraints = "~> 1.6" - hashes = [ - "h1:5mRZcn95gML0qXMS8zqGcHRvYhpNggWIxmaAHXO8Q8c=", - "h1:A47VSveTxWRnOyztioExRAFGcmvoAy7WFkcwsL4Fa7Y=", - "zh:312cfc3c27aa0319618daaac24db3ac0608474f8281b7264187ee2df19c5771f", - "zh:36c6ae8b63651fee94e1c7ef114c8bb8ceb33694da05015d6e077b1721185954", - "zh:4d8439699f18b4968aafcc09b425b10505199c2c4c15b845d4abd61b84ea2566", - "zh:4e93df4454a7422f0e9be56cef73889488052726260ca62153a6db2d43b06d38", - "zh:597e3354711d00d5a64571bdc437532e529fc2310ae67f6d31aff0bac6417496", - "zh:7c9f9dfb44ca42bb61cd801447adac7dde08c34413dc74187f7daf1b2a2845e8", - "zh:997f40a66cd9ccf8dd63083ede93a3ea1b4fdac9eb79ceaea1c80dfed513dd1d", - "zh:b30265d6abd1c98dd710c575ff19a5a838cd6703926330f8a1d7162fe3ba5ccb", - "zh:c1bdf5a644a55b5ad608d191569f2bc2ccc3326b0a5bb4f82edfee71c0f5c488", - "zh:ced8421c565b15b7e533f0976e050b24d8c6f3950275fbd952bb318df3aa6678", - "zh:d4bf9f8208bb0aae4007f0346d5affcf953297ab6fbe7ea518a20d8b8557eae7", - "zh:d91fcd132e3002622369d24eb26a41e284f7e1f09d0733cbfc64f6ce646c64c5", - "zh:ecb99b27cdfc63e022a70fe7a45889bec41b372b59ddfd6cf2a3714718f5fb6a", - "zh:edfb66ca8f43b28aeef929e67965ae6d748227cc4fb907704235bcbd630ac913", - ] -} - -provider "registry.terraform.io/terraform-community-providers/railway" { - version = "0.2.0" - constraints = "0.2.0" - hashes = [ - "h1:U/VVVIWDS+t3xlXKaX/avgZ/70HxKMefo99c3koB6Og=", - "zh:0bffd3602bdf24052db7b04c41436c2632e3e913bc9bdfc97747cdfdab51a004", - "zh:248aaacf11bf150b2821a68b48c30d68cd4f5c87c853953ceee8119c28f80780", - "zh:2cac43f6db31f603f3c3200fc1aeb5173d87ef71861d558cdb5cbf4408047549", - "zh:2e4c88047bfd04e11563dcc8108976b94cd19aacaab323388d7046dc728cc85a", - "zh:65831d5be3589493fefe6bee3cc2fccd1df1312ad103fdea1abe8be34c92d093", - "zh:77b8ad8d7e50a0d7b4f5e4070b9f66807faa8b7615d74fea15951a421d2465ac", - "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", - "zh:91003519d701efd7cb307cfbc60cf6af518b4dcde6e5a613d44ffd9f45e77761", - "zh:91eded9b3385d44c4cd7cf08fd778570929059467378bd1d719e22365e47cdac", - "zh:971ef18b54b16647ba6209c8ea5478c821074e493a903021013efc413021c5bd", - "zh:9b72b99dcc4eb71f16f70d03ffb53eba90a01be89e3268b9de1da283be0e2229", - "zh:b9dfc27daf7bafbccf1802df20af325af7652ce97b85cba8b3ae85a1f528ea37", - "zh:bd4833532e90a9d40d2f30441d8fce513e8e1b75f2d4dbf9a5266c427c0e5303", - "zh:c6947701366df1ac2ee896f9ecbc28b09f12b5e1cf21a2ab2d365bf6f6a8bfbc", - "zh:f863927868270a620ee1138313bf078e185e7754c588798e3f1187d7648a002f", - ] -} diff --git a/infrastructure/terraform/bot/README.md b/infrastructure/terraform/bot/README.md deleted file mode 100644 index 3b31af9..0000000 --- a/infrastructure/terraform/bot/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# bot - - -## Requirements - -| Name | Version | -|------|---------| -| [terraform](#requirement\_terraform) | >= 1.0 | -| [aws](#requirement\_aws) | ~> 4.42 | -| [github](#requirement\_github) | ~> 5.3.0 | -| [mongodbatlas](#requirement\_mongodbatlas) | ~> 1.6 | -| [railway](#requirement\_railway) | 0.2.0 | -| [sentry](#requirement\_sentry) | ~> 0.9 | - -## Providers - -| Name | Version | -|------|---------| -| [aws](#provider\_aws) | 4.44.0 | -| [http](#provider\_http) | 3.2.1 | -| [mongodbatlas](#provider\_mongodbatlas) | 1.6.0 | -| [railway](#provider\_railway) | 0.2.0 | -| [sentry](#provider\_sentry) | 0.10.0 | - -## Modules - -No modules. - -## Resources - -| Name | Type | -|------|------| -| [aws_s3_bucket.lhbot_reports_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | -| [aws_s3_bucket.lhcloudy_bot_config](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | -| [aws_s3_bucket.terraform_state_lhbot](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | -| [aws_s3_bucket_policy.lhbot_bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | -| [aws_s3_bucket_public_access_block.lhbot_reports_bucket_public_access_block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | -| [aws_s3_bucket_public_access_block.lhcloudy_bot_config_public_access_block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | -| [aws_s3_bucket_public_access_block.terraform_state_lhbot_public_access_block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | -| [aws_s3_bucket_server_side_encryption_configuration.lhcloudy_bot_config_server_side_encryption](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource | -| [aws_s3_bucket_server_side_encryption_configuration.terraform_state_lhbot_server_side_encryption](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource | -| [mongodbatlas_cluster.lhcloudy_cluster](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/cluster) | resource | -| [mongodbatlas_database_user.lhcloudybot_db_user](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/database_user) | resource | -| [railway_custom_domain.lhbot_domain](https://registry.terraform.io/providers/terraform-community-providers/railway/0.2.0/docs/resources/custom_domain) | resource | -| [railway_deployment_trigger.lhbot_trigger](https://registry.terraform.io/providers/terraform-community-providers/railway/0.2.0/docs/resources/deployment_trigger) | resource | -| [railway_environment.lhbot_environment](https://registry.terraform.io/providers/terraform-community-providers/railway/0.2.0/docs/resources/environment) | resource | -| [railway_project.lhbot_project](https://registry.terraform.io/providers/terraform-community-providers/railway/0.2.0/docs/resources/project) | resource | -| [railway_service.lhbot_service](https://registry.terraform.io/providers/terraform-community-providers/railway/0.2.0/docs/resources/service) | resource | -| [railway_variable.lhbot_vars](https://registry.terraform.io/providers/terraform-community-providers/railway/0.2.0/docs/resources/variable) | resource | -| [sentry_project.sentry_lhcloudybot](https://registry.terraform.io/providers/jianyuan/sentry/latest/docs/resources/project) | resource | -| [aws_iam_policy_document.lhbot_bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | -| [http_http.github_tag](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [app\_name](#input\_app\_name) | The name of the Heroku app | `string` | n/a | yes | -| [app\_quantity](#input\_app\_quantity) | Number of dynos in your Heroku formation | `number` | `1` | no | -| [app\_region](#input\_app\_region) | The region to deploy the app to | `string` | n/a | yes | -| [aws\_profile](#input\_aws\_profile) | AWS profile to use | `string` | n/a | yes | -| [aws\_region](#input\_aws\_region) | AWS region to use | `string` | n/a | yes | -| [database\_password](#input\_database\_password) | Mongodb Atlas database password | `string` | n/a | yes | -| [database\_user](#input\_database\_user) | Mongodb Atlas database user | `string` | n/a | yes | -| [dyno\_size](#input\_dyno\_size) | Size of dyno | `string` | n/a | yes | -| [dyno\_type](#input\_dyno\_type) | Type of dyno | `string` | n/a | yes | -| [enviorment\_vars](#input\_enviorment\_vars) | Environment variables for the app | `map(string)` | n/a | yes | -| [heroku\_api\_key](#input\_heroku\_api\_key) | Heroku API Key | `string` | n/a | yes | -| [heroku\_email](#input\_heroku\_email) | Heroku account email | `string` | n/a | yes | -| [heroku\_stack](#input\_heroku\_stack) | Stack for your Heroku app | `string` | n/a | yes | -| [lh\_bot\_reports\_s3\_bucket](#input\_lh\_bot\_reports\_s3\_bucket) | S3 bucket for the reports | `string` | n/a | yes | -| [lh\_bot\_s3\_bot\_config\_bucket](#input\_lh\_bot\_s3\_bot\_config\_bucket) | S3 bucket for the bot config | `string` | n/a | yes | -| [lh\_bot\_s3\_terraform\_state\_bucket](#input\_lh\_bot\_s3\_terraform\_state\_bucket) | S3 bucket for the terraform state | `string` | n/a | yes | -| [mongo\_auth\_database\_name](#input\_mongo\_auth\_database\_name) | Mongodb Atlas auth database name | `string` | n/a | yes | -| [mongo\_database\_name](#input\_mongo\_database\_name) | Mongodb Atlas database name | `string` | n/a | yes | -| [mongodb\_cluster\_name](#input\_mongodb\_cluster\_name) | Mongodb Atlas cluster name | `string` | n/a | yes | -| [mongodb\_project\_id](#input\_mongodb\_project\_id) | Mongodb Atlas project ID | `string` | n/a | yes | -| [mongodb\_region](#input\_mongodb\_region) | Mongodb Atlas region | `string` | n/a | yes | -| [mongodbatlas\_private\_key](#input\_mongodbatlas\_private\_key) | Mongodb Atlas private key | `string` | n/a | yes | -| [mongodbatlas\_public\_key](#input\_mongodbatlas\_public\_key) | Mongodb Atlas public key | `string` | n/a | yes | -| [railway\_token](#input\_railway\_token) | Railway token | `string` | n/a | yes | -| [sentry\_organization](#input\_sentry\_organization) | Sentry organization | `string` | n/a | yes | -| [sentry\_project\_name](#input\_sentry\_project\_name) | Sentry project name | `string` | n/a | yes | -| [sentry\_slug](#input\_sentry\_slug) | Sentry slug | `string` | n/a | yes | -| [sentry\_team\_name](#input\_sentry\_team\_name) | Sentry team name | `string` | n/a | yes | -| [sentry\_token](#input\_sentry\_token) | Sentry token | `string` | n/a | yes | - -## Outputs - -| Name | Description | -|------|-------------| -| [database\_url](#output\_database\_url) | Database URL | - diff --git a/infrastructure/terraform/bot/data.tf b/infrastructure/terraform/bot/data.tf deleted file mode 100644 index 333e008..0000000 --- a/infrastructure/terraform/bot/data.tf +++ /dev/null @@ -1,7 +0,0 @@ -data "http" "github_tag" { - url = "https://api.github.com/repos/alexraskin/lhbot/tags" - - request_headers = { - Accept = "application/json" - } -} diff --git a/infrastructure/terraform/bot/main.tf b/infrastructure/terraform/bot/main.tf deleted file mode 100644 index 2622f48..0000000 --- a/infrastructure/terraform/bot/main.tf +++ /dev/null @@ -1,9 +0,0 @@ -terraform { - backend "s3" { - bucket = "terraform-state-lhbot" - key = "terraform.tfstate" - encrypt = true - region = "us-east-1" - profile = "default" - } -} diff --git a/infrastructure/terraform/bot/mongodb.tf b/infrastructure/terraform/bot/mongodb.tf deleted file mode 100644 index b93c8d3..0000000 --- a/infrastructure/terraform/bot/mongodb.tf +++ /dev/null @@ -1,39 +0,0 @@ -provider "mongodbatlas" { - public_key = var.mongodbatlas_public_key - private_key = var.mongodbatlas_private_key -} - -resource "mongodbatlas_cluster" "lhcloudy_cluster" { - project_id = var.mongodb_project_id - name = var.mongodb_cluster_name - - provider_name = "TENANT" - backing_provider_name = "AWS" - provider_region_name = "US_EAST_1" - provider_instance_size_name = "M0" - termination_protection_enabled = true - mongo_db_major_version = "6.0" -} - -resource "mongodbatlas_database_user" "lhcloudybot_db_user" { - username = var.database_user - password = var.database_password - project_id = var.mongodb_project_id - auth_database_name = var.mongo_auth_database_name - - roles { - role_name = "readWrite" - database_name = var.mongo_database_name - } - - labels { - key = "Terraform" - value = "true" - } - - scopes { - name = var.mongodb_cluster_name - type = "CLUSTER" - } - -} diff --git a/infrastructure/terraform/bot/outputs.tf b/infrastructure/terraform/bot/outputs.tf deleted file mode 100644 index f8133e7..0000000 --- a/infrastructure/terraform/bot/outputs.tf +++ /dev/null @@ -1,4 +0,0 @@ -output "database_url" { - value = "mongodb+srv://${var.database_user}:${var.database_password}@${split("//", mongodbatlas_cluster.lhcloudy_cluster.connection_strings.0.standard_srv)[1]}/${var.mongo_database_name}?retryWrites=true&w=majority" - description = "Database URL" -} diff --git a/infrastructure/terraform/bot/railway.tf b/infrastructure/terraform/bot/railway.tf deleted file mode 100644 index 6cbf3a4..0000000 --- a/infrastructure/terraform/bot/railway.tf +++ /dev/null @@ -1,40 +0,0 @@ -provider "railway" { - token = var.railway_token -} - -resource "railway_project" "lhbot_project" { - name = "LhBot-Discord" - description = "Discord Bot used in LhCloudys Discord" -} - -resource "railway_service" "lhbot_service" { - name = "LhBot" - project_id = railway_project.lhbot_project.id -} - -resource "railway_environment" "lhbot_environment" { - name = "production" - project_id = railway_project.lhbot_project.id -} - -resource "railway_custom_domain" "lhbot_domain" { - domain = "lhbot.twizy.dev" - environment_id = railway_environment.lhbot_environment.id - service_id = railway_service.lhbot_service.id -} - -resource "railway_deployment_trigger" "lhbot_trigger" { - repository = "alexraskin/lhbot" - branch = "main" - check_suites = false - environment_id = railway_environment.lhbot_environment.id - service_id = railway_service.lhbot_service.id -} - -resource "railway_variable" "lhbot_vars" { - for_each = var.enviorment_vars - name = each.key - value = each.value - environment_id = railway_environment.lhbot_environment.id - service_id = railway_service.lhbot_service.id -} diff --git a/infrastructure/terraform/bot/s3.tf b/infrastructure/terraform/bot/s3.tf deleted file mode 100644 index c32cd1c..0000000 --- a/infrastructure/terraform/bot/s3.tf +++ /dev/null @@ -1,99 +0,0 @@ -provider "aws" { - profile = var.aws_profile - region = var.aws_region - default_tags { - tags = { - env = "lhcloudybot" - terraform = "true" - github = "https://github.com/alexraskin/lhbot" - } - } -} - -resource "aws_s3_bucket" "lhcloudy_bot_config" { - bucket = var.lh_bot_s3_bot_config_bucket - tags = { - name = var.lh_bot_s3_bot_config_bucket - } -} - -resource "aws_s3_bucket_server_side_encryption_configuration" "lhcloudy_bot_config_server_side_encryption" { - bucket = aws_s3_bucket.lhcloudy_bot_config.bucket - - rule { - apply_server_side_encryption_by_default { - sse_algorithm = "AES256" - } - } -} - -resource "aws_s3_bucket_public_access_block" "lhcloudy_bot_config_public_access_block" { - bucket = aws_s3_bucket.lhcloudy_bot_config.id - - block_public_acls = true - block_public_policy = true -} - -resource "aws_s3_bucket" "terraform_state_lhbot" { - bucket = var.lh_bot_s3_terraform_state_bucket - tags = { - name = var.lh_bot_s3_terraform_state_bucket - } -} - -resource "aws_s3_bucket_server_side_encryption_configuration" "terraform_state_lhbot_server_side_encryption" { - bucket = aws_s3_bucket.terraform_state_lhbot.bucket - - rule { - apply_server_side_encryption_by_default { - sse_algorithm = "AES256" - } - } -} - -resource "aws_s3_bucket_public_access_block" "terraform_state_lhbot_public_access_block" { - bucket = aws_s3_bucket.terraform_state_lhbot.id - - block_public_acls = true - block_public_policy = true -} - -resource "aws_s3_bucket" "lhbot_reports_bucket" { - bucket = var.lh_bot_reports_s3_bucket - - tags = { - name = var.lh_bot_reports_s3_bucket - } -} - -resource "aws_s3_bucket_policy" "lhbot_bucket_policy" { - bucket = aws_s3_bucket.lhbot_reports_bucket.id - policy = data.aws_iam_policy_document.lhbot_bucket_policy.json -} - -resource "aws_s3_bucket_public_access_block" "lhbot_reports_bucket_public_access_block" { - bucket = aws_s3_bucket.lhbot_reports_bucket.id - - block_public_acls = false - block_public_policy = false -} - - -data "aws_iam_policy_document" "lhbot_bucket_policy" { - statement { - principals { - type = "Service" - identifiers = ["s3.amazonaws.com"] - } - effect = "Allow" - actions = [ - "s3:PutObject", - "s3:PutObjectAcl", - "s3:GetObject", - "s3:GetObjectAcl", - "s3:DeleteObject" - ] - resources = ["arn:aws:s3:::lhbot", - "arn:aws:s3:::lhbot/*"] - } -} \ No newline at end of file diff --git a/infrastructure/terraform/bot/sentry.tf b/infrastructure/terraform/bot/sentry.tf deleted file mode 100644 index 1c767a5..0000000 --- a/infrastructure/terraform/bot/sentry.tf +++ /dev/null @@ -1,16 +0,0 @@ -provider "sentry" { - token = var.sentry_token -} - -resource "sentry_project" "sentry_lhcloudybot" { - organization = var.sentry_organization - - teams = [ - var.sentry_team_name, - ] - name = var.sentry_project_name - slug = var.sentry_slug - - platform = "python" - resolve_age = 720 -} diff --git a/infrastructure/terraform/bot/shared-envs.tf b/infrastructure/terraform/bot/shared-envs.tf deleted file mode 100644 index 8da6a85..0000000 --- a/infrastructure/terraform/bot/shared-envs.tf +++ /dev/null @@ -1,23 +0,0 @@ -locals { - enviorment_vars = { - DATABASE_URL = var.enviorment_vars["DATABASE_URL"] - BOT_PREFIX = var.enviorment_vars["BOT_PREFIX"] - BOT_TOKEN = var.enviorment_vars["BOT_TOKEN"] - BOT_VERSION = var.enviorment_vars["BOT_VERSION"] - APPLICATION_ID = var.enviorment_vars["APPLICATION_ID"] - SENTRY_DSN = var.enviorment_vars["SENTRY_DSN"] - MAIN_GUILD = var.enviorment_vars["MAIN_GUILD"] - OWNERS = var.enviorment_vars["OWNERS"] - SUPERUSERS = var.enviorment_vars["SUPERUSERS"] - ADMIN_ROLES = var.enviorment_vars["ADMIN_ROLES"] - GIPHY_API_KEY = var.enviorment_vars["GIPHY_API_KEY"] - BOT_NAME = var.enviorment_vars["BOT_NAME"] - AWS_ACCESS_KEY_ID = var.enviorment_vars["AWS_ACCESS_KEY"] - AWS_SECRET_KEY_ID = var.enviorment_vars["AWS_SECRET_ACCESS_KEY"] - AWS_REGION = var.enviorment_vars["AWS_REGION"] - S3_BUCKET_NAME = var.enviorment_vars["S3_BUCKET_NAME"] - TWITCH_CLIENT_ID = var.enviorment_vars["TWITCH_CLIENT_ID"] - TWITCH_CLIENT_SECRET = var.enviorment_vars["TWITCH_CLIENT_SECRET"] - OPENAI_API_KEY = var.enviorment_vars["OPENAI_API_KEY"] - } -} diff --git a/infrastructure/terraform/bot/variables.tf b/infrastructure/terraform/bot/variables.tf deleted file mode 100644 index 37fc670..0000000 --- a/infrastructure/terraform/bot/variables.tf +++ /dev/null @@ -1,144 +0,0 @@ -variable "railway_token" { - type = string - description = "Railway token" -} - -variable "aws_profile" { - description = "AWS profile to use" - type = string -} - -variable "aws_region" { - description = "AWS region to use" - type = string -} - -variable "app_name" { - type = string - description = "The name of the Heroku app" -} - -variable "heroku_email" { - type = string - description = "Heroku account email" -} - -variable "heroku_api_key" { - type = string - description = "Heroku API Key" -} - -variable "heroku_stack" { - type = string - description = "Stack for your Heroku app" -} - -variable "dyno_type" { - type = string - description = "Type of dyno" -} - -variable "dyno_size" { - type = string - description = "Size of dyno" -} - -variable "app_region" { - type = string - description = "The region to deploy the app to" -} - -variable "app_quantity" { - default = 1 - description = "Number of dynos in your Heroku formation" -} - -variable "enviorment_vars" { - type = map(string) - description = "Environment variables for the app" -} - -variable "mongodb_cluster_name" { - type = string - description = "Mongodb Atlas cluster name" -} - -variable "mongodb_region" { - type = string - description = "Mongodb Atlas region" -} - -variable "database_user" { - type = string - description = "Mongodb Atlas database user" -} - -variable "database_password" { - type = string - description = "Mongodb Atlas database password" -} - -variable "mongodb_project_id" { - type = string - description = "Mongodb Atlas project ID" -} - -variable "mongo_database_name" { - type = string - description = "Mongodb Atlas database name" -} - -variable "mongodbatlas_private_key" { - type = string - description = "Mongodb Atlas private key" -} - -variable "mongodbatlas_public_key" { - type = string - description = "Mongodb Atlas public key" -} - -variable "mongo_auth_database_name" { - type = string - description = "Mongodb Atlas auth database name" -} - -variable "sentry_token" { - type = string - description = "Sentry token" -} - -variable "sentry_team_name" { - type = string - description = "Sentry team name" -} - -variable "sentry_project_name" { - type = string - description = "Sentry project name" -} - -variable "sentry_slug" { - type = string - description = "Sentry slug" -} - -variable "sentry_organization" { - type = string - description = "Sentry organization" -} - -variable "lh_bot_s3_bot_config_bucket" { - type = string - description = "S3 bucket for the bot config" -} - -variable "lh_bot_s3_terraform_state_bucket" { - type = string - description = "S3 bucket for the terraform state" -} - -variable "lh_bot_reports_s3_bucket" { - type = string - description = "S3 bucket for the reports" -} diff --git a/infrastructure/terraform/bot/versions.tf b/infrastructure/terraform/bot/versions.tf deleted file mode 100644 index ae06e7e..0000000 --- a/infrastructure/terraform/bot/versions.tf +++ /dev/null @@ -1,25 +0,0 @@ -terraform { - required_providers { - mongodbatlas = { - source = "mongodb/mongodbatlas" - version = "~> 1.6" - } - sentry = { - source = "jianyuan/sentry" - version = "~> 0.9" - } - aws = { - source = "hashicorp/aws" - version = "~> 4.42" - } - github = { - source = "integrations/github" - version = "~> 5.3.0" - } - railway = { - source = "terraform-community-providers/railway" - version = "0.2.0" - } - } - required_version = ">= 1.0" -} diff --git a/runtime.txt b/runtime.txt deleted file mode 100644 index 2fef004..0000000 --- a/runtime.txt +++ /dev/null @@ -1 +0,0 @@ -python-3.10.8 \ No newline at end of file