Skip to content

feat: add crn parser submodule #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Primary owner should be listed first in list of global owners, followed by any secondary owners
* @SirSpidey @ocofaigh
* @MatthewLemmond @toddgiguere
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ repository:
description: "A collection of common utility terraform modules"

# 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, core-team
topics: terraform, ibm-cloud, terraform-module, core-team, utilities
70 changes: 10 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Update this title with a descriptive name. Use sentence case. -->
# Terraform modules template project
# Terraform IBM common utilities module

<!--
Update status and "latest release" badges:
1. For the status options, see https://terraform-ibm-modules.github.io/documentation/#/badge-status
2. Update the "latest release" badge to point to the correct module's repo. Replace "terraform-ibm-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)
[![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)
[![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-common-utilities?logo=GitHub&sort=semver)](https://github.com/terraform-ibm-modules/terraform-ibm-common-utilities/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)
Expand All @@ -20,46 +20,22 @@ For information, see "Module names and descriptions" at
https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions
-->

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

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.

<!-- The following content is automatically populated by the pre-commit hook -->
<!-- BEGIN OVERVIEW HOOK -->
## Overview
* [terraform-ibm-common-utilities](#terraform-ibm-common-utilities)
* [Submodules](./modules)
* [crn-parser](./modules/crn-parser)
* [Examples](./examples)
* [Advanced example](./examples/advanced)
* [Basic example](./examples/basic)
* [CRN parser example](./examples/crn-parser)
* [Contributing](#contributing)
<!-- END OVERVIEW HOOK -->


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


<!-- Replace this heading with the name of the root level module (the repo name) -->
## terraform-ibm-common-utilities

### 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

```

### Required IAM access policies
<!-- ### Required IAM access policies -->

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

<!-- No permissions are needed to run this module.-->


<!-- The following content is automatically populated by the pre-commit hook -->
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
### Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |

### Modules

No modules.

### Resources

No resources.

### Inputs

No inputs.

### Outputs

No outputs.
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- No permissions are needed to run this module. -->

<!-- Leave this section as is so that your module has a link to local development environment set-up steps for contributors to follow -->
## Contributing
Expand Down
6 changes: 3 additions & 3 deletions cra-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,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
version: "v1"
CRA_TARGETS:
- CRA_TARGET: "examples/advanced" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
- CRA_TARGET: "examples/crn-parser" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
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`
PROFILE_ID: "0e6e7b5a-817d-4344-ab6f-e5d7a9c49520" # SCC profile ID (currently set to the FSCloud 1.4.0 profile).
# 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.
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
# 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.
# TF_VAR_sample: "sample value"
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.
TF_VAR_crn: "crn:version:cname:ctype:service-name:location:scope:service-instance:resource-type:resource"
# TF_VAR_other: "another value"
4 changes: 0 additions & 4 deletions examples/advanced/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions examples/advanced/main.tf

This file was deleted.

23 changes: 0 additions & 23 deletions examples/advanced/outputs.tf

This file was deleted.

8 changes: 0 additions & 8 deletions examples/advanced/provider.tf

This file was deleted.

29 changes: 0 additions & 29 deletions examples/advanced/variables.tf

This file was deleted.

12 changes: 0 additions & 12 deletions examples/advanced/version.tf

This file was deleted.

11 changes: 0 additions & 11 deletions examples/basic/README.md

This file was deleted.

24 changes: 0 additions & 24 deletions examples/basic/main.tf

This file was deleted.

18 changes: 0 additions & 18 deletions examples/basic/outputs.tf

This file was deleted.

33 changes: 0 additions & 33 deletions examples/basic/variables.tf

This file was deleted.

12 changes: 0 additions & 12 deletions examples/basic/version.tf

This file was deleted.

3 changes: 3 additions & 0 deletions examples/crn-parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CRN parser example

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.
10 changes: 5 additions & 5 deletions outputs.tf → examples/crn-parser/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
########################################################################################################################
# Outputs
# CRN Parser
########################################################################################################################

#output "myoutput" {
# description = "Description of my output"
# value = "value"
#}
module "crn_parser" {
source = "../../modules/crn-parser"
crn = var.crn
}
38 changes: 38 additions & 0 deletions examples/crn-parser/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
########################################################################################################################
# Outputs
########################################################################################################################

output "parsed_crn_ctype" {
value = module.crn_parser.ctype
description = "The parsed `ctype` field of the Key Protect instance CRN"
}

output "parsed_crn_service_name" {
value = module.crn_parser.service_name
description = "The parsed `service_name` field of the Key Protect instance CRN"
}

output "parsed_crn_region" {
value = module.crn_parser.region
description = "The parsed `region` field of the Key Protect instance CRN"
}

output "parsed_crn_scope" {
value = module.crn_parser.scope
description = "The parsed `scope` field of the Key Protect instance CRN"
}

output "parsed_crn_service_instance" {
value = module.crn_parser.service_instance
description = "The parsed `service_instance` field of the Key Protect instance CRN"
}

output "parsed_crn_resource_type" {
value = module.crn_parser.resource_type
description = "The parsed `resource_type` field of the Key Protect instance CRN"
}

output "parsed_crn_resource" {
value = module.crn_parser.resource
description = "The parsed `resource` field of the Key Protect instance CRN"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
########################################################################################################################
# Provider config
########################################################################################################################

provider "ibm" {
ibmcloud_api_key = var.ibmcloud_api_key
region = var.region
}
8 changes: 8 additions & 0 deletions examples/crn-parser/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
########################################################################################################################
# Input variables
########################################################################################################################

variable "crn" {
type = string
description = "The CRN to parse."
}
3 changes: 3 additions & 0 deletions examples/crn-parser/version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 1.3.0"
}
Loading