Skip to content

Commit 80fb117

Browse files
authored
feat: allow backend role arn to init (AIR-1495) (#48)
## what - Allow a backend role arn to be used during `init` ## why - We've had interest in using a backend role for local tf operations, as an alternative to defining an `assume_role` within backend config or relying on ambient credentials. ## references - [AIR-1495](https://www.notion.so/masterpoint/Ensure-mp-infra-demonstrates-read-only-vs-write-role-separation-for-Spacelift-backend-access-as-refe-342859758a56816a8d9cd9080ed989e8) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Backend role ARN configuration is now supported through environment variables during initialization, providing greater flexibility for infrastructure deployments. This enhancement streamlines multi-environment setup workflows and eliminates the need for code modifications when managing backend configurations. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 953d140 commit 80fb117

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/tf/Taskfile.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ tasks:
2525
sh: echo "{{.TFVARS_PATH}}/{{.WORKSPACE}}.tfvars"
2626
TF_CMD:
2727
sh: '[ "${USE_TERRAFORM}" = "true" ] && echo "terraform" || echo "tofu"'
28+
TF_BACKEND_ROLE_ARN:
29+
sh: echo "${TF_BACKEND_ROLE_ARN:-}"
2830

2931
init:
3032
desc: Initialize Terraform or OpenTofu working directory.
@@ -37,7 +39,7 @@ tasks:
3739
silent: true
3840
vars: *vars
3941
cmds:
40-
- "{{.TF_CMD}} init {{.TF_ARGS}}"
42+
- '{{.TF_CMD}} init {{if .TF_BACKEND_ROLE_ARN}}-backend-config="role_arn={{.TF_BACKEND_ROLE_ARN}}" {{end}}{{.TF_ARGS}}'
4143

4244
plan:
4345
desc: Generate a Terraform or OpenTofu execution plan, loading variable values from the given file.

0 commit comments

Comments
 (0)