Skip to content

Commit

Permalink
adding datasource for autokeyconfig (#12611) (#20807)
Browse files Browse the repository at this point in the history
[upstream:9ca4299ff15c8f81506bbed2696bd30919c440db]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jan 2, 2025
1 parent f2f60b6 commit d2c3730
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/12611.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-datasource
`google_kms_autokey_config`
```
3 changes: 3 additions & 0 deletions google/services/kms/data_source_google_kms_auotokey_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package kms
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package kms_test
8 changes: 8 additions & 0 deletions google/services/kms/kms_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ type KmsKeyHandleId struct {
Name string
}

type KmsAutokeyConfigId struct {
Folder string
}

func (s *KmsAutokeyConfigId) AutokeyConfigId() string {
return fmt.Sprintf("%s/autokeyConfig", s.Folder)
}

func (s *KmsKeyHandleId) KeyHandleId() string {
return fmt.Sprintf("projects/%s/locations/%s/keyHandles/%s", s.Project, s.Location, s.Name)
}
Expand Down
42 changes: 42 additions & 0 deletions website/docs/d/kms_autokey_config.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
subcategory: "Cloud Key Management Service"
description: |-
Provides access to KMS Autokey config data with Google Cloud KMS.
---

# google_kms_key_handle

Provides access to Google Cloud Platform KMS AutokeyConfig. A AutokeyConfig is a Cloud KMS resource that helps you safely span the separation of duties to create new Cloud KMS keys for CMEK using Autokey.

~> **Warning:** This resource is in beta, and should be used with the terraform-provider-google-beta provider.
See [Provider Versions](https://terraform.io/docs/providers/google/guides/provider_versions.html) for more details on beta resources.


For more information see
[the official documentation](https://cloud.google.com/kms/docs/reference/rest/v1/folders)
and
[API](https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyHandles).

## Example Usage

```hcl
data "google_kms_autokey_config" "my_autokey_config" {
folder = "folders/123"
}
```

## Argument Reference

The following arguments are supported:

* `folder` - The folder in which the AutokeyConfig is configured. If it
is not provided, the provider folder is used.

## Attributes Reference

In addition to the arguments listed above, the following computed attributes are
exported:

* `id` - The identifier of the AutokeyConfig. Its format is `folders/{folderId}/autokeyConfig`.

* `key_project` - The identifier of the project hosting KMS KeyRings and Keys generated by Autokey. Its format is `projects/{projectId}`.

0 comments on commit d2c3730

Please sign in to comment.