From 26f489ecc094e91291cc17f15ea2382318526b1d Mon Sep 17 00:00:00 2001 From: developomp Date: Mon, 15 Apr 2024 20:19:51 +0900 Subject: [PATCH] chore: migrate from terraform to opentofu --- .../workflows/{terraform.yml => opentofu.yml} | 14 ++++---- .terraform.lock.hcl | 33 ++++++++----------- .vscode/extensions.json | 2 +- .vscode/settings.json | 4 +++ CONTRIBUTING.md | 11 ++++++- package.json | 2 +- 6 files changed, 36 insertions(+), 30 deletions(-) rename .github/workflows/{terraform.yml => opentofu.yml} (65%) diff --git a/.github/workflows/terraform.yml b/.github/workflows/opentofu.yml similarity index 65% rename from .github/workflows/terraform.yml rename to .github/workflows/opentofu.yml index df2ebbd..55bfb02 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/opentofu.yml @@ -19,10 +19,8 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 - - name: Setup Terraform - uses: hashicorp/setup-terraform@v2 - with: - cli_config_credentials_token: ${{ secrets.TERRAFORM_TOKEN }} + - name: Setup OpenTofu + uses: opentofu/setup-opentofu@v1 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 @@ -31,7 +29,7 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-west-1 # just a random region (also used in main.tf) - - run: terraform init - - run: terraform fmt -check - - run: terraform plan -input=false - - run: terraform apply -auto-approve -input=false + - run: tofu init + - run: tofu fmt -check + - run: tofu plan -input=false + - run: tofu apply -auto-approve -input=false diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl index 7be38b4..700a2d8 100644 --- a/.terraform.lock.hcl +++ b/.terraform.lock.hcl @@ -1,25 +1,20 @@ -# This file is maintained automatically by "terraform init". +# This file is maintained automatically by "tofu init". # Manual edits may be lost in future updates. -provider "registry.terraform.io/hashicorp/aws" { - version = "5.17.0" +provider "registry.opentofu.org/hashicorp/aws" { + version = "5.45.0" constraints = "~> 5.0" hashes = [ - "h1:U+EDfeUqefebA1h7KyBMD1xH0h311LMi7wijPDPkC/0=", - "zh:0087b9dd2c9c638fd63e527e5b9b70988008e263d480a199f180efe5a4f070f0", - "zh:0fd532a4fd03ddef11f0502ff9fe4343443e1ae805cb088825a71d6d48906ec7", - "zh:16411e731100cd15f7e165f53c23be784b2c86c2fcfd34781e0642d17090d342", - "zh:251d520927e77f091e2ec6302e921d839a2430ac541c6a461aed7c08fb5eae12", - "zh:4919e69682dc2a8c32d44f6ebc038a52c9f40af9c61cb574b64e322800d6a794", - "zh:5334c60759d5f76bdc51355d1a3ebcc451d4d20f632f5c73b6e55c52b5dc9e52", - "zh:7341a2b7247572eba0d0486094a870b872967702ec0ac7af728c2df2c30af4e5", - "zh:81d1b1cb2cac6b3922a05adab69543b678f344a01debd54500263700dad7a288", - "zh:882bc8e15ef6d4020a07321ec4c056977c5c1d96934118032922561d29504d43", - "zh:8cd4871ef2b03fd916de1a6dc7eb8a81a354c421177d4334a2e3308e50215e41", - "zh:97e12fe6529b21298adf1046c5e20ac35d0569c836a6f385ff041e257e00cfd2", - "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:9f5baf5d59b9f3cf5504d1fa975f10f27da3791896a9e18ece47c258bac17634", - "zh:dffafba6731ac1db1c540bdbd6a8c878486b71de9d0ca1d23c5c00a6c3c14d80", - "zh:fa7440c3c15a42fc5731444d324ced75407d417bfe3184661ae47d40a9718dce", + "h1:A8MJa+VwONA4BNO5xzeleguJbrblNLnXBImHTK/qgFg=", + "zh:1d71c406aeaf4ba762eb62e4595ab9c9f8da1a2c9b74bb4277c0acfd9678ae65", + "zh:3b00b13154eadedb37bca99bf7cbd556fa9472e6900c970effa17a270ee9f721", + "zh:6f264e8b70153925ac8abfa83ebffe2c2d5a27ab5557a6b16124269b08ac2441", + "zh:80f7d552faf5c43d7dc22c6c1f7e70557b9f01c67db07abbb0330d5d3fc0e464", + "zh:863a2a2e6ae5b42fc46b209d8f2761c882d46aca481a8c49ef221d290b4fd88e", + "zh:8e3bddeb2da7e6bcfd0b0221a083778d2f7fc5cd64f55de7d8d79bd1f7378bae", + "zh:c726104e46cd743bbf240101d7975f44091d893b6e97b46070df0041779b04d2", + "zh:db73a89b462fdd6eb6f32e6ed464430a895fc2e54fb629e8b99773fc32a6a7a8", + "zh:e35179b89eba358f521ffd4546345b4d0683ca3364a9deb8f3b7b4bf60be6f02", + "zh:e7b54a0faecd34a9c73729d1d1f0cfc1b8f56bae789f95987002616f1265ce72", ] } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d1763c1..2c83a4e 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -10,7 +10,7 @@ "svelte.svelte-vscode", "redhat.vscode-xml", "github.vscode-github-actions", - "4ops.terraform", + "gamunu.opentofu", "foxundermoon.shell-format" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 3f47d5c..19f5838 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -48,6 +48,7 @@ "nojs", "noopener", "noto", + "opentofu", "planetscale", "pnpm", "pocketbase", @@ -115,5 +116,8 @@ }, "[ignore]": { "editor.defaultFormatter": "foxundermoon.shell-format" + }, + "[terraform]": { + "editor.defaultFormatter": "gamunu.opentofu" } } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5285b35..cdcebcf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,6 @@ 2. Install the following - [NodeJS](https://nodejs.org) - [pnpm](https://pnpm.io/installation) - - [terraform CLI](https://developer.hashicorp.com/terraform/downloads) 3. Install Dependencies ``` pnpm install @@ -41,6 +40,16 @@ - `pnpm lint` - Lint all apps and packages - `pnpm clean` - Remove all auto-generated content such as `node_modules` and `dist`. +## Setting up for deployment + +1. Install the following + - [terraform CLI](https://developer.hashicorp.com/terraform/downloads) + - [AWS CLI](https://aws.amazon.com/cli) +2. Setup AWS credentials + ``` + aws configure + ``` + ## Testing 1. Build site diff --git a/package.json b/package.json index 2111315..176b4fc 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test:unit": "turbo run test:unit --parallel --continue", "test:e2e": "turbo run test:e2e --parallel --continue", "lint": "turbo run lint", - "clean": "turbo run clean && rm -rf node_modules" + "clean": "turbo run clean && rm -rf node_modules .turbo .terraform terraform.tfstate" }, "devDependencies": { "@commitlint/cli": "^18.4.3",