Skip to content

Commit e28c1cd

Browse files
fix: add new example to use existing kms (#389)
* fix: add new example to use existing kms" * fix: pre-commit failure --------- Co-authored-by: shikha-mah <[email protected]>
1 parent 0ce8804 commit e28c1cd

File tree

7 files changed

+53
-0
lines changed

7 files changed

+53
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ You need the following permissions to run this module.
4242
## Examples
4343

4444
- [ End to end example with default values](examples/default)
45+
- [ An example that uses existing KMS](examples/existing-kms)
4546
<!-- END EXAMPLES HOOK -->
4647
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4748
## Requirements

examples/existing-kms/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# An example that uses existing KMS
2+
3+
An example that uses the existing KMS and create a Key Ring within the provided KMS Instance.

examples/existing-kms/main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
3+
##############################################################################
4+
# Key Ring module
5+
##############################################################################
6+
7+
module "kms_key_ring" {
8+
source = "../.."
9+
instance_id = var.existing_kms_instance_guid
10+
key_ring_id = "${var.prefix}-key-ring"
11+
}

examples/existing-kms/outputs.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
##############################################################################
2+
# Outputs
3+
##############################################################################
4+
5+
output "kms_key_ring_id" {
6+
description = "KMS Key Ring ID"
7+
value = module.kms_key_ring.key_ring_id
8+
}

examples/existing-kms/provider.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "ibm" {
2+
ibmcloud_api_key = var.ibmcloud_api_key
3+
}

examples/existing-kms/variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
variable "ibmcloud_api_key" {
2+
type = string
3+
description = "The IBM Cloud API Key"
4+
sensitive = true
5+
}
6+
7+
variable "prefix" {
8+
type = string
9+
description = "Prefix to append to all resources created by this example"
10+
default = "kms-kr"
11+
}
12+
13+
variable "existing_kms_instance_guid" {
14+
type = string
15+
description = "GUID of an existing KMS instance."
16+
default = null
17+
}

examples/existing-kms/version.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.3.0"
3+
required_providers {
4+
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
5+
ibm = {
6+
source = "IBM-Cloud/ibm"
7+
version = "1.49.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)