Skip to content

Commit

Permalink
feat: initial release (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khuzaima05 authored Nov 29, 2023
1 parent 145690d commit 9931045
Show file tree
Hide file tree
Showing 28 changed files with 612 additions and 199 deletions.
6 changes: 3 additions & 3 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ repository:
# By changing this field, you rename the repository.

# Uncomment this name property and set the name to the current repo name.
# name: ""
name: "terraform-ibm-secrets-manager"

# The description is displayed under the repository name on the
# organization page and in the 'About' section of the repository.

# Uncomment this description property
# and update the description to the current repo description.
# description: ""
description: "This module creates a Secrets Manager instance"

# Use a comma-separated list of topics to set on the repo (ensure not to use any caps in the topic string).
topics: terraform, ibm-cloud, terraform-module
topics: core-team, terraform, ibm-cloud, terraform-module, secrets-manager, supported, graduated
15 changes: 13 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "go.sum|^.secrets.baseline$",
"lines": null
},
"generated_at": "2023-06-03T04:42:19Z",
"generated_at": "2023-11-29T09:46:00Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -76,7 +76,18 @@
"name": "TwilioKeyDetector"
}
],
"results": {},
"results": {
"README.md": [
{
"hashed_secret": "33da8d0e8af2efc260f01d8e5edfcc5c5aba44ad",
"is_secret": true,
"is_verified": false,
"line_number": 32,
"type": "Secret Keyword",
"verified_result": null
}
]
},
"version": "0.13.1+ibm.61.dss",
"word_list": {
"file": null,
Expand Down
103 changes: 50 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Secrets Manager module

<!--
Update status and "latest release" badges:
1. For the status options, see https://github.ibm.com/GoldenEye/documentation/blob/master/status.md
2. Update the "latest release" badge to point to the correct module's repo. Replace "module-template" in two places.
-->
[![Incubating (Not yet consumable)](https://img.shields.io/badge/status-Incubating%20(Not%20yet%20consumable)-red)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)

[![Graduated (Supported)](https://img.shields.io/badge/Status-Graduated%20(Supported)-brightgreen)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-secrets-manager?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager/releases/latest)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

<!-- Add a description of module(s) in this repo -->
TODO: Replace me with description of the module(s) in this repo
This module is used to provision and configure an IBM Cloud [Secrets Manager](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-getting-started) instance.


<!-- Below content is automatically populated via pre-commit hook -->
Expand All @@ -21,64 +17,43 @@ TODO: Replace me with description of the module(s) in this repo
* [terraform-ibm-secrets-manager](#terraform-ibm-secrets-manager)
* [Examples](./examples)
* [Basic example](./examples/basic)
* [Complete example](./examples/complete)
* [Complete example with BYOK encryption](./examples/complete)
* [Complete example with private only instance and KYOK encryption](./examples/complete-private)
* [Contributing](#contributing)
<!-- END OVERVIEW HOOK -->


<!--
If this repo contains any reference architectures, uncomment the heading below and links to them.
(Usually in the `/reference-architectures` directory.)
See "Reference architecture" in Authoring Guidelines in the public documentation at
https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=reference-architecture
-->
<!-- ## Reference architectures -->


<!-- This heading should always match the name of the root level module (aka the repo name) -->
## terraform-ibm-secrets-manager

### Usage

<!--
Add an example of the use of the module in the following code block.
Use real values instead of "var.<var_name>" or other placeholder values
unless real values don't help users know what to change.
-->

```hcl
provider "ibm" {
ibmcloud_api_key = "XXXXXXXXXXXXXX"
region = "us-south"
}
module "secrets_manager" {
source = "terraform-ibm-modules/secrets-manager/ibm"
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
resource_group_id = "xxXXxxXXxXxXXXXxxXxxxXXXXxXXXXX"
region = "us-south"
secrets_manager_name = "my-secrets-manager"
sm_service_plan = "trial"
service_endpoints = "public-and-private"
}
```

### Required IAM access policies

<!-- PERMISSIONS REQUIRED TO RUN MODULE
If this module requires permissions, uncomment the following block and update
the sample permissions, following the format.
Replace the sample Account and IBM Cloud service names and roles with the
information in the console at
Manage > Access (IAM) > Access groups > Access policies.
-->

<!--
## Required IAM access policies
You need the following permissions to run this module.

- Account Management
- **Sample Account Service** service
- `Editor` platform access
- `Manager` service access
- **Resource Group** service
- `Viewer` platform access
- IAM Services
- **Sample Cloud Service** service
- **Secrets Manager** service
- `Administrator` platform access
-->

<!-- NO PERMISSIONS FOR MODULE
If no permissions are required for the module, uncomment the following
statement instead the previous block.
-->

<!-- No permissions are needed to run this module.-->
- `Manager` service access


<!-- Below content is automatically populated via pre-commit hook -->
Expand All @@ -87,23 +62,45 @@ statement instead the previous block.

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.6.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= v1.0.0, <1.6.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.56.1, < 2.0.0 |
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1, < 1.0.0 |

### Modules

No modules.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_cbr_rule"></a> [cbr\_rule](#module\_cbr\_rule) | terraform-ibm-modules/cbr/ibm//modules/cbr-rule-module | 1.16.0 |

### Resources

No resources.
| Name | Type |
|------|------|
| [ibm_iam_authorization_policy.policy](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
| [ibm_resource_instance.secrets_manager_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |

### Inputs

No inputs.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cbr_rules"></a> [cbr\_rules](#input\_cbr\_rules) | (Optional, list) List of CBR rules to create | <pre>list(object({<br> description = string<br> account_id = string<br> rule_contexts = list(object({<br> attributes = optional(list(object({<br> name = string<br> value = string<br> }))) }))<br> enforcement_mode = string<br> }))</pre> | `[]` | no |
| <a name="input_existing_kms_instance_guid"></a> [existing\_kms\_instance\_guid](#input\_existing\_kms\_instance\_guid) | The GUID of the Hyper Protect Crypto Services or Key Protect instance in which the key specified in `kms_key_crn` is coming from. Required only if `kms_encryption_enabled` is set to true, and `skip_iam_authorization_policy` is set to false. | `string` | `null` | no |
| <a name="input_kms_encryption_enabled"></a> [kms\_encryption\_enabled](#input\_kms\_encryption\_enabled) | Set this to true to control the encryption keys used to encrypt the data that you store in Secrets Manager. If set to false, the data that you store is encrypted at rest by using envelope encryption. For more details, see https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-mng-data&interface=ui#about-encryption. | `bool` | `false` | no |
| <a name="input_kms_key_crn"></a> [kms\_key\_crn](#input\_kms\_key\_crn) | The root key CRN of a Key Management Service like Key Protect or Hyper Protect Crypto Services (HPCS) that you want to use for encryption. Only used if `kms_encryption_enabled` is set to true. | `string` | `null` | no |
| <a name="input_region"></a> [region](#input\_region) | The region to provision the Secrets Manager instance to. | `string` | n/a | yes |
| <a name="input_resource_group_id"></a> [resource\_group\_id](#input\_resource\_group\_id) | The ID of the resource group to provision the Secrets Manager instance to. | `string` | n/a | yes |
| <a name="input_secrets_manager_name"></a> [secrets\_manager\_name](#input\_secrets\_manager\_name) | The name to give the Secrets Manager instance. | `string` | n/a | yes |
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | The types of service endpoints to set on the Secrets Manager instance. Possible values are `public`, `private` or `public-and-private`. | `string` | `"public-and-private"` | no |
| <a name="input_skip_iam_authorization_policy"></a> [skip\_iam\_authorization\_policy](#input\_skip\_iam\_authorization\_policy) | Set to true to skip the creation of an IAM authorization policy that permits all Secrets Manager instances in the resource group to read the encryption key from the KMS instance. If set to false, pass in a value for the KMS instance in the `existing_kms_instance_guid` variable. In addition, no policy is created if `kms_encryption_enabled` is set to false. | `bool` | `false` | no |
| <a name="input_sm_service_plan"></a> [sm\_service\_plan](#input\_sm\_service\_plan) | The Secrets Manager plan to provision. | `string` | `"standard"` | no |
| <a name="input_sm_tags"></a> [sm\_tags](#input\_sm\_tags) | The list of resource tags that you want to associate with your Secrets Manager instance. | `list(string)` | `[]` | no |

### Outputs

No outputs.
| Name | Description |
|------|-------------|
| <a name="output_secrets_manager_guid"></a> [secrets\_manager\_guid](#output\_secrets\_manager\_guid) | GUID of Secrets-Manager instance |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

<!-- Leave this section as is so that your module has a link to local development environment set up steps for contributors to follow -->
Expand Down
2 changes: 1 addition & 1 deletion common-dev-assets
13 changes: 5 additions & 8 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Basic example

<!--
The basic example should call the module(s) stored in this repository with a basic configuration.
Note, there is a pre-commit hook that will take the title of each example and include it in the repos main README.md.
The text below should describe exactly what resources are provisioned / configured by the example.
-->
A simple example that shows how to provision a basic Trial instance of Secrets Manager.

An end-to-end basic example that will provision the following:
- A new resource group if one is not passed in.
- A new Cloud Object Storage instance.
The following resources are provisioned by this example:

- A new resource group, if an existing one is not passed in.
- A Trial instance of Secrets Manager.
22 changes: 7 additions & 15 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
########################################################################################################################
# Resource group
########################################################################################################################

module "resource_group" {
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.1.4"
Expand All @@ -10,15 +6,11 @@ module "resource_group" {
existing_resource_group_name = var.resource_group
}

########################################################################################################################
# COS instance
########################################################################################################################

resource "ibm_resource_instance" "cos_instance" {
name = "${var.prefix}-cos"
resource_group_id = module.resource_group.resource_group_id
service = "cloud-object-storage"
plan = "standard"
location = "global"
tags = var.resource_tags
module "secrets_manager" {
source = "../.."
resource_group_id = module.resource_group.resource_group_id
region = var.region
secrets_manager_name = "${var.prefix}-secrets-manager" #tfsec:ignore:general-secrets-no-plaintext-exposure
sm_service_plan = "trial"
sm_tags = var.resource_tags
}
20 changes: 3 additions & 17 deletions examples/basic/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
########################################################################################################################
# Outputs
########################################################################################################################

output "cos_instance_id" {
description = "COS instance id"
value = ibm_resource_instance.cos_instance.id
}

output "resource_group_name" {
description = "Resource group name"
value = module.resource_group.resource_group_name
}

output "resource_group_id" {
description = "Resource group ID"
value = module.resource_group.resource_group_id
output "secrets_manager_guid" {
value = module.secrets_manager.secrets_manager_guid
description = "GUID of Secrets Manager instance."
}
4 changes: 0 additions & 4 deletions examples/basic/provider.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
########################################################################################################################
# Provider config
########################################################################################################################

provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
Expand Down
20 changes: 8 additions & 12 deletions examples/basic/variables.tf
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
########################################################################################################################
# Input variables
########################################################################################################################

variable "ibmcloud_api_key" {
type = string
description = "The IBM Cloud API Key"
description = "The IBM Cloud API key this account authenticates to"
sensitive = true
}

variable "region" {
variable "prefix" {
type = string
description = "Region to provision all resources created by this example"
default = "us-south"
description = "Prefix for sm instance"
default = "secrets-manager-test"
}

variable "prefix" {
variable "region" {
type = string
description = "Prefix to append to all resources created by this example"
default = "basic"
description = "Region where resources will be created"
default = "us-east"
}

variable "resource_group" {
type = string
description = "The name of an existing resource group to provision resources in to. If not set a new resource group will be created using the prefix variable"
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
default = null
}

Expand Down
6 changes: 3 additions & 3 deletions examples/basic/version.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
terraform {
required_version = ">= 1.3.0, <1.6.0"
required_version = ">= v1.0.0, <1.6.0"

# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
# module's version.tf (usually a basic example), and 1 example that will always use the latest provider version.
# module's version.tf (this example), and 1 example that will always use the latest provider version (complete example).
required_providers {
ibm = {
source = "IBM-Cloud/ibm"
version = "1.49.0"
version = "1.56.1"
}
}
}
5 changes: 5 additions & 0 deletions examples/complete-private/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Complete example with private only instance and KYOK encryption

This examples handles the provisioning of Secrets-Manager instance, the IAM engine configuration in the recently created instance and a context-based restriction (CBR) rule to only allow Secret Manager to be accessible from within the VPC..

Only private service endpoints are enabled, public are disabled. Secrets Manager instances that are private only do not offer a UI management experience.
Loading

0 comments on commit 9931045

Please sign in to comment.