File tree Expand file tree Collapse file tree 4 files changed +68
-6
lines changed Expand file tree Collapse file tree 4 files changed +68
-6
lines changed Original file line number Diff line number Diff line change @@ -18,19 +18,19 @@ permissions:
18
18
jobs :
19
19
main :
20
20
name : " Main"
21
- uses : osinfra-io/github-opentofu-gcp-called-workflows/.github/workflows/plan-and-apply.yml@367d86eecaab18bb7fae7f5fa17fe7001df13f16
21
+ uses : osinfra-io/github-opentofu-gcp-called-workflows/.github/workflows/plan-and-apply.yml@e3c59e43f2458550c7f13b6369fb6978b6f42c6e # v0.2.9
22
22
if : github.actor != 'osinfra-sa'
23
23
with :
24
24
checkout_ref : ${{ github.ref }}
25
25
github_environment : " Production: Main"
26
26
service_account : plt-dd-organization-github@plt-lz-backend-tf5f-prod.iam.gserviceaccount.com
27
+ opentofu_kms_encryption_key : projects/plt-lz-backend-tf5f-prod/locations/us/keyRings/state-encryption/cryptoKeys/default
27
28
opentofu_plan_args : -var-file=tfvars/production.tfvars
28
29
opentofu_state_bucket : plt-dd-organization-d3c2-prod
29
30
opentofu_version : ${{ vars.OPENTOFU_VERSION }}
30
31
opentofu_workspace : main-production
31
32
workload_identity_provider : projects/134040294660/locations/global/workloadIdentityPools/github-actions/providers/github-actions-oidc
32
33
secrets :
33
- gpg_passphrase : ${{ secrets.GPG_PASSPHRASE }}
34
34
opentofu_plan_secret_args : >-
35
35
-var=datadog_api_key=${{ secrets.DATADOG_API_KEY }}
36
36
-var=datadog_app_key=${{ secrets.DATADOG_APP_KEY }}
Original file line number Diff line number Diff line change 1
1
# Backend Configuration
2
- # https://www.terraform.io /language/settings/backends/configuration
2
+ # https://opentofu.org/docs /language/settings/backends/configuration
3
3
4
4
terraform {
5
-
6
5
# Google Cloud Storage
7
- # https://www.terraform.io /language/settings/backends/gcs
6
+ # https://opentofu.org/docs /language/settings/backends/gcs
8
7
9
8
backend "gcs" {
10
- prefix = "datadog-organization-management"
9
+ bucket = var.state_bucket
10
+ kms_encryption_key = var.state_kms_encryption_key
11
+ prefix = var.state_prefix
11
12
}
12
13
}
Original file line number Diff line number Diff line change 2
2
# https://registry.terraform.io/providers/DataDog/datadog/latest/docs
3
3
4
4
terraform {
5
+ # State and Plan Encryption
6
+ # https://opentofu.org/docs/language/state/encryption
7
+
8
+ # The commented out sections below demonstrate how to configure
9
+ # fallback encryption methods for state and plan files for bootstrapping.
10
+
11
+ encryption {
12
+ method "unencrypted" "migrate" {}
13
+
14
+ key_provider "gcp_kms" "default" {
15
+ kms_encryption_key = var.state_kms_encryption_key
16
+ key_length = 32
17
+ }
18
+
19
+ method "aes_gcm" "default" {
20
+ keys = key_provider.gcp_kms.default
21
+ }
22
+
23
+ plan {
24
+ method = method.aes_gcm.default
25
+ # enforced = true
26
+
27
+ fallback {
28
+ method = method.unencrypted.migrate
29
+ }
30
+ }
31
+
32
+ state {
33
+ method = method.aes_gcm.default
34
+ # enforced = true
35
+
36
+ fallback {
37
+ method = method.unencrypted.migrate
38
+ }
39
+ }
40
+ }
41
+
5
42
required_providers {
6
43
datadog = {
7
44
source = "datadog/datadog"
@@ -162,3 +199,9 @@ resource "datadog_user" "this" {
162
199
name = each.value.name
163
200
roles = [data.datadog_role.this[each.value.role].id]
164
201
}
202
+
203
+ resource "null_resource" "force_apply" {
204
+ triggers = {
205
+ always_run = timestamp()
206
+ }
207
+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,24 @@ variable "log_indexes" {
29
29
}))
30
30
}
31
31
32
+ # These three state_* variables are required for early variable evaluation for backend and provider configuration.
33
+ # They are defined in the GitHub Actions called workflows and should NOT be set in the OpenTofu configuration.
34
+
35
+ variable "state_bucket" {
36
+ description = "The name of the GCS bucket to store state files"
37
+ type = string
38
+ }
39
+
40
+ variable "state_kms_encryption_key" {
41
+ description = "The KMS encryption key for state and plan files"
42
+ type = string
43
+ }
44
+
45
+ variable "state_prefix" {
46
+ description = "The prefix for state files in the GCS bucket"
47
+ type = string
48
+ }
49
+
32
50
variable "teams" {
33
51
description = "Map of Datadog teams to create"
34
52
type = map(object({
You can’t perform that action at this time.
0 commit comments