-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
252 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,15 @@ The secret replication policy is automatically managed if no location is set, or | |
```hcl | ||
module "secret-manager" { | ||
source = "./fabric/modules/secret-manager" | ||
project_id = "my-project" | ||
project_id = var.project_id | ||
secrets = { | ||
test-auto = {} | ||
test-manual = { | ||
locations = ["europe-west1", "europe-west4"] | ||
locations = [var.regions.primary, var.regions.secondary] | ||
} | ||
} | ||
} | ||
# tftest modules=1 resources=2 | ||
# tftest modules=1 resources=2 inventory=secret.yaml e2e | ||
``` | ||
|
||
### Secret IAM bindings | ||
|
@@ -33,23 +33,23 @@ IAM bindings can be set per secret in the same way as for most other modules sup | |
```hcl | ||
module "secret-manager" { | ||
source = "./fabric/modules/secret-manager" | ||
project_id = "my-project" | ||
project_id = var.project_id | ||
secrets = { | ||
test-auto = {} | ||
test-manual = { | ||
locations = ["europe-west1", "europe-west4"] | ||
locations = [var.regions.primary, var.regions.secondary] | ||
} | ||
} | ||
iam = { | ||
test-auto = { | ||
"roles/secretmanager.secretAccessor" = ["group:[email protected]"] | ||
"roles/secretmanager.secretAccessor" = ["group:${var.group_email}"] | ||
} | ||
test-manual = { | ||
"roles/secretmanager.secretAccessor" = ["group:[email protected]"] | ||
"roles/secretmanager.secretAccessor" = ["group:${var.group_email}"] | ||
} | ||
} | ||
} | ||
# tftest modules=1 resources=4 inventory=iam.yaml | ||
# tftest modules=1 resources=4 inventory=iam.yaml e2e | ||
``` | ||
|
||
### Secret versions | ||
|
@@ -59,11 +59,11 @@ As mentioned above, please be aware that **version data will be stored in state | |
```hcl | ||
module "secret-manager" { | ||
source = "./fabric/modules/secret-manager" | ||
project_id = "my-project" | ||
project_id = var.project_id | ||
secrets = { | ||
test-auto = {} | ||
test-manual = { | ||
locations = ["europe-west1", "europe-west4"] | ||
locations = [var.regions.primary, var.regions.secondary] | ||
} | ||
} | ||
versions = { | ||
|
@@ -76,7 +76,7 @@ module "secret-manager" { | |
} | ||
} | ||
} | ||
# tftest modules=1 resources=5 inventory=versions.yaml | ||
# tftest modules=1 resources=5 inventory=versions.yaml e2e | ||
``` | ||
|
||
### Secret with customer managed encryption key | ||
|
@@ -86,24 +86,24 @@ CMEK will be used if an encryption key is set in the `keys` field of `secrets` o | |
```hcl | ||
module "secret-manager" { | ||
source = "./fabric/modules/secret-manager" | ||
project_id = "my-project" | ||
project_id = var.project_id | ||
secrets = { | ||
test-auto = { | ||
keys = { | ||
global = "projects/PROJECT_ID/locations/global/keyRings/KEYRING/cryptoKeys/KEY" | ||
global = module.kms_global.keys.key-gl.id | ||
} | ||
} | ||
test-auto-nokeys = {} | ||
test-manual = { | ||
locations = ["europe-west1", "europe-west4"] | ||
locations = [var.regions.primary, var.regions.secondary] | ||
keys = { | ||
europe-west1 = "projects/PROJECT_ID/locations/europe-west1/keyRings/KEYRING/cryptoKeys/KEY" | ||
europe-west4 = "projects/PROJECT_ID/locations/europe-west4/keyRings/KEYRING/cryptoKeys/KEY" | ||
"${var.regions.primary}" = module.kms_regional_primary.keys.key-a.id | ||
"${var.regions.secondary}" = module.kms_regional_secondary.keys.key-b.id | ||
} | ||
} | ||
} | ||
} | ||
# tftest modules=1 resources=3 | ||
# tftest modules=4 resources=11 fixtures=fixtures/kms-global-regional-keys.tf inventory=secret-cmek.yaml e2e | ||
``` | ||
<!-- BEGIN TFDOC --> | ||
## Variables | ||
|
@@ -125,6 +125,10 @@ module "secret-manager" { | |
| [version_ids](outputs.tf#L29) | Version ids keyed by secret name : version name. | | | ||
| [version_versions](outputs.tf#L36) | Version versions keyed by secret name : version name. | | | ||
| [versions](outputs.tf#L43) | Secret versions. | ✓ | | ||
|
||
## Fixtures | ||
|
||
- [kms-global-regional-keys.tf](../../tests/fixtures/kms-global-regional-keys.tf) | ||
<!-- END TFDOC --> | ||
## Requirements | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
resource "google_project_service_identity" "secretmanager" { | ||
provider = google-beta | ||
project = var.project_id | ||
service = "secretmanager.googleapis.com" | ||
} | ||
|
||
resource "google_project_iam_binding" "bindings" { | ||
project = var.project_id | ||
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" | ||
members = ["serviceAccount:${resource.google_project_service_identity.secretmanager.email}"] | ||
} | ||
|
||
module "kms_regional_primary" { | ||
source = "./fabric/modules/kms" | ||
project_id = var.project_id | ||
keyring = { | ||
location = var.regions.primary | ||
name = "keyring-primary" | ||
} | ||
keys = { | ||
"key-a" = { | ||
} | ||
} | ||
depends_on = [google_project_iam_binding.bindings] | ||
} | ||
|
||
module "kms_regional_secondary" { | ||
source = "./fabric/modules/kms" | ||
project_id = var.project_id | ||
keyring = { | ||
location = var.regions.secondary | ||
name = "keyring-secondary" | ||
} | ||
keys = { | ||
"key-b" = { | ||
} | ||
} | ||
depends_on = [google_project_iam_binding.bindings] | ||
} | ||
|
||
module "kms_global" { | ||
source = "./fabric/modules/kms" | ||
project_id = var.project_id | ||
keyring = { | ||
location = "global" | ||
name = "keyring-gl" | ||
} | ||
keys = { | ||
"key-gl" = { | ||
} | ||
} | ||
depends_on = [google_project_iam_binding.bindings] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
values: | ||
module.secret-manager.google_secret_manager_secret.default["test-auto"]: | ||
annotations: null | ||
labels: null | ||
project: project-id | ||
replication: | ||
- auto: | ||
- {} | ||
user_managed: [] | ||
rotation: [] | ||
secret_id: test-auto | ||
timeouts: null | ||
topics: [] | ||
ttl: null | ||
version_aliases: null | ||
version_destroy_ttl: null | ||
module.secret-manager.google_secret_manager_secret.default["test-auto-nokeys"]: | ||
annotations: null | ||
labels: null | ||
project: project-id | ||
replication: | ||
- auto: | ||
- customer_managed_encryption: [] | ||
user_managed: [] | ||
rotation: [] | ||
secret_id: test-auto-nokeys | ||
timeouts: null | ||
topics: [] | ||
ttl: null | ||
version_aliases: null | ||
version_destroy_ttl: null | ||
module.secret-manager.google_secret_manager_secret.default["test-manual"]: | ||
annotations: null | ||
labels: null | ||
project: project-id | ||
replication: | ||
- auto: [] | ||
user_managed: | ||
- replicas: | ||
- location: europe-west8 | ||
- location: europe-west9 | ||
rotation: [] | ||
secret_id: test-manual | ||
timeouts: null | ||
topics: [] | ||
ttl: null | ||
version_aliases: null | ||
version_destroy_ttl: null | ||
|
||
counts: | ||
google_kms_crypto_key: 3 | ||
google_kms_key_ring: 3 | ||
google_project_iam_binding: 1 | ||
google_project_service_identity: 1 | ||
google_secret_manager_secret: 3 | ||
modules: 4 | ||
resources: 11 | ||
|
||
outputs: {} | ||
|
||
outputs: {} |
Oops, something went wrong.