Skip to content

Commit b2d5f78

Browse files
authored
feat: initial creation of module (#6)
1 parent cc49c3c commit b2d5f78

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1939
-166
lines changed

.secrets.baseline

Lines changed: 13 additions & 2 deletions
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-09T06:39:44Z",
6+
"generated_at": "2024-01-19T16:07:13Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -76,7 +76,18 @@
7676
"name": "TwilioKeyDetector"
7777
}
7878
],
79-
"results": {},
79+
"results": {
80+
"README.md": [
81+
{
82+
"hashed_secret": "ff9ee043d85595eb255c05dfe32ece02a53efbb2",
83+
"is_secret": false,
84+
"is_verified": false,
85+
"line_number": 53,
86+
"type": "Secret Keyword",
87+
"verified_result": null
88+
}
89+
]
90+
},
8091
"version": "0.13.1+ibm.62.dss",
8192
"word_list": {
8293
"file": null,

README.md

Lines changed: 83 additions & 37 deletions
Large diffs are not rendered by default.

cra-config.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
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.
5-
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.
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"
11-
# TF_VAR_other: "another value"
4+
- CRA_TARGET: "examples/fscloud"
5+
CRA_IGNORE_RULES_FILE: "cra-tf-validate-ignore-rules.json"
6+
PROFILE_ID: "0e6e7b5a-817d-4344-ab6f-e5d7a9c49520"
7+
CRA_ENVIRONMENT_VARIABLES:
8+
TF_VAR_existing_at_instance_crn: "crn:v1:bluemix:public:logdnaat:eu-de:a/abac0df06b644a9cabc6e44f55b3880e:b1ef3365-dfbf-4d8f-8ac8-75f4f84d6f4a::"
9+
TF_VAR_existing_kms_instance_guid: "e6dce284-e80f-46e1-a3c1-830f7adff7a9"
10+
TF_VAR_kms_key_crn: "crn:v1:bluemix:public:hs-crypto:us-south:a/abac0df06b644a9cabc6e44f55b3880e:e6dce284-e80f-46e1-a3c1-830f7adff7a9:key:76170fae-4e0c-48c3-8ebe-326059ebb533"

cra-tf-validate-ignore-rules.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
{
2-
"scc_rules": []
2+
"scc_rules": [
3+
{
4+
"scc_rule_id": "rule-216e2449-27d7-4afc-929a-b66e196a9cf9",
5+
"description": "Check whether Flow Logs for VPC are enabled",
6+
"ignore_reason": "This rule is not relevant to the module itself, just the VPC resource is used in the example that is scanned",
7+
"is_valid": false
8+
}
9+
]
310
}

examples/backup/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Restore from backup example
2+
3+
This example provides an end-to-end executable flow of how a MySQL DB can be created from a backup instance. This example uses the IBM Cloud terraform provider to:
4+
5+
- Create a new resource group if one is not passed in.
6+
- Create a new ICD MySQL database instance if no existing backup crn is provided.
7+
- Create a restored ICD MySQL database instance pointing to the backup of the first instance.

examples/backup/main.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
##############################################################################
2+
# Resource Group
3+
##############################################################################
4+
5+
module "resource_group" {
6+
source = "terraform-ibm-modules/resource-group/ibm"
7+
version = "1.1.4"
8+
# if an existing resource group is not set (null) create a new one using prefix
9+
resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null
10+
existing_resource_group_name = var.resource_group
11+
}
12+
13+
module "mysql_db" {
14+
count = var.mysql_db_backup_crn != null ? 0 : 1
15+
source = "../.."
16+
resource_group_id = module.resource_group.resource_group_id
17+
name = "${var.prefix}-mysql"
18+
mysql_version = var.mysql_version
19+
region = var.region
20+
resource_tags = var.resource_tags
21+
access_tags = var.access_tags
22+
}
23+
24+
data "ibm_database_backups" "backup_database" {
25+
count = var.mysql_db_backup_crn != null ? 0 : 1
26+
deployment_id = module.mysql_db[0].id
27+
}
28+
29+
# New mysql instance pointing to the backup instance
30+
module "restored_mysql_db" {
31+
source = "../.."
32+
resource_group_id = module.resource_group.resource_group_id
33+
name = "${var.prefix}-mysql-restored"
34+
mysql_version = var.mysql_version
35+
region = var.region
36+
resource_tags = var.resource_tags
37+
access_tags = var.access_tags
38+
backup_crn = var.mysql_db_backup_crn == null ? data.ibm_database_backups.backup_database[0].backups[0].backup_id : var.mysql_db_backup_crn
39+
}

examples/backup/outputs.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
##############################################################################
2+
# Outputs
3+
##############################################################################
4+
output "id" {
5+
description = "MySQL instance id"
6+
value = var.mysql_db_backup_crn == null ? module.mysql_db[0].id : null
7+
}
8+
9+
output "restored_mysql_db_id" {
10+
description = "Restored MySQL instance id"
11+
value = module.restored_mysql_db.id
12+
}
13+
14+
output "restored_mysql_db_version" {
15+
description = "Restored MySQL instance version"
16+
value = module.restored_mysql_db.version
17+
}

examples/backup/provider.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
provider "ibm" {
2+
ibmcloud_api_key = var.ibmcloud_api_key
3+
region = var.region
4+
}

examples/backup/variables.tf

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
variable "ibmcloud_api_key" {
2+
type = string
3+
description = "The IBM Cloud API Key"
4+
sensitive = true
5+
}
6+
7+
variable "region" {
8+
type = string
9+
description = "Region to provision all resources created by this example."
10+
default = "us-south"
11+
}
12+
13+
variable "prefix" {
14+
type = string
15+
description = "Prefix to append to all resources created by this example"
16+
default = "mysql-res"
17+
}
18+
19+
variable "mysql_version" {
20+
description = "Version of the MySQL instance. If no value passed, the current ICD preferred version is used."
21+
type = string
22+
default = null
23+
}
24+
25+
variable "resource_group" {
26+
type = string
27+
description = "An existing resource group name to use for this example, if unset a new resource group will be created"
28+
default = null
29+
}
30+
31+
variable "resource_tags" {
32+
type = list(string)
33+
description = "Optional list of tags to be added to created resources"
34+
default = []
35+
}
36+
37+
variable "access_tags" {
38+
type = list(string)
39+
description = "A list of access tags to apply to the MySQL instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
40+
default = []
41+
}
42+
43+
variable "mysql_db_backup_crn" {
44+
type = string
45+
description = "The existing CRN of a backup resource to restore from. If null then it will create a new instance first and then create another instance pointing to the backup of the first instance."
46+
default = null
47+
}

examples/backup/version.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
terraform {
2+
required_version = ">= 1.3.0, <1.6.0"
3+
required_providers {
4+
# Use latest version of provider in non-basic examples to verify latest version works with module
5+
ibm = {
6+
source = "IBM-Cloud/ibm"
7+
version = ">= 1.61.0"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)