Skip to content

Commit 82bd85c

Browse files
authored
feat: module template refactor (#587)
1 parent d7f778c commit 82bd85c

35 files changed

+94
-129
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ terraform.rc
4040
# Ignore .tfsec
4141
.tfsec/
4242

43-
# Ignore brew lock
44-
Brewfile.lock.json
45-
4643
# Ignore Mac files
4744
.DS_Store
4845

.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-06-03T04:41:19Z",
6+
"generated_at": "2023-06-03T04:42:19Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Follow this process to create and submit a Terraform module.
3535
1. Create a repository from this repository template by clicking `Use this template` in the upper right of the GitHub UI.
3636
&emsp;&emsp;&emsp;&emsp;<br>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).
3737
1. Select `terraform-ibm-modules` as the owner.
38-
1. Enter a name for the module in format `terraform-ibm-<NAME>`, where `<NAME>` reflects the type of infrastructure that the module manages.
38+
1. Enter a name for the module in format `terraform-ibm-<name>`, where `<name>` reflects the type of infrastructure that the module manages.
3939
&emsp;&emsp;&emsp;&emsp;<br>Use hyphens as delimiters for names with multiple words (for example, terraform-ibm-`activity-tracker`).
4040
1. Provide a short description of the module.
4141
&emsp;&emsp;&emsp;&emsp;<br>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.
@@ -79,8 +79,6 @@ After you implement the logic for your module and create examples and tests, upd
7979

8080
After the first PR for your module is merged, follow these post-merge steps:
8181

82-
1. Create a PR to enable the upgrade test by removing the `t.Skip` line in `tests/pr_test.go`.
83-
8482
<!-- Remove the content in this previous H2 heading -->
8583
## Reference architectures
8684

@@ -136,16 +134,15 @@ statement instead the previous block.
136134
<!-- BEGIN EXAMPLES HOOK -->
137135
## Examples
138136

139-
- [ Default example](examples/default)
140-
- [ Example that uses existing resources](examples/existing-resources)
141-
- [ Non default example](examples/non-default)
137+
- [ Basic example](examples/basic)
138+
- [ Complete example](examples/complete)
142139
<!-- END EXAMPLES HOOK -->
143140
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
144141
## Requirements
145142

146143
| Name | Version |
147144
|------|---------|
148-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
145+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3, < 1.6 |
149146

150147
## Modules
151148

common-dev-assets

Submodule common-dev-assets updated 37 files

cra-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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/default" # Target directory for CRA scan. If not provided, the CRA Scan will not be run.
4+
- CRA_TARGET: "examples/basic" # 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
# 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.
77
# TF_VAR_sample: "sample value"

examples/basic/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Basic example
2+
3+
<!-- There is a pre-commit hook that will take the title of each example add include it in the repos main README.md -->
4+
<!-- The text below should describe exactly what resources are provisioned / configured by the example -->
5+
6+
An end-to-end basic example that will provision the following:
7+
- A new resource group if one is not passed in.
8+
- A new Cloud Object Storage instance.
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
##############################################################################
2-
# Resource Group
2+
# Resource group
33
##############################################################################
44

55
module "resource_group" {
6-
source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-resource-group.git?ref=v1.0.5"
6+
source = "terraform-ibm-modules/resource-group/ibm"
7+
version = "1.0.5"
78
# if an existing resource group is not set (null) create a new one using prefix
89
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
910
existing_resource_group_name = var.resource_group
1011
}
1112

13+
##############################################################################
14+
# COS instance
15+
##############################################################################
16+
1217
resource "ibm_resource_instance" "cos_instance" {
1318
name = "${var.prefix}-cos"
1419
resource_group_id = module.resource_group.resource_group_id
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
##############################################################################
2-
# Outputs
2+
# Provider config
33
##############################################################################
44

5-
output "vpc_id" {
6-
description = "ID of the existing VPC"
7-
value = data.ibm_is_vpc.example.id
5+
provider "ibm" {
6+
ibmcloud_api_key = var.ibmcloud_api_key
7+
region = var.region
88
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
##############################################################################
2+
# Input variables
3+
##############################################################################
4+
15
variable "ibmcloud_api_key" {
26
type = string
37
description = "The IBM Cloud API Key"
@@ -13,12 +17,12 @@ variable "region" {
1317
variable "prefix" {
1418
type = string
1519
description = "Prefix to append to all resources created by this example"
16-
default = "terraform"
20+
default = "basic"
1721
}
1822

1923
variable "resource_group" {
2024
type = string
21-
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
25+
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"
2226
default = null
2327
}
2428

0 commit comments

Comments
 (0)