-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add module to get a Key from the GCP Project #84
Open
hbitoun-aneo
wants to merge
10
commits into
revamp-cloud
Choose a base branch
from
hb/gcp-get-key-module
base: revamp-cloud
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4740e21
feat: add module to get a key from the project
hbitoun-aneo 916ca64
fix: changes from CI
hbitoun-aneo 0b93d69
terraform-docs: automated action
github-actions[bot] 4790e45
fix: changes to fit to the kms module and after review
hbitoun-aneo a2df6e9
fix: changes from CI
hbitoun-aneo 59d9c94
Merge branch 'hb/gcp-get-key-module' of https://github.com/aneoconsul…
hbitoun-aneo 279a614
terraform-docs: automated action
github-actions[bot] e3493d1
doc: add explanation about the module get-key
hbitoun-aneo 36b59af
Merge branch 'main' into hb/gcp-get-key-module
hbitoun-aneo 75bbca8
fix: change directory name of the get-kms module to kms-get
hbitoun-aneo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Cloud KMS | ||
|
||
Cloud Key Management Service allows you to create, import, and manage cryptographic keys and perform cryptographic | ||
operations in a single centralized cloud service. You can use these keys and perform these operations by using Cloud KMS | ||
directly, by using Cloud HSM or Cloud External Key Manager, or by using Customer-Managed Encryption Keys (CMEK) integrations | ||
within other Google Cloud services. | ||
|
||
This module retrieve a key from the GCP project. The retrieved keys are used by the service accounts for | ||
encrypt and decrypt the data (by adding decrypt/encrypt rights on the kms key for the service accounts). | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 4.75.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_google"></a> [google](#provider\_google) | >= 4.75.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [google_client_config.current](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_config) | data source | | ||
| [google_kms_crypto_key.my_crypto_keys](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/kms_crypto_key) | data source | | ||
| [google_kms_key_ring.my_key_ring](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/kms_key_ring) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_crypto_key_names"></a> [crypto\_key\_names](#input\_crypto\_key\_names) | The names of the crypto keys to retrieve from the GCP project. | `list(string)` | n/a | yes | | ||
| <a name="input_key_ring_name"></a> [key\_ring\_name](#input\_key\_ring\_name) | The key ring name on which the crypto key belongs to. | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_key_ring_id"></a> [key\_ring\_id](#output\_key\_ring\_id) | The ID of the KeyRing. | | ||
| <a name="output_key_ring_location"></a> [key\_ring\_location](#output\_key\_ring\_location) | The location for the KeyRing. | | ||
| <a name="output_key_ring_name"></a> [key\_ring\_name](#output\_key\_ring\_name) | The resource name for the KeyRing. | | ||
| <a name="output_my_crypto_key_output"></a> [my\_crypto\_key\_output](#output\_my\_crypto\_key\_output) | The crypto keys on the GCP project from the specified KeyRing. | | ||
<!-- END_TF_DOCS --> |
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,4 @@ | ||
# Simple GCP Cloud KMS | ||
|
||
Terraform scripts to get a kms key from the GCP project. | ||
|
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,38 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_google"></a> [google](#requirement\_google) | ~> 4.75.0 | | ||
|
||
## Providers | ||
|
||
No providers. | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_simple_kms"></a> [simple\_kms](#module\_simple\_kms) | ../../../get-kms | n/a | | ||
|
||
## Resources | ||
|
||
No resources. | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_project"></a> [project](#input\_project) | Project name | `string` | n/a | yes | | ||
| <a name="input_region"></a> [region](#input\_region) | The GCP region used to deploy the KMS. | `string` | `"europe-west9"` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_key_ring_id"></a> [key\_ring\_id](#output\_key\_ring\_id) | The ID of the KeyRing. | | ||
| <a name="output_key_ring_location"></a> [key\_ring\_location](#output\_key\_ring\_location) | The location for the KeyRing. | | ||
| <a name="output_key_ring_name"></a> [key\_ring\_name](#output\_key\_ring\_name) | The resource name for the KeyRing. | | ||
| <a name="output_my_crypto_key_output"></a> [my\_crypto\_key\_output](#output\_my\_crypto\_key\_output) | The crypto keys on the GCP project from the specified KeyRing. | | ||
<!-- END_TF_DOCS --> |
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,5 @@ | ||
module "simple_kms" { | ||
source = "../../../get-kms" | ||
key_ring_name = "test" | ||
crypto_key_names = ["my-key-name", "my-key-name2"] | ||
} |
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,19 @@ | ||||||
output "my_crypto_key_output" { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
description = "The crypto keys on the GCP project from the specified KeyRing." | ||||||
value = module.simple_kms.my_crypto_key_output | ||||||
} | ||||||
|
||||||
output "key_ring_name" { | ||||||
description = "The resource name for the KeyRing." | ||||||
value = module.simple_kms.key_ring_name | ||||||
} | ||||||
|
||||||
output "key_ring_location" { | ||||||
description = "The location for the KeyRing." | ||||||
value = module.simple_kms.key_ring_location | ||||||
} | ||||||
|
||||||
output "key_ring_id" { | ||||||
description = "The ID of the KeyRing." | ||||||
value = module.simple_kms.key_ring_id | ||||||
} |
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,10 @@ | ||
variable "region" { | ||
description = "The GCP region used to deploy the KMS." | ||
type = string | ||
default = "europe-west9" | ||
} | ||
|
||
variable "project" { | ||
description = "Project name" | ||
type = string | ||
} |
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,14 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 4.75.0" | ||
} | ||
} | ||
} | ||
|
||
provider "google" { | ||
project = var.project | ||
region = var.region | ||
} |
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,12 @@ | ||
data "google_kms_key_ring" "my_key_ring" { | ||
name = var.key_ring_name | ||
location = data.google_client_config.current.region | ||
} | ||
|
||
data "google_kms_crypto_key" "my_crypto_keys" { | ||
for_each = toset(var.crypto_key_names) | ||
name = each.value | ||
key_ring = data.google_kms_key_ring.my_key_ring.id | ||
} | ||
|
||
data "google_client_config" "current" {} |
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,19 @@ | ||
output "my_crypto_key_output" { | ||
description = "The crypto keys on the GCP project from the specified KeyRing." | ||
value = { for key, value in data.google_kms_crypto_key.my_crypto_keys : key => value.id } | ||
} | ||
|
||
output "key_ring_name" { | ||
description = "The resource name for the KeyRing." | ||
value = data.google_kms_key_ring.my_key_ring.name | ||
} | ||
|
||
output "key_ring_location" { | ||
description = "The location for the KeyRing." | ||
value = data.google_kms_key_ring.my_key_ring.location | ||
} | ||
|
||
output "key_ring_id" { | ||
description = "The ID of the KeyRing." | ||
value = data.google_kms_key_ring.my_key_ring.id | ||
} |
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,9 @@ | ||||||
variable "crypto_key_names" { | ||||||
description = "The names of the crypto keys to retrieve from the GCP project." | ||||||
type = list(string) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
variable "key_ring_name" { | ||||||
description = "The key ring name on which the crypto key belongs to." | ||||||
type = string | ||||||
} |
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,9 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = ">= 4.75.0" | ||
} | ||
} | ||
} |
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,52 @@ | ||
# Cloud KMS | ||
|
||
Cloud Key Management Service allows you to create, import, and manage cryptographic keys and perform cryptographic | ||
operations in a single centralized cloud service. You can use these keys and perform these operations by using Cloud KMS | ||
directly, by using Cloud HSM or Cloud External Key Manager, or by using Customer-Managed Encryption Keys (CMEK) integrations | ||
within other Google Cloud services. | ||
|
||
This module retrieve a key from the GCP project. The retrieved keys are used by the service accounts for | ||
encrypt and decrypt the data (by adding decrypt/encrypt rights on the kms key for the service accounts). | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_google"></a> [google](#requirement\_google) | >= 4.75.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_google"></a> [google](#provider\_google) | >= 4.75.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [google_client_config.current](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_config) | data source | | ||
| [google_kms_crypto_key.my_crypto_keys](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/kms_crypto_key) | data source | | ||
| [google_kms_key_ring.my_key_ring](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/kms_key_ring) | data source | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_crypto_key_names"></a> [crypto\_key\_names](#input\_crypto\_key\_names) | The names of the crypto keys to retrieve from the GCP project. | `list(string)` | n/a | yes | | ||
| <a name="input_key_ring_name"></a> [key\_ring\_name](#input\_key\_ring\_name) | The key ring name on which the crypto key belongs to. | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_key_ring_id"></a> [key\_ring\_id](#output\_key\_ring\_id) | The ID of the KeyRing. | | ||
| <a name="output_key_ring_location"></a> [key\_ring\_location](#output\_key\_ring\_location) | The location for the KeyRing. | | ||
| <a name="output_key_ring_name"></a> [key\_ring\_name](#output\_key\_ring\_name) | The resource name for the KeyRing. | | ||
| <a name="output_my_crypto_key_output"></a> [my\_crypto\_key\_output](#output\_my\_crypto\_key\_output) | The crypto keys on the GCP project from the specified KeyRing. | | ||
<!-- END_TF_DOCS --> |
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,4 @@ | ||
# Simple GCP Cloud KMS | ||
|
||
Terraform scripts to get a kms key from the GCP project. | ||
|
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,38 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_google"></a> [google](#requirement\_google) | ~> 4.75.0 | | ||
|
||
## Providers | ||
|
||
No providers. | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_simple_kms"></a> [simple\_kms](#module\_simple\_kms) | ../../../get-kms | n/a | | ||
|
||
## Resources | ||
|
||
No resources. | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_project"></a> [project](#input\_project) | Project name | `string` | n/a | yes | | ||
| <a name="input_region"></a> [region](#input\_region) | The GCP region used to deploy the KMS. | `string` | `"europe-west9"` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_key_ring_id"></a> [key\_ring\_id](#output\_key\_ring\_id) | The ID of the KeyRing. | | ||
| <a name="output_key_ring_location"></a> [key\_ring\_location](#output\_key\_ring\_location) | The location for the KeyRing. | | ||
| <a name="output_key_ring_name"></a> [key\_ring\_name](#output\_key\_ring\_name) | The resource name for the KeyRing. | | ||
| <a name="output_my_crypto_key_output"></a> [my\_crypto\_key\_output](#output\_my\_crypto\_key\_output) | The crypto keys on the GCP project from the specified KeyRing. | | ||
<!-- END_TF_DOCS --> |
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,5 @@ | ||
module "simple_kms" { | ||
source = "../../../get-kms" | ||
key_ring_name = "test" | ||
crypto_key_names = ["my-key-name", "my-key-name2"] | ||
} |
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,19 @@ | ||
output "my_crypto_key_output" { | ||
description = "The crypto keys on the GCP project from the specified KeyRing." | ||
value = module.simple_kms.my_crypto_key_output | ||
} | ||
|
||
output "key_ring_name" { | ||
description = "The resource name for the KeyRing." | ||
value = module.simple_kms.key_ring_name | ||
} | ||
|
||
output "key_ring_location" { | ||
description = "The location for the KeyRing." | ||
value = module.simple_kms.key_ring_location | ||
} | ||
|
||
output "key_ring_id" { | ||
description = "The ID of the KeyRing." | ||
value = module.simple_kms.key_ring_id | ||
} |
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,10 @@ | ||
variable "region" { | ||
description = "The GCP region used to deploy the KMS." | ||
type = string | ||
default = "europe-west9" | ||
} | ||
|
||
variable "project" { | ||
description = "Project name" | ||
type = string | ||
} |
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,14 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 4.75.0" | ||
} | ||
} | ||
} | ||
|
||
provider "google" { | ||
project = var.project | ||
region = var.region | ||
} |
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,12 @@ | ||
data "google_kms_key_ring" "my_key_ring" { | ||
name = var.key_ring_name | ||
location = data.google_client_config.current.region | ||
} | ||
|
||
data "google_kms_crypto_key" "my_crypto_keys" { | ||
for_each = toset(var.crypto_key_names) | ||
name = each.value | ||
key_ring = data.google_kms_key_ring.my_key_ring.id | ||
} | ||
|
||
data "google_client_config" "current" {} |
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,19 @@ | ||
output "my_crypto_key_output" { | ||
description = "The crypto keys on the GCP project from the specified KeyRing." | ||
value = { for key, value in data.google_kms_crypto_key.my_crypto_keys : key => value.id } | ||
} | ||
|
||
output "key_ring_name" { | ||
description = "The resource name for the KeyRing." | ||
value = data.google_kms_key_ring.my_key_ring.name | ||
} | ||
|
||
output "key_ring_location" { | ||
description = "The location for the KeyRing." | ||
value = data.google_kms_key_ring.my_key_ring.location | ||
} | ||
|
||
output "key_ring_id" { | ||
description = "The ID of the KeyRing." | ||
value = data.google_kms_key_ring.my_key_ring.id | ||
} |
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,9 @@ | ||
variable "crypto_key_names" { | ||
description = "The names of the crypto keys to retrieve from the GCP project." | ||
type = list(string) | ||
} | ||
|
||
variable "key_ring_name" { | ||
description = "The key ring name on which the crypto key belongs to." | ||
type = string | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a missing output compared to to the resource module: