use new iam variables in kms module
This commit is contained in:
parent
f72bea3f96
commit
f1a3c3ebe8
|
@ -16,7 +16,7 @@ In this module **no lifecycle blocks are set on resources to prevent destroy**,
|
|||
module "kms" {
|
||||
source = "../modules/kms"
|
||||
project_id = "my-project"
|
||||
iam_members = {
|
||||
iam = {
|
||||
"roles/owner" = ["user:user1@example.com"]
|
||||
}
|
||||
keyring = { location = "europe-west1", name = "test" }
|
||||
|
@ -31,7 +31,7 @@ module "kms" {
|
|||
module "kms" {
|
||||
source = "../modules/kms"
|
||||
project_id = "my-project"
|
||||
key_iam_members = {
|
||||
key_iam = {
|
||||
key-a = {
|
||||
"roles/owner" = ["user:user1@example.com"]
|
||||
}
|
||||
|
@ -72,8 +72,8 @@ module "kms" {
|
|||
|---|---|:---: |:---:|:---:|
|
||||
| keyring | Keyring attributes. | <code title="object({ location = string name = string })">object({...})</code> | ✓ | |
|
||||
| project_id | Project id where the keyring will be created. | <code title="">string</code> | ✓ | |
|
||||
| *iam_members* | Keyring IAM members. | <code title="map(set(string))">map(set(string))</code> | | <code title="">{}</code> |
|
||||
| *key_iam_members* | IAM members keyed by key name and role. | <code title="map(map(set(string)))">map(map(set(string)))</code> | | <code title="">{}</code> |
|
||||
| *iam* | Keyring IAM bindings for topic in {ROLE => [MEMBERS]} format. | <code title="map(list(string))">map(list(string))</code> | | <code title="">{}</code> |
|
||||
| *key_iam* | Key IAM bindings for topic in {KEY => {ROLE => [MEMBERS]}} format. | <code title="map(map(list(string)))">map(map(list(string)))</code> | | <code title="">{}</code> |
|
||||
| *key_purpose* | Per-key purpose, if not set defaults will be used. If purpose is not `ENCRYPT_DECRYPT` (the default), `version_template.algorithm` is required. | <code title="map(object({ purpose = string version_template = object({ algorithm = string protection_level = string }) }))">map(object({...}))</code> | | <code title="">{}</code> |
|
||||
| *key_purpose_defaults* | Defaults used for key purpose when not defined at the key level. If purpose is not `ENCRYPT_DECRYPT` (the default), `version_template.algorithm` is required. | <code title="object({ purpose = string version_template = object({ algorithm = string protection_level = string }) })">object({...})</code> | | <code title="{ purpose = null version_template = null }">...</code> |
|
||||
| *keyring_create* | Set to false to manage keys and IAM bindings in an existing keyring. | <code title="">bool</code> | | <code title="">true</code> |
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
locals {
|
||||
key_iam_members = flatten([
|
||||
for key, roles in var.key_iam_members : [
|
||||
for key, roles in var.key_iam : [
|
||||
for role, members in roles : {
|
||||
key = key
|
||||
role = role
|
||||
|
@ -51,7 +51,7 @@ resource "google_kms_key_ring" "default" {
|
|||
}
|
||||
|
||||
resource "google_kms_key_ring_iam_binding" "default" {
|
||||
for_each = var.iam_members
|
||||
for_each = var.iam
|
||||
key_ring_id = local.keyring.self_link
|
||||
role = each.key
|
||||
members = each.value
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
variable "iam_members" {
|
||||
description = "Keyring IAM members."
|
||||
type = map(set(string))
|
||||
variable "iam" {
|
||||
description = "Keyring IAM bindings for topic in {ROLE => [MEMBERS]} format."
|
||||
type = map(list(string))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "key_iam_members" {
|
||||
description = "IAM members keyed by key name and role."
|
||||
type = map(map(set(string)))
|
||||
variable "key_iam" {
|
||||
description = "Key IAM bindings for topic in {KEY => {ROLE => [MEMBERS]}} format."
|
||||
type = map(map(list(string)))
|
||||
default = {}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
module "test" {
|
||||
source = "../../../../modules/kms"
|
||||
iam_members = var.iam_members
|
||||
key_iam_members = var.key_iam_members
|
||||
iam = var.iam
|
||||
key_iam = var.key_iam
|
||||
key_purpose = var.key_purpose
|
||||
key_purpose_defaults = var.key_purpose_defaults
|
||||
keyring = var.keyring
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
variable "iam_members" {
|
||||
variable "iam" {
|
||||
type = map(list(string))
|
||||
default = {
|
||||
"roles/owner" = ["user:ludo@ludomagno.net"]
|
||||
}
|
||||
}
|
||||
|
||||
variable "key_iam_members" {
|
||||
variable "key_iam" {
|
||||
type = map(map(list(string)))
|
||||
default = {
|
||||
key-a = {
|
||||
|
|
Loading…
Reference in New Issue