Skip to content

Commit 555209a

Browse files
authored
feat: initial release (#46)
1 parent 755a19b commit 555209a

33 files changed

+816
-271
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Primary owner should be listed first in list of global owners, followed by any secondary owners
2+
* @shemau @alex-reiff

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-12-09T07:17:24Z",
6+
"generated_at": "2024-03-06T16:42:37Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

README.md

Lines changed: 131 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,31 @@
77
[![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)
88

99
<!-- Add a description of module(s) in this repo -->
10-
TODO: Replace me with description of the module(s) in this repo
10+
This module configures a public certificates engine for a Secrets Manager instance. For more information about enabling Secrets Manager for public certificates, see [Preparing to order public certificates](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-prepare-order-certificates).
1111

12+
The module handles the following resources:
13+
14+
- [Authorization between Secrets Manager and Cloud Internet Services (CIS)](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-prepare-order-certificates&interface=ui#authorize-cis)
15+
- [CIS DNS](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-prepare-order-certificates&interface=ui#connect-dns-provider) configuration
16+
- [Let's Encrypt certificate authority](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-prepare-order-certificates&interface=ui#connect-certificate-authority) configuration
17+
18+
The two configurations make up the `public_cert` secrets type. This module also signs the intermediate certificate authority (CA) when the engine is created.
19+
## Before you begin
20+
21+
Make sure that you have the following prerequisites:
22+
23+
- An IBM Cloud Internet Services (CIS) instance
24+
- A private key `.pem` file generated by the [ACME account creation tool](https://github.com/ibm-cloud-security/acme-account-creation-tool)
25+
26+
:information_source: **Tip:** The [Secrets Manager module](https://github.com/terraform-ibm-modules/terraform-ibm-secrets-manager) provides automation to create a Secret Manager instance.
1227

1328
<!-- Below content is automatically populated via pre-commit hook -->
1429
<!-- BEGIN OVERVIEW HOOK -->
1530
## Overview
1631
* [terraform-ibm-secrets-manager-public-cert-engine](#terraform-ibm-secrets-manager-public-cert-engine)
1732
* [Examples](./examples)
18-
* [Basic example](./examples/basic)
19-
* [Complete example](./examples/complete)
33+
* [Secrets Manager public certificate engine using API key authentication](./examples/api_key_auth)
34+
* [Secrets Manager public certificate engine using an IBM IAM authorization policy](./examples/iam_auth)
2035
* [Contributing](#contributing)
2136
<!-- END OVERVIEW HOOK -->
2237

@@ -35,45 +50,104 @@ https://terraform-ibm-modules.github.io/documentation/#/implementation-guideline
3550

3651
### Usage
3752

38-
<!--
39-
Add an example of the use of the module in the following code block.
53+
```hcl
54+
# Authentication with IAM policy
55+
module "public_secret_engine" {
56+
source = "terraform-ibm-modules/secrets-manager-public-cert-engine/ibm"
57+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
58+
secrets_manager_guid = "<secrets_manager_instance_id>"
59+
region = "us-south"
60+
dns_config_name = "My DNS Config"
61+
internet_services_crn = "<internet_services_instance_id>"
62+
ca_config_name = "My CA Config"
63+
acme_letsencrypt_private_key = "<acme_letsnecrypt_private_key>" # pragma: allowlist secret
64+
}
65+
66+
# Authentication with API key
67+
module "public_secret_engine" {
68+
source = "terraform-ibm-modules/secrets-manager-public-cert-engine/ibm"
69+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
70+
secrets_manager_guid = "<secrets_manager_instance_id>"
71+
region = "us-south"
72+
dns_config_name = "My DNS Config"
73+
internet_services_crn = "<internet_services_instance_id>"
74+
ca_config_name = "My CA Config"
75+
acme_letsencrypt_private_key = "<acme_letsnecrypt_private_key>" # pragma: allowlist secret
76+
ibmcloud_cis_api_key = "<ibmcloud_api_key>" # pragma: allowlist secret
77+
}
78+
79+
# Authentication with IAM policy, ACME private key stored in Secrets Manager
80+
module "public_secret_engine" {
81+
source = "terraform-ibm-modules/secrets-manager-public-cert-engine/ibm"
82+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
83+
secrets_manager_guid = "<secrets_manager_instance_id>"
84+
region = "us-south"
85+
dns_config_name = "My DNS Config"
86+
internet_services_crn = "<internet_services_instance_id>"
87+
ca_config_name = "My CA Config"
88+
secrets_manager_instance_id = "<my secrets manager instance ID>" # pragma: allowlist secret
89+
secrets_manager_secret_id = "<the secret ID of the private key>" # pragma: allowlist secret
90+
}
91+
92+
# Authentication with API key, ACME private key stored in Secrets Manager
93+
module "public_secret_engine" {
94+
source = "terraform-ibm-modules/secrets-manager-public-cert-engine/ibm"
95+
version = "X.X.X" # Replace "X.X.X" with a release version to lock into a specific release
96+
secrets_manager_guid = "<secrets_manager_instance_id>"
97+
region = "us-south"
98+
dns_config_name = "My DNS Config"
99+
internet_services_crn = "<internet_services_instance_id>"
100+
ca_config_name = "My CA Config"
101+
ibmcloud_cis_api_key = "<ibmcloud_api_key>" # pragma: allowlist secret
102+
secrets_manager_instance_id = "<my secrets manager instance ID>" # pragma: allowlist secret
103+
secrets_manager_secret_id = "<the secret ID of the private key>" # pragma: allowlist secret
104+
}
105+
```
40106

41-
Use real values instead of "var.<var_name>" or other placeholder values
42-
unless real values don't help users know what to change.
43-
-->
107+
Because the ACME Let's Encrypt private key is a multi-line string, you may encounter errors passing it into terraform. You can store it as an arbitrary secret in Secrets Manager which terraform will pull or you can use one of the following methods to provide it through the CLI:
44108

45-
```hcl
109+
### In the .tfvars file:
110+
```
111+
acme_letsencrypt_private_key = <<-EOT # pragma: allowlist secret
112+
-----PRIVATE KEY----- # pragma: allowlist secret
113+
CONTENTS
114+
OFYOUR
115+
PRIVATEKEY
116+
-----END PRIVATE KEY-----
117+
EOT
118+
```
46119

120+
### From the command line:
47121
```
122+
export TF_VAR_acme_letsencrypt_private_key='-----PRIVATE KEY----- # pragma: allowlist secret
123+
CONTENTS
124+
OFYOUR
125+
PRIVATEKEY
126+
-----END PRIVATE KEY-----'
127+
```
128+
This will work with most UNIX-based shells. You may need to change the `'` character depending on your shell.
48129

49-
### Required IAM access policies
130+
### As a variable in Terraform:
131+
```
132+
acme_letsencrypt_private_key = "-----PRIVATE KEY-----\nCONTENTS\nOFYOUR\nPRIVATEKEY\n-----END PRIVATE KEY-----" # pragma: allowlist secret
133+
```
134+
You can replace the new lines in the private key with newline characters `\n`.
50135

51-
<!-- PERMISSIONS REQUIRED TO RUN MODULE
52-
If this module requires permissions, uncomment the following block and update
53-
the sample permissions, following the format.
54-
Replace the sample Account and IBM Cloud service names and roles with the
55-
information in the console at
56-
Manage > Access (IAM) > Access groups > Access policies.
57-
-->
136+
### Required IAM access policies
58137

59-
<!--
60138
You need the following permissions to run this module.
61139

62140
- Account Management
63-
- **Sample Account Service** service
141+
- **IAM Access Groups** service
64142
- `Editor` platform access
143+
- **IAM Identity** service
144+
- `Operator` platform access
145+
- **Resource Group** service
146+
- `Viewer` platform access
147+
- IAM Services
148+
- **Secrets Manager** service
149+
- `Administrator` platform access
65150
- `Manager` service access
66-
- IAM Services
67-
- **Sample Cloud Service** service
68-
- `Administrator` platform access
69-
-->
70-
71-
<!-- NO PERMISSIONS FOR MODULE
72-
If no permissions are required for the module, uncomment the following
73-
statement instead the previous block.
74-
-->
75-
76-
<!-- No permissions are needed to run this module.-->
77151

78152

79153
<!-- Below content is automatically populated via pre-commit hook -->
@@ -83,18 +157,43 @@ statement instead the previous block.
83157
| Name | Version |
84158
|------|---------|
85159
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
160+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.54.0, < 2.0.0 |
161+
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1, < 1.0.0 |
86162

87163
### Modules
88164

89165
No modules.
90166

91167
### Resources
92168

93-
No resources.
169+
| Name | Type |
170+
|------|------|
171+
| [ibm_iam_authorization_policy.cis_service_authorization](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/iam_authorization_policy) | resource |
172+
| [ibm_sm_public_certificate_configuration_ca_lets_encrypt.public_ca_config](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/sm_public_certificate_configuration_ca_lets_encrypt) | resource |
173+
| [ibm_sm_public_certificate_configuration_dns_cis.public_dns_config](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/sm_public_certificate_configuration_dns_cis) | resource |
174+
| [time_sleep.wait_for_authorization_policy](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
175+
| [ibm_iam_account_settings.iam_account_settings](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/iam_account_settings) | data source |
176+
| [ibm_sm_arbitrary_secret.ibm_secrets_manager_secret](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/sm_arbitrary_secret) | data source |
94177

95178
### Inputs
96179

97-
No inputs.
180+
| Name | Description | Type | Default | Required |
181+
|------|-------------|------|---------|:--------:|
182+
| <a name="input_acme_letsencrypt_private_key"></a> [acme\_letsencrypt\_private\_key](#input\_acme\_letsencrypt\_private\_key) | The private key generated by the ACME account creation tool. Required if private\_key\_secrets\_manager\_instance\_guid and private\_key\_secrets\_manager\_secret\_id are not set. | `string` | `null` | no |
183+
| <a name="input_ca_config_name"></a> [ca\_config\_name](#input\_ca\_config\_name) | Name of the CA config for the public\_cert secrets engine | `string` | `null` | no |
184+
| <a name="input_cis_account_id"></a> [cis\_account\_id](#input\_cis\_account\_id) | Account ID of the CIS instance (only needed if different from Secrets Manager account) | `string` | `null` | no |
185+
| <a name="input_dns_config_name"></a> [dns\_config\_name](#input\_dns\_config\_name) | Name of the DNS config for the public\_cert secrets engine | `string` | `null` | no |
186+
| <a name="input_ibmcloud_cis_api_key"></a> [ibmcloud\_cis\_api\_key](#input\_ibmcloud\_cis\_api\_key) | Optional, when not using IAM authorization, use an API key for CIS DNS configuration | `string` | `null` | no |
187+
| <a name="input_internet_service_domain_id"></a> [internet\_service\_domain\_id](#input\_internet\_service\_domain\_id) | (optional) Specific domain in the CIS to authorize Secrets Manager access to. | `string` | `null` | no |
188+
| <a name="input_internet_services_crn"></a> [internet\_services\_crn](#input\_internet\_services\_crn) | CRN of the CIS instance to authorize Secrets Manager against | `string` | `null` | no |
189+
| <a name="input_lets_encrypt_environment"></a> [lets\_encrypt\_environment](#input\_lets\_encrypt\_environment) | Let's Encrtyp environment (staging, production) | `string` | `"production"` | no |
190+
| <a name="input_private_key_secrets_manager_instance_guid"></a> [private\_key\_secrets\_manager\_instance\_guid](#input\_private\_key\_secrets\_manager\_instance\_guid) | The Secrets Manager instance GUID of the Secrets Manager containing your ACME private key. Required if acme\_letsencrypt\_private\_key is not set. | `string` | `null` | no |
191+
| <a name="input_private_key_secrets_manager_region"></a> [private\_key\_secrets\_manager\_region](#input\_private\_key\_secrets\_manager\_region) | The region of the Secrets Manager instance containing your ACME private key. (Only needed if different from the region variable) | `string` | `null` | no |
192+
| <a name="input_private_key_secrets_manager_secret_id"></a> [private\_key\_secrets\_manager\_secret\_id](#input\_private\_key\_secrets\_manager\_secret\_id) | The secret ID of your ACME private key. Required if acme\_letsencrypt\_private\_key is not set. If both are set, this value will be used as the private key. | `string` | `null` | no |
193+
| <a name="input_region"></a> [region](#input\_region) | Region where resources will be created or fetched from | `string` | `"us-south"` | no |
194+
| <a name="input_secrets_manager_guid"></a> [secrets\_manager\_guid](#input\_secrets\_manager\_guid) | GUID of secrets manager instance to create the secret engine in | `string` | n/a | yes |
195+
| <a name="input_service_endpoints"></a> [service\_endpoints](#input\_service\_endpoints) | The service endpoint type to communicate with the provided secrets manager instance. Possible values are `public` or `private` | `string` | `"public"` | no |
196+
| <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 Secrets Manager to create a DNS config in the CIS specified in `internet_services_crn`. WARNING: An authorization policy must exist before a DNS config can be created, OR an API key must be provided in `ibmcloud_cis_api_key` | `bool` | `false` | no |
98197

99198
### Outputs
100199

cra-config.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# More info about this file at https://github.com/terraform-ibm-modules/common-pipeline-assets/blob/main/.github/workflows/terraform-test-pipeline.md#cra-config-yaml
22
version: "v1"
33
CRA_TARGETS:
4-
- CRA_TARGET: "examples/complete" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
4+
- CRA_TARGET: "examples/iam_auth" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
55
CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json" # CRA Ignore file to use. If not provided, it checks the repo root directory for `cra-tf-validate-ignore-rules.json`
6-
PROFILE_ID: "0e6e7b5a-817d-4344-ab6f-e5d7a9c49520" # SCC profile ID (currently set to the FSCloud 1.4.0 profile).
7-
# SCC_INSTANCE_ID: "" # The SCC instance ID to use to download profile for CRA scan. If not provided, a default global value will be used.
8-
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
6+
CRA_ENVIRONMENT_VARIABLES:
7+
TF_VAR_cis_id: "crn:v1:bluemix:public:internet-svcs:global:a/abac0df06b644a9cabc6e44f55b3880e:59aa1a88-ac47-45e4-bd96-2bc778d26ca7::"
8+
TF_VAR_acme_letsencrypt_private_key: "DUMMY VALUE FOR CRA"
99
# CRA_ENVIRONMENT_VARIABLES: # An optional map of environment variables for CRA, where the key is the variable name and value is the value. Useful for providing TF_VARs.
1010
# TF_VAR_sample: "sample value"
1111
# TF_VAR_other: "another value"
12+
# SCC_INSTANCE_ID: "" # The SCC instance ID to use to download profile for CRA scan. If not provided, a default global value will be used.
13+
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
14+
# PROFILE_ID: "" # The Profile ID input for CRA SCC scan. If not provided, a default global value will be used.

examples/api_key_auth/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Secrets Manager public certificate engine using API key authentication
2+
3+
A simple example to set up a Secret Manager public certificate engine which uses an API key for authentication to CIS.
4+
5+
The following resources are provisioned by this example:
6+
7+
- A new resource group, if an existing one is not passed in.
8+
- A Secrets Manager instance.
9+
- A CIS configuration for a (DNS) domain as part of the public certificate engine with an API key.
10+
- A CIS configuration for a certificate authority (CA) as part of the public certificate engine.
11+
- A active public certificate to demonstrate functionality of public certificate engine.
12+
13+
### Before you begin
14+
15+
The CIS instance should own a domain and the public certificate must be for that domain.

0 commit comments

Comments
 (0)