Skip to content

Commit

Permalink
fix: add new example to use existing kms (#389)
Browse files Browse the repository at this point in the history
* fix: add new example to use existing kms"

* fix: pre-commit failure

---------

Co-authored-by: shikha-mah <shikha.mah@in.ibm.com>
  • Loading branch information
maheshwarishikha and ShikhaMahe authored Jun 20, 2023
1 parent 0ce8804 commit e28c1cd
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ You need the following permissions to run this module.
## Examples

- [ End to end example with default values](examples/default)
- [ An example that uses existing KMS](examples/existing-kms)
<!-- END EXAMPLES HOOK -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements
Expand Down
3 changes: 3 additions & 0 deletions examples/existing-kms/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# An example that uses existing KMS

An example that uses the existing KMS and create a Key Ring within the provided KMS Instance.
11 changes: 11 additions & 0 deletions examples/existing-kms/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


##############################################################################
# Key Ring module
##############################################################################

module "kms_key_ring" {
source = "../.."
instance_id = var.existing_kms_instance_guid
key_ring_id = "${var.prefix}-key-ring"
}
8 changes: 8 additions & 0 deletions examples/existing-kms/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##############################################################################
# Outputs
##############################################################################

output "kms_key_ring_id" {
description = "KMS Key Ring ID"
value = module.kms_key_ring.key_ring_id
}
3 changes: 3 additions & 0 deletions examples/existing-kms/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
}
17 changes: 17 additions & 0 deletions examples/existing-kms/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variable "ibmcloud_api_key" {
type = string
description = "The IBM Cloud API Key"
sensitive = true
}

variable "prefix" {
type = string
description = "Prefix to append to all resources created by this example"
default = "kms-kr"
}

variable "existing_kms_instance_guid" {
type = string
description = "GUID of an existing KMS instance."
default = null
}
10 changes: 10 additions & 0 deletions examples/existing-kms/version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.3.0"
required_providers {
# Pin to the lowest provider version of the range defined in the main module's version.tf to ensure lowest version still works
ibm = {
source = "IBM-Cloud/ibm"
version = "1.49.0"
}
}
}

0 comments on commit e28c1cd

Please sign in to comment.