Skip to content

Commit e3c59e4

Browse files
authored
Update environment variables for OpenTofu state management and enhance documentation on encryption requirements (#190)
1 parent 1c86a06 commit e3c59e4

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

.github/workflows/plan-and-apply.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ permissions:
5151
env:
5252
# Early variable evaluation required for backend and provider configuration
5353

54-
TF_VAR_kms_encryption_key: ${{ inputs.opentofu_kms_encryption_key }}
5554
TF_VAR_state_bucket: ${{ inputs.opentofu_state_bucket }}
55+
TF_VAR_state_kms_encryption_key: ${{ inputs.opentofu_kms_encryption_key }}
5656
TF_VAR_state_prefix: ${{ github.event.repository.name }}
5757

5858
# If you use private modules you'll need this env variable to use

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Rather than copying and pasting from one workflow to another, you can make workf
2020
- [Dependencies cache](https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows)
2121
- [Job summaries](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary)
2222
- [OpenID connect in Google Cloud Platform](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-google-cloud-platform)
23+
- [OpenTofu state and plan encryption](https://opentofu.org/docs/language/state/encryption)
2324

2425
### Workflows
2526

@@ -36,3 +37,25 @@ You can check the [.github/workflows](.github/workflows/) directory for example
3637
- [module-test.yml](.github/workflows/module-test.yml)
3738

3839
These set up the system for the testing process by providing all the necessary initial code, thus creating good examples to base your configuration on.
40+
41+
Since we use early variable evaluation for backend and provider configuration, consumers must ensure that the following variables are set in each respective `variables.tofu` file:
42+
43+
```hcl
44+
# These three state_* variables are required for early variable evaluation for backend and provider configuration.
45+
# They are defined in the GitHub Actions called workflows and should NOT be set in the OpenTofu configuration.
46+
47+
variable "state_bucket" {
48+
description = "The name of the GCS bucket to store state files"
49+
type = string
50+
}
51+
52+
variable "state_kms_encryption_key" {
53+
description = "The KMS encryption key for state and plan files"
54+
type = string
55+
}
56+
57+
variable "state_prefix" {
58+
description = "The prefix for state files in the GCS bucket"
59+
type = string
60+
}
61+
```

0 commit comments

Comments
 (0)