You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The v4.0 release of *kms* is a backwards incompatible release.
3
+
4
+
### Autokey Submodule
5
+
The current users of Autokey submodules needs to
6
+
- Switch `project_id` to `key_project_id`
7
+
- Stop using `autokey_handles` field to generate keyhandles, instead directly use `google_kms_key_handle` terraform resource to create keyhandles. For detailed example check [bucket_setup_using_autokey](../examples/bucket_setup_using_autokey/).
8
+
9
+
10
+
### To Migrate from v3.0 to v4.0
11
+
Using V3.0 of Autokey modules if you have created keyhandles and wants to use them with V4.0 version then they need to be imported using below steps
12
+
13
+
1. Retrieve the keyhandles created:
14
+
- Run `terraform state list module.autokey.google_kms_key_handle.primary` to list all keyhandles created using v3.0
15
+
- For each item in the output of above CLI, run `terraform state show 'module.autokey.google_kms_key_handle.primary["<an id from the output of list>"]'` and copy the resulting `id` field from the cli output to notepad
16
+
2. Delete all keyhandles from the state: run `terraform state rm module.autokey.google_kms_key_handle.primary`
17
+
3. Update the main root module to use V4.0 version. Add the keyhandle config definition to the main root module for all the keyhandle found in step1.
18
+
4. Import all the keyhandles configs using id copied in setp1 to the terraform state
19
+
- for each keyhandle id found in step1, Run `terraform import resource.google_kms_key_handle.<key_handle_name_given_in_step3> "<paste corresponding keyhandle id copied in step 1>"`
Copy file name to clipboardexpand all lines: examples/bucket_setup_using_autokey/README.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,23 @@
1
1
# Autokey Example
2
2
3
-
This example illustrates how to use the `autokey` kms submodule for [KMS Autokey](https://cloud.google.com/kms/docs/autokey-overview) feature.
3
+
This example illustrates how to use the `autokey` kms submodule for [KMS Autokey](https://cloud.google.com/kms/docs/autokey-overview) feature to create the bucket.
4
4
5
5
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6
6
## Inputs
7
7
8
8
| Name | Description | Type | Default | Required |
| autokey\_resource\_project\_id | The ID of the project for Autokey to be used (e.g: a storage project which expects to use Autokey as CMEK). |`string`| n/a | yes |
11
-
| folder\_id | The Autokey folder number used by Autokey config resource. Required when using Autokey. |`string`| n/a | yes |
12
-
| project\_id | The ID of the project in which to provision Autokey resources (autokey keyring and keyHandle keys). |`string`| n/a | yes |
10
+
| bucket\_location | The GCP location where storage bucket will be created |`string`|`"us-central1"`| no |
11
+
| folder\_id | The ID of the folder for which to configure and enable Autokey feature. |`string`| n/a | yes |
12
+
| key\_project\_id | The ID of the project in which KMS keyring and KMS keys will be provisioned by autokey. |`string`| n/a | yes |
13
+
| resource\_project\_id | The ID of the project in which to provision cloud storage bucket resource. |`string`| n/a | yes |
13
14
14
15
## Outputs
15
16
16
17
| Name | Description |
17
18
|------|-------------|
18
-
| autokey\_config\_id | An Autokey configuration identifier. |
19
-
| autokey\_keyhandles | A map of KeyHandles created. |
20
-
| autokey\_project\_id | Project used for autokey. |
19
+
| bucket\_keyhandle | Keyhandle configuration created for the bucket. |
This is a submodule built to make [KMS Autokey](https://cloud.google.com/kms/docs/autokey-overview) feature simple to be used. This submodule will create the [Autokey Config](https://cloud.google.com/kms/docs/enable-autokey#enable-autokey-folder) for an existing folder where you want to enable Autokey, set up the Cloud KMS [service agent](https://cloud.google.com/kms/docs/enable-autokey#autokey-service-agent) on an existing key project and create [Key Handles](https://cloud.google.com/kms/docs/resource-hierarchy#key_handles) for existing resource projects.
4
-
3
+
This is a submodule built to make [KMS Autokey](https://cloud.google.com/kms/docs/autokey-overview) feature simple to be used. This submodule will create the [Autokey Config](https://cloud.google.com/kms/docs/enable-autokey#enable-autokey-folder) for an existing folder where you want to enable Autokey, set up the Cloud KMS [service agent](https://cloud.google.com/kms/docs/enable-autokey#autokey-service-agent) on an existing key project.
5
4
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6
5
## Inputs
7
6
8
7
| Name | Description | Type | Default | Required |
| autokey\_folder\_number | The Autokey folder number used by Autokey config resource. Required when using Autokey. |`string`| n/a | yes |
11
-
| autokey\_handles | (Optional) A KeyHandle is a resource used by Autokey to auto-provision CryptoKeys for CMEK for a particular service.<br>- name: The resource name for the KeyHandle.<br>- resource\_type\_selector: Indicates the resource type that the resulting CryptoKey is meant to protect, in the following format: {SERVICE}.googleapis.com/{TYPE}. For example, storage.googleapis.com/Bucket. All Cloud KMS Autokey compatible services available at https://cloud.google.com/kms/docs/autokey-overview#compatible-services.<br>- location: The location for the KeyHandle. A full list of valid locations can be found by running gcloud kms locations list.<br>- project: The ID of the project in which the resource belongs. If it is not provided, the provider project is used. | <pre>map(object({<br> name = string<br> resource_type_selector = string<br> location = string<br> project = string<br> }))</pre> |`null`| no |
12
-
| project\_id | Project id where the Autokey configuration and KeyHandles will be created. |`string`| n/a | yes |
9
+
| autokey\_folder\_number | The folder number on which autokey will be configured and enabled. Required when using Autokey. |`string`| n/a | yes |
10
+
| key\_project\_id | The ID of the project in which kms keyrings and keys will be provisioned by the Autokey. |`string`| n/a | yes |
13
11
14
12
## Outputs
15
13
16
14
| Name | Description |
17
15
|------|-------------|
18
16
| autokey\_config\_id | An Autokey configuration identifier. |
19
-
| autokey\_keyhandles | A map of KeyHandles created. |
20
-
| random\_suffix | Random 4 digits suffix used in Autokey submodule. |
Copy file name to clipboardexpand all lines: modules/autokey/variables.tf
+3-19
Original file line number
Diff line number
Diff line change
@@ -14,29 +14,13 @@
14
14
* limitations under the License.
15
15
*/
16
16
17
-
variable"project_id" {
18
-
description="Project id where the Autokey configuration and KeyHandles will be created."
17
+
variable"key_project_id" {
18
+
description="The ID of the project in which kms keyrings and keys will be provisioned by the Autokey."
19
19
type=string
20
20
}
21
21
22
22
variable"autokey_folder_number" {
23
23
type=string
24
-
description="The Autokey folder number used by Autokey config resource. Required when using Autokey."
24
+
description="The folder number on which autokey will be configured and enabled. Required when using Autokey."
25
25
}
26
26
27
-
variable"autokey_handles" {
28
-
type=map(object({
29
-
name =string
30
-
resource_type_selector =string
31
-
location =string
32
-
project =string
33
-
}))
34
-
description=<<-EOF
35
-
(Optional) A KeyHandle is a resource used by Autokey to auto-provision CryptoKeys for CMEK for a particular service.
36
-
- name: The resource name for the KeyHandle.
37
-
- resource_type_selector: Indicates the resource type that the resulting CryptoKey is meant to protect, in the following format: {SERVICE}.googleapis.com/{TYPE}. For example, storage.googleapis.com/Bucket. All Cloud KMS Autokey compatible services available at https://cloud.google.com/kms/docs/autokey-overview#compatible-services.
38
-
- location: The location for the KeyHandle. A full list of valid locations can be found by running gcloud kms locations list.
39
-
- project: The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
assert.True(keyHandleKmsKey!="", "Invalid KMS Key generated for bucket keyhandle")
37
+
assert.True(bucketKmsKey==keyHandleKmsKey, "KMS Key generated for bucket keyhandle %s is not matching with kms key used in bucket %s", keyHandleKmsKey, bucketKmsKey)
0 commit comments