Skip to content

Commit 019faa2

Browse files
bradeglerverbanicm
authored andcommitted
feat: added provider file locking (#17)
Marking the file readonly which will cause terraform init to fail if new providers are added
1 parent f37a913 commit 019faa2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

.github/actions/secure-setup-terraform/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ inputs:
1919
description: 'The terraform version to install'
2020
default: '1.3.3'
2121
required: false
22+
terraform_lockfile_location:
23+
description: 'Path to the directory containing the .terraform.lock.hcl file. This action will mark this file readonly to prevent terraform init calls from adding new providers.'
24+
required: true
2225

2326
runs:
2427
using: 'composite'
@@ -56,5 +59,8 @@ runs:
5659
CHECKSUM=$(jq -r --arg version ${{ inputs.terraform_version }} '.versions[] | select(.version==$version and .arch=="amd64" and .os=="linux") | .binary_checksum' < terraform-checksums.json)
5760
echo "${CHECKSUM} $(which terraform)" > terraform.sha256
5861
shasum --algorithm 256 --check terraform.sha256
62+
- name: 'lock-provider-file'
63+
shell: 'bash'
64+
run: 'chmod 444 ${{ inputs.terraform_lockfile_location }}/.terraform.lock.hcl'
5965

6066

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
uses: 'abcxyz/[email protected]'
3838
with:
3939
terraform_version: '1.3.3'
40+
terraform_lockfile_location: './terraform/modules'
4041
## Use terraform normally
4142
```
4243

0 commit comments

Comments
 (0)