Skip to content

Commit 5c502ec

Browse files
feat: added new FSCloud submodule (#18)
1 parent cbd8348 commit 5c502ec

File tree

17 files changed

+577
-49
lines changed

17 files changed

+577
-49
lines changed

.github/settings.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ repository:
1515
# By changing this field, you rename the repository.
1616

1717
# Uncomment this name property and set the name to the current repo name.
18-
# name: ""
18+
name: "terraform-ibm-icd-rabbitmq"
1919

2020
# The description is displayed under the repository name on the
2121
# organization page and in the 'About' section of the repository.
2222

2323
# Uncomment this description property
2424
# and update the description to the current repo description.
25-
# description: ""
25+
description: "Implements an instance of the IBM Cloud Databases for RabbitMQ."
2626

2727
# Uncomment this topics property
2828
# and add a comma-separated list of topics to set on the repo.
29-
# topics: terraform, ibm-cloud, terraform-module
29+
topics: core-team, terraform, ibm-cloud, terraform-module, ibm-database, icd, icd-rabbitmq, supported, graduated

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ You need the following permissions to run this module.
3939

4040
- [ Basic example](examples/basic)
4141
- [ Complete example with BYOK encryption, CBR rules, autoscaling, and service credentials creation](examples/complete)
42+
- [ Financial Services Cloud profile example with autoscaling enabled](examples/fscloud)
4243
<!-- END EXAMPLES HOOK -->
4344
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4445
### Requirements

cra-config.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
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-
# 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.
7-
# TF_VAR_sample: "sample value"
8-
# TF_VAR_other: "another value"
9-
# 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.
10-
# SCC_REGION: "" # The IBM Cloud region that the SCC instance is in. If not provided, a default global value will be used.
11-
# PROFILE_ID: "" # The Profile ID input for CRA SCC scan. If not provided, a default global value will be used.
4+
- CRA_TARGET: "examples/fscloud"
5+
CRA_IGNORE_RULES_FILE: "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+
CRA_ENVIRONMENT_VARIABLES:
8+
TF_VAR_existing_kms_instance_guid: "e6dce284-e80f-46e1-a3c1-830f7adff7a9"
9+
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"

examples/fscloud/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Financial Services Cloud profile example with autoscaling enabled
2+
3+
An end-to-end example that uses the [Profile for IBM Cloud Framework for Financial Services](../../modules/fscloud/) to deploy an instance of IBM Cloud Databases for RabbitMQ.
4+
5+
The example uses the IBM Cloud Terraform provider to create the following infrastructure:
6+
7+
- A resource group, if one is not passed in.
8+
- An IAM authorization between all RabbitMQ database instances in the given resource group, and the Hyper Protect Crypto Services instance that is passed in.
9+
- An IBM Cloud Databases RabbitMQ database instance that is encrypted with the Hyper Protect Crypto Services root key that is passed in.
10+
- Autoscaling rules for the IBM Cloud Databases RabbitMQ database instance.
11+
- Service Credentials for the RabbitMQ database instance.
12+
- A sample virtual private cloud (VPC).
13+
- A context-based restriction (CBR) rule to only allow RabbitMQ to be accessible from within the VPC.
14+
15+
:exclamation: **Important:** In this example, only the IBM Cloud Databases for RabbitMQ instance complies with the IBM Cloud Framework for Financial Services. Other parts of the infrastructure do not necessarily comply.
16+
17+
## Before you begin
18+
19+
- You need a Hyper Protect Crypto Services instance and root key available in the region that you want to deploy your RabbitMQ database instance to.

examples/fscloud/main.tf

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
##############################################################################
2+
# Resource Group
3+
##############################################################################
4+
5+
module "resource_group" {
6+
source = "terraform-ibm-modules/resource-group/ibm"
7+
version = "1.1.0"
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+
##############################################################################
14+
# Get Cloud Account ID
15+
##############################################################################
16+
17+
data "ibm_iam_account_settings" "iam_account_settings" {
18+
}
19+
20+
##############################################################################
21+
# VPC
22+
##############################################################################
23+
resource "ibm_is_vpc" "example_vpc" {
24+
name = "${var.prefix}-vpc"
25+
resource_group = module.resource_group.resource_group_id
26+
tags = var.resource_tags
27+
}
28+
29+
resource "ibm_is_subnet" "testacc_subnet" {
30+
name = "${var.prefix}-subnet"
31+
vpc = ibm_is_vpc.example_vpc.id
32+
zone = "${var.region}-1"
33+
total_ipv4_address_count = 256
34+
resource_group = module.resource_group.resource_group_id
35+
}
36+
37+
##############################################################################
38+
# Create CBR Zone
39+
##############################################################################
40+
module "cbr_zone" {
41+
source = "terraform-ibm-modules/cbr/ibm//modules/cbr-zone-module"
42+
version = "1.15.1"
43+
name = "${var.prefix}-VPC-network-zone"
44+
zone_description = "CBR Network zone representing VPC"
45+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
46+
addresses = [{
47+
type = "vpc", # to bind a specific vpc to the zone
48+
value = ibm_is_vpc.example_vpc.crn,
49+
}]
50+
}
51+
52+
##############################################################################
53+
# Postgres Instance
54+
##############################################################################
55+
56+
module "rabbitmq_database" {
57+
source = "../../modules/fscloud"
58+
resource_group_id = module.resource_group.resource_group_id
59+
instance_name = "${var.prefix}-rabbitmq"
60+
region = var.region
61+
rabbitmq_version = var.rabbitmq_version
62+
kms_key_crn = var.kms_key_crn
63+
existing_kms_instance_guid = var.existing_kms_instance_guid
64+
service_credential_names = var.service_credential_names
65+
endpoints = var.endpoints
66+
tags = var.tags
67+
access_tags = var.access_tags
68+
auto_scaling = var.auto_scaling
69+
cbr_rules = [
70+
{
71+
description = "${var.prefix}-rabbitmq access only from vpc"
72+
enforcement_mode = "enabled"
73+
account_id = data.ibm_iam_account_settings.iam_account_settings.account_id
74+
rule_contexts = [{
75+
attributes = [
76+
{
77+
"name" : "endpointType",
78+
"value" : "private"
79+
},
80+
{
81+
name = "networkZoneId"
82+
value = module.cbr_zone.zone_id
83+
}]
84+
}]
85+
}
86+
]
87+
}

examples/fscloud/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 = "RabbitMQ instance id"
6+
value = module.rabbitmq_database.id
7+
}
8+
9+
output "guid" {
10+
description = "RabbitMQ instance guid"
11+
value = module.rabbitmq_database.guid
12+
}
13+
14+
output "version" {
15+
description = "RabbitMQ instance version"
16+
value = module.rabbitmq_database.version
17+
}

examples/fscloud/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/fscloud/variables.tf

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 "resource_tags" {
14+
type = list(string)
15+
description = "Optional list of tags to be added to created resources"
16+
default = []
17+
}
18+
19+
variable "prefix" {
20+
type = string
21+
description = "Prefix to append to all resources created by this example"
22+
default = "fs-cloud"
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 "existing_kms_instance_guid" {
32+
description = "The GUID of the Hyper Protect Crypto service in which the key specified in var.kms_key_crn is coming from"
33+
type = string
34+
}
35+
36+
variable "kms_key_crn" {
37+
type = string
38+
description = "The root key CRN of a Hyper Protect Crypto Service (HPCS) that you want to use for disk encryption. See https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs&interface=ui for more information on integrating HPCS with RabbitMQ instance."
39+
}
40+
41+
variable "rabbitmq_version" {
42+
type = string
43+
description = "The version of RabbitMQ to deploy. If no value passed, the current ICD preferred version is used."
44+
default = null
45+
}
46+
47+
variable "auto_scaling" {
48+
type = object({
49+
disk = object({
50+
capacity_enabled = optional(bool, false)
51+
free_space_less_than_percent = optional(number, 10)
52+
io_above_percent = optional(number, 90)
53+
io_enabled = optional(bool, false)
54+
io_over_period = optional(string, "15m")
55+
rate_increase_percent = optional(number, 10)
56+
rate_limit_mb_per_member = optional(number, 3670016)
57+
rate_period_seconds = optional(number, 900)
58+
rate_units = optional(string, "mb")
59+
})
60+
memory = object({
61+
io_above_percent = optional(number, 90)
62+
io_enabled = optional(bool, false)
63+
io_over_period = optional(string, "15m")
64+
rate_increase_percent = optional(number, 10)
65+
rate_limit_mb_per_member = optional(number, 114688)
66+
rate_period_seconds = optional(number, 900)
67+
rate_units = optional(string, "mb")
68+
})
69+
})
70+
description = "Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/messages-for-rabbitmq?topic=messages-for-rabbitmq-autoscaling in the IBM Cloud Docs."
71+
default = null
72+
}
73+
74+
variable "service_credential_names" {
75+
description = "Map of name, role for service credentials that you want to create for the database"
76+
type = map(string)
77+
default = {}
78+
}
79+
80+
variable "endpoints" {
81+
description = "Endpoints available to the database instance (public, private, public-and-private)"
82+
type = string
83+
default = "private"
84+
}
85+
86+
variable "tags" {
87+
type = list(any)
88+
description = "Optional list of tags to be added to the RabbitMQ instance."
89+
default = []
90+
}
91+
92+
variable "access_tags" {
93+
type = list(string)
94+
description = "A list of access tags to apply to the rabbitmq instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
95+
default = []
96+
}

examples/fscloud/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.56.1, <2.0.0"
8+
}
9+
}
10+
}

main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ resource "time_sleep" "wait_for_authorization_policy" {
4242
create_duration = "30s"
4343
}
4444

45-
4645
resource "ibm_database" "rabbitmq_database" {
4746
depends_on = [ibm_iam_authorization_policy.kms_policy]
4847
name = var.instance_name
@@ -88,7 +87,7 @@ resource "ibm_database" "rabbitmq_database" {
8887
}
8988

9089
## This for_each block is NOT a loop to attach to multiple auto_scaling blocks.
91-
## This block is only used to conditionally add auto_scaling block depending on var.auto_scaling
90+
## This block is only used to conditionally add auto_scaling block depending on var.auto_scaling.
9291
dynamic "auto_scaling" {
9392
for_each = local.auto_scaling_enabled
9493
content {

0 commit comments

Comments
 (0)