Skip to content

Commit 86ed633

Browse files
committed
Switch to S3 terraform backend
1 parent 98c8c3d commit 86ed633

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

.github/workflows/terraform-github.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ name: Terraform GitHub
1414
workflow_dispatch:
1515
env:
1616
TF_VAR_GITHUB_APP_PEM_FILE: ${{ secrets.TF_VAR_GITHUB_APP_PEM_FILE }}
17+
AWS_ACCESS_KEY_ID: ${{ secrets.TF_S3_ACCESS_KEY_ID }}
18+
AWS_SECRET_ACCESS_KEY: ${{ secrets.TF_S3_SECRET_ACCESS_KEY }}
1719
jobs:
1820
terraform:
1921
name: Terraform
@@ -25,8 +27,6 @@ jobs:
2527
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2628

2729
- uses: hashicorp/setup-terraform@5e8dbf3c6d9deaf4193ca7a8fb23f2ac83bb6c85 # v4.0.0
28-
with:
29-
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
3030

3131
- name: Terraform fmt
3232
id: fmt

terraform/github/provider.tf

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@ terraform {
55
version = "6.11.1"
66
}
77
}
8-
cloud {
9-
organization = "stackhpc"
108

11-
workspaces {
12-
name = "github"
9+
backend "s3" {
10+
bucket = "github-terraform-backend"
11+
key = "github/terraform.tfstate"
12+
region = "auto" # Cloudflare R2 uses "auto" for the region
13+
use_lockfile = true
14+
15+
endpoints = {
16+
s3 = "https://99e8d2e95b14ef888ce364a5ab310629.r2.cloudflarestorage.com"
1317
}
18+
19+
# Bypasses strict AWS checks so the S3-compatible API works
20+
skip_credentials_validation = true
21+
skip_region_validation = true
22+
skip_requesting_account_id = true
23+
skip_metadata_api_check = true
24+
skip_s3_checksum = true
1425
}
1526
}
1627

0 commit comments

Comments
 (0)