tf init with definition in main

This commit is contained in:
Noah Masur 2024-03-24 14:36:23 -04:00
parent efac745bdd
commit 6b37ba13c9
2 changed files with 20 additions and 12 deletions

View File

@ -7,8 +7,8 @@ env:
CLOUDFLARE_R2_ENDPOINT: "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com" CLOUDFLARE_R2_ENDPOINT: "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com"
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY }} AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_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_vultr_api_key: ${{ secrets.VULTR_API_KEY }}
TF_VAR_cloudflare_r2_endpoint: "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com"
on: on:
workflow_dispatch: workflow_dispatch:
@ -82,16 +82,7 @@ jobs:
# Connects to remote state backend and download providers. # Connects to remote state backend and download providers.
- name: Terraform Init - name: Terraform Init
working-directory: ${{ env.TERRAFORM_DIRECTORY }} working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: | run: terraform init
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"
# Deploys infrastructure or changes to infrastructure. # Deploys infrastructure or changes to infrastructure.
- name: Terraform Apply - name: Terraform Apply

View File

@ -1,5 +1,22 @@
terraform { 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_version = ">= 1.0.0"
required_providers { required_providers {
aws = { aws = {