From 6b37ba13c98a42b4d23455e16c5e2c2f5dce6442 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 24 Mar 2024 14:36:23 -0400 Subject: [PATCH] tf init with definition in main --- .github/workflows/arrow.yml | 13 ++----------- hosts/arrow/main.tf | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/arrow.yml b/.github/workflows/arrow.yml index c32d3ec..6b61777 100644 --- a/.github/workflows/arrow.yml +++ b/.github/workflows/arrow.yml @@ -7,8 +7,8 @@ env: CLOUDFLARE_R2_ENDPOINT: "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com" AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_KEY }} + AWS_ENDPOINT_URL_S3: "https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com" TF_VAR_vultr_api_key: ${{ secrets.VULTR_API_KEY }} - TF_VAR_cloudflare_r2_endpoint: "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com" on: workflow_dispatch: @@ -82,16 +82,7 @@ jobs: # Connects to remote state backend and download providers. - name: Terraform Init working-directory: ${{ env.TERRAFORM_DIRECTORY }} - run: | - terraform init \ - -backend-config="endpoint=${{ env.CLOUDFLARE_R2_ENDPOINT }}" \ - -backend-config="workspace_key_prefix=${{ github.repository }}/arrow" \ - -backend-config="key=state.tfstate" \ - -backend-config="skip_credentials_validation=true" \ - -backend-config="skip_region_validation=true" \ - -backend-config="skip_requesting_account_id=true" \ - -backend-config="region=anything" \ - -backend-config="bucket=noahmasur-terraform" + run: terraform init # Deploys infrastructure or changes to infrastructure. - name: Terraform Apply diff --git a/hosts/arrow/main.tf b/hosts/arrow/main.tf index 56148a6..5eed978 100644 --- a/hosts/arrow/main.tf +++ b/hosts/arrow/main.tf @@ -1,5 +1,22 @@ terraform { - backend "s3" {} + backend "s3" { + bucket = "noahmasur-terraform" + key = "arrow.tfstate" + region = "auto" + skip_credentials_validation = true + skip_metadata_api_check = true + skip_region_validation = true + skip_requesting_account_id = true + skip_s3_checksum = true + use_path_style = true + /* + ENVIRONMENT VARIABLES + --------------------- + AWS_ACCESS_KEY_ID - R2 token + AWS_SECRET_ACCESS_KEY - R2 secret + AWS_ENDPOINT_URL_S3 - R2 location: https://ACCOUNT_ID.r2.cloudflarestorage.com + */ + } required_version = ">= 1.0.0" required_providers { aws = {