From 14a6c3a839c71afb55e7656fafafc4cb63f7a5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conall=20=C3=93=20Cofaigh?= Date: Tue, 15 Aug 2023 11:48:33 +0100 Subject: [PATCH] feat: mod template cleanup (#619) --- README.md | 117 ++++++++---------------------------- common-dev-assets | 2 +- cra-config.yaml | 8 +-- examples/basic/README.md | 7 ++- examples/basic/main.tf | 8 +-- examples/basic/outputs.tf | 4 +- examples/basic/provider.tf | 4 +- examples/basic/variables.tf | 4 +- outputs.tf | 4 +- tests/README.md | 3 - variables.tf | 4 +- version.tf | 3 +- 12 files changed, 51 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index cf7bea95..db78b651 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,30 @@ - - - + # Terraform Modules Template Project - + + [![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) -[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![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) +[![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) + + + + + + + + + ## Overview * [terraform-ibm-module-template](#terraform-ibm-module-template) @@ -19,88 +36,6 @@ ## terraform-ibm-module-template - - -## Submit a new module - -:+1::tada: Thank you for taking the time to contribute! :tada::+1: - -This template repository exists to help you create Terraform modules for IBM Cloud. - -The default structure includes the following files: - -- `README.md`: A description of the module -- `main.tf`: The logic for the module -- `version.tf`: The required terraform and provider versions -- `variables.tf`: The input variables for the module -- `outputs.tf`: The values that are output from the module - -Use nested modules to split complex behavior into smaller modules that advanced users can choose from. Put nested modules under a `/modules` subdirectory. If you include more than one nested module, make the submodules [composable](https://developer.hashicorp.com/terraform/language/modules/develop/composition) by the caller. In other words, don't embed calls between submodules to create a deeply nested tree of modules. -For more information, see [Module structure](https://terraform-ibm-modules.github.io/documentation/#/module-structure) in the project documentation. - -You can add other content to support what your module does and how it works. For example, you might add a `scripts/` directory that contains shell scripts that are run by a `local-exec` `null_resource` in the Terraform module. - -Follow this process to create and submit a Terraform module. - -### Create a repo from this repo template - -1. Create a repository from this repository template by clicking `Use this template` in the upper right of the GitHub UI. -    
For more information about creating a repository from a template, see the [GitHub docs](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template). -1. Select `terraform-ibm-modules` as the owner. -1. Enter a name for the module in format `terraform-ibm-`, where `` reflects the type of infrastructure that the module manages. -    
Use hyphens as delimiters for names with multiple words (for example, terraform-ibm-`activity-tracker`). -1. Provide a short description of the module. -    
The description is displayed under the repository name on the [organization page](https://github.com/terraform-ibm-modules) and in the **About** section of the repository. Use the description to help users understand the purpose of your module. For more information, see [module names and descriptions](https://terraform-ibm-modules.github.io/documentation/#/implementation-guidelines?id=module-names-and-descriptions) in the docs. - -### Clone the repo and set up your development environment - -Locally clone the new repository and set up your development environment by completing the tasks in [Local development setup](https://terraform-ibm-modules.github.io/documentation/#/local-dev-setup) in the project documentation. - -### Update the repo name and description in source control - -To help make sure that the repo name and description are not changed except through pull requests, they are defined in the `settings.yml` file. - -Check to make sure that values are uncommented and correct: - -1. Open the [settings.yml](.github/settings.yml) file. -1. If not already updated, uncomment the `name` and `description` properties and set the values to what you specified when you requested the repo. - -### Update the Terraform files - -Implement the logic for your module by updating the `main.tf`, `version.tf`, `variables.tf`, and `outputs.tf` Terraform files. For more information, see [Creating Terraform on IBM Cloud templates](https://cloud.ibm.com/docs/ibm-cloud-provider-for-terraform?topic=ibm-cloud-provider-for-terraform-create-tf-config). - -### Create examples and tests - -Add one or more examples in the `examples` directory that consume your new module, and configure tests for them in the `tests` directory. For more information about tests, see [Tests](https://terraform-ibm-modules.github.io/documentation/#/tests). - -### Update the content in the readme file - -After you implement the logic for your module and create examples and tests, update this readme file in your repository by following these steps: - -1. Update the title heading and add a description about your module. -1. Update the badge links. -1. Remove all the content in this H2 heading section. -1. Complete the [Usage](#usage) and [Required IAM access policies](#required-iam-access-policies) sections. The [Examples](#examples) and [Requirements](#requirements) section are populated by a pre-commit hook. - -### Commit your code and submit your module for review - -1. Before you commit any code, review [Contributing to the IBM Cloud Terraform modules project](https://terraform-ibm-modules.github.io/documentation/#/contribute-module) in the project documentation. -1. Create a pull request for review. - -### Post-merge steps - -After the first PR for your module is merged, follow these post-merge steps: - - -### Reference architectures - - - ### Usage - + + + ### Requirements @@ -167,13 +104,9 @@ No inputs. No outputs. - - ## Contributing You can report issues and request features for this module in GitHub issues in the module repo. See [Report an issue or request a feature](https://github.com/terraform-ibm-modules/.github/blob/main/.github/SUPPORT.md). To set up your local development environment, see [Local development setup](https://terraform-ibm-modules.github.io/documentation/#/local-dev-setup) in the project documentation. - - diff --git a/common-dev-assets b/common-dev-assets index 14ccabd2..fdcae25d 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit 14ccabd232cf35a6542ba1b1de8ef42836b59212 +Subproject commit fdcae25d56cd6532c17343ae44d16d5cb69112f9 diff --git a/cra-config.yaml b/cra-config.yaml index f38e457d..9f49af96 100644 --- a/cra-config.yaml +++ b/cra-config.yaml @@ -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/basic" # Target directory for CRA scan. If not provided, the CRA Scan will not be run. + - CRA_TARGET: "examples/complete" # 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" # TF_VAR_other: "another value" - # 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. - # PROFILE_ID: "" # The Profile ID input for CRA SCC scan. If not provided, a default global value will be used. diff --git a/examples/basic/README.md b/examples/basic/README.md index 31e62c6a..86eab8eb 100644 --- a/examples/basic/README.md +++ b/examples/basic/README.md @@ -1,7 +1,10 @@ # Basic example - - + An end-to-end basic example that will provision the following: - A new resource group if one is not passed in. diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 494457ec..a2fffc7e 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -1,6 +1,6 @@ -############################################################################## +######################################################################################################################## # Resource group -############################################################################## +######################################################################################################################## module "resource_group" { source = "terraform-ibm-modules/resource-group/ibm" @@ -10,9 +10,9 @@ module "resource_group" { existing_resource_group_name = var.resource_group } -############################################################################## +######################################################################################################################## # COS instance -############################################################################## +######################################################################################################################## resource "ibm_resource_instance" "cos_instance" { name = "${var.prefix}-cos" diff --git a/examples/basic/outputs.tf b/examples/basic/outputs.tf index 9ed62737..04b196e9 100644 --- a/examples/basic/outputs.tf +++ b/examples/basic/outputs.tf @@ -1,6 +1,6 @@ -############################################################################## +######################################################################################################################## # Outputs -############################################################################## +######################################################################################################################## output "cos_instance_id" { description = "COS instance id" diff --git a/examples/basic/provider.tf b/examples/basic/provider.tf index 2080946b..84b69850 100644 --- a/examples/basic/provider.tf +++ b/examples/basic/provider.tf @@ -1,6 +1,6 @@ -############################################################################## +######################################################################################################################## # Provider config -############################################################################## +######################################################################################################################## provider "ibm" { ibmcloud_api_key = var.ibmcloud_api_key diff --git a/examples/basic/variables.tf b/examples/basic/variables.tf index 48ab01ea..dd0d0af9 100644 --- a/examples/basic/variables.tf +++ b/examples/basic/variables.tf @@ -1,6 +1,6 @@ -############################################################################## +######################################################################################################################## # Input variables -############################################################################## +######################################################################################################################## variable "ibmcloud_api_key" { type = string diff --git a/outputs.tf b/outputs.tf index 4b614c7f..bb6ea662 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,6 +1,6 @@ -############################################################################## +######################################################################################################################## # Outputs -############################################################################## +######################################################################################################################## #output "myoutput" { # description = "Description of my output" diff --git a/tests/README.md b/tests/README.md index 581aa046..dfd68426 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,8 +1,5 @@ - - # Tests For information about how to create and run tests, see [Validation tests](https://terraform-ibm-modules.github.io/documentation/#/tests) in the project documentation. - diff --git a/variables.tf b/variables.tf index d9583df7..df604346 100644 --- a/variables.tf +++ b/variables.tf @@ -1,6 +1,6 @@ -############################################################################## +######################################################################################################################## # Input Variables -############################################################################## +######################################################################################################################## #variable "my_variable" { # type = string diff --git a/version.tf b/version.tf index abbe099a..e213bb0a 100644 --- a/version.tf +++ b/version.tf @@ -1,7 +1,8 @@ terraform { required_version = ">= 1.3.0" + # If your module requires any terraform providers, uncomment the "required_providers" section below and add all required providers. + # Each required provider's version should be a flexible range to future proof the module's usage with upcoming minor and patch versions. - # Use a flexible range in modules that future proofs the module's usage with upcoming minor and patch versions # required_providers { # ibm = { # source = "IBM-Cloud/ibm"