Skip to content

Commit 116534d

Browse files
feat: added crn parser submodule (#2)
1 parent 2e87789 commit 116534d

30 files changed

+192
-313
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Primary owner should be listed first in list of global owners, followed by any secondary owners
2-
* @SirSpidey @ocofaigh
2+
* @MatthewLemmond @toddgiguere

.github/settings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ repository:
2525
description: "A collection of common utility terraform modules"
2626

2727
# Use a comma-separated list of topics to set on the repo (ensure not to use any caps in the topic string).
28-
topics: terraform, ibm-cloud, terraform-module, core-team
28+
topics: terraform, ibm-cloud, terraform-module, core-team, utilities

README.md

Lines changed: 10 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!-- Update this title with a descriptive name. Use sentence case. -->
2-
# Terraform modules template project
2+
# Terraform IBM common utilities module
33

44
<!--
55
Update status and "latest release" badges:
66
1. For the status options, see https://terraform-ibm-modules.github.io/documentation/#/badge-status
77
2. Update the "latest release" badge to point to the correct module's repo. Replace "terraform-ibm-module-template" in two places.
88
-->
9-
[![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)
10-
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-module-template?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-module-template/releases/latest)
9+
[![Graduated (Supported)](https://img.shields.io/badge/Status-Graduated%20(Supported)-brightgreen)](https://terraform-ibm-modules.github.io/documentation/#/badge-status)
10+
[![latest release](https://img.shields.io/github/v/release/terraform-ibm-modules/terraform-ibm-common-utilities?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-common-utilities/releases/latest)
1111
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
1212
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/)
1313
[![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)
@@ -20,46 +20,22 @@ For information, see "Module names and descriptions" at
2020
https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions
2121
-->
2222

23-
TODO: Replace this with a description of the modules in this repo.
23+
Common Terraform utilities that are used in other modules in the terraform-ibm-modules GitHub organization.
2424

25+
You can reference any utility in this repo from your Terraform project by pointing to the utility in the [modules](./modules) directory. For a list of available submodules, see the Submodules in the [Overview](#overview) section.
2526

2627
<!-- The following content is automatically populated by the pre-commit hook -->
2728
<!-- BEGIN OVERVIEW HOOK -->
2829
## Overview
2930
* [terraform-ibm-common-utilities](#terraform-ibm-common-utilities)
31+
* [Submodules](./modules)
32+
* [crn-parser](./modules/crn-parser)
3033
* [Examples](./examples)
31-
* [Advanced example](./examples/advanced)
32-
* [Basic example](./examples/basic)
34+
* [CRN parser example](./examples/crn-parser)
3335
* [Contributing](#contributing)
3436
<!-- END OVERVIEW HOOK -->
3537

36-
37-
<!--
38-
If this repo contains any reference architectures, uncomment the heading below and link to them.
39-
(Usually in the `/reference-architectures` directory.)
40-
See "Reference architecture" in the public documentation at
41-
https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=reference-architecture
42-
-->
43-
<!-- ## Reference architectures -->
44-
45-
46-
<!-- Replace this heading with the name of the root level module (the repo name) -->
47-
## terraform-ibm-common-utilities
48-
49-
### Usage
50-
51-
<!--
52-
Add an example of the use of the module in the following code block.
53-
54-
Use real values instead of "var.<var_name>" or other placeholder values
55-
unless real values don't help users know what to change.
56-
-->
57-
58-
```hcl
59-
60-
```
61-
62-
### Required IAM access policies
38+
<!-- ### Required IAM access policies -->
6339

6440
<!-- PERMISSIONS REQUIRED TO RUN MODULE
6541
If this module requires permissions, uncomment the following block and update
@@ -86,33 +62,7 @@ If no permissions are required for the module, uncomment the following
8662
statement instead the previous block.
8763
-->
8864

89-
<!-- No permissions are needed to run this module.-->
90-
91-
92-
<!-- The following content is automatically populated by the pre-commit hook -->
93-
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
94-
### Requirements
95-
96-
| Name | Version |
97-
|------|---------|
98-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
99-
100-
### Modules
101-
102-
No modules.
103-
104-
### Resources
105-
106-
No resources.
107-
108-
### Inputs
109-
110-
No inputs.
111-
112-
### Outputs
113-
114-
No outputs.
115-
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
65+
<!-- No permissions are needed to run this module. -->
11666

11767
<!-- Leave this section as is so that your module has a link to local development environment set-up steps for contributors to follow -->
11868
## Contributing

cra-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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/advanced" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
4+
- CRA_TARGET: "examples/crn-parser" # 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`
66
PROFILE_ID: "0e6e7b5a-817d-4344-ab6f-e5d7a9c49520" # SCC profile ID (currently set to the FSCloud 1.4.0 profile).
77
# 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.
88
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
9-
# 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.
10-
# TF_VAR_sample: "sample value"
9+
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.
10+
TF_VAR_crn: "crn:version:cname:ctype:service-name:location:scope:service-instance:resource-type:resource"
1111
# TF_VAR_other: "another value"

examples/advanced/README.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/advanced/main.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/advanced/outputs.tf

Lines changed: 0 additions & 23 deletions
This file was deleted.

examples/advanced/provider.tf

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/advanced/variables.tf

Lines changed: 0 additions & 29 deletions
This file was deleted.

examples/advanced/version.tf

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/basic/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/basic/main.tf

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/basic/outputs.tf

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/basic/variables.tf

Lines changed: 0 additions & 33 deletions
This file was deleted.

examples/basic/version.tf

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/crn-parser/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CRN parser example
2+
3+
This example takes a CRN as the input. The outputs are the segments of the CRN that are parsed by using the CRN parser utility.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
########################################################################################################################
2-
# Outputs
2+
# CRN Parser
33
########################################################################################################################
44

5-
#output "myoutput" {
6-
# description = "Description of my output"
7-
# value = "value"
8-
#}
5+
module "crn_parser" {
6+
source = "../../modules/crn-parser"
7+
crn = var.crn
8+
}

examples/crn-parser/outputs.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
########################################################################################################################
2+
# Outputs
3+
########################################################################################################################
4+
5+
output "parsed_crn_ctype" {
6+
value = module.crn_parser.ctype
7+
description = "The parsed `ctype` field of the Key Protect instance CRN"
8+
}
9+
10+
output "parsed_crn_service_name" {
11+
value = module.crn_parser.service_name
12+
description = "The parsed `service_name` field of the Key Protect instance CRN"
13+
}
14+
15+
output "parsed_crn_region" {
16+
value = module.crn_parser.region
17+
description = "The parsed `region` field of the Key Protect instance CRN"
18+
}
19+
20+
output "parsed_crn_scope" {
21+
value = module.crn_parser.scope
22+
description = "The parsed `scope` field of the Key Protect instance CRN"
23+
}
24+
25+
output "parsed_crn_service_instance" {
26+
value = module.crn_parser.service_instance
27+
description = "The parsed `service_instance` field of the Key Protect instance CRN"
28+
}
29+
30+
output "parsed_crn_resource_type" {
31+
value = module.crn_parser.resource_type
32+
description = "The parsed `resource_type` field of the Key Protect instance CRN"
33+
}
34+
35+
output "parsed_crn_resource" {
36+
value = module.crn_parser.resource
37+
description = "The parsed `resource` field of the Key Protect instance CRN"
38+
}
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
########################################################################################################################
22
# Provider config
33
########################################################################################################################
4-
5-
provider "ibm" {
6-
ibmcloud_api_key = var.ibmcloud_api_key
7-
region = var.region
8-
}

examples/crn-parser/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
########################################################################################################################
2+
# Input variables
3+
########################################################################################################################
4+
5+
variable "crn" {
6+
type = string
7+
description = "The CRN to parse."
8+
}

examples/crn-parser/version.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 1.3.0"
3+
}

0 commit comments

Comments
 (0)