diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2b6bb95..0ef97ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,5 +8,5 @@ on: jobs: call-terraform-ci-pipeline: - uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/common-terraform-module-ci-v2.yml@v1.22.1 + uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/common-terraform-module-ci-v2.yml@v1.22.3 secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3bde59..8cd5e62 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,5 +8,5 @@ on: jobs: call-terraform-release-pipeline: - uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/common-release.yml@v1.22.1 + uses: terraform-ibm-modules/common-pipeline-assets/.github/workflows/common-release.yml@v1.22.3 secrets: inherit diff --git a/README.md b/README.md index 9dc38fd..5bcd6f1 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,6 @@ No permissions are needed to run this module. |------|---------| | [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 | | [ibm](#requirement\_ibm) | >= 1.58.1, < 2.0.0 | -| [tls](#requirement\_tls) | >= 4.0.4, < 5.0.0 | ### Modules @@ -63,27 +62,19 @@ No modules. | Name | Type | |------|------| -| [ibm_is_ssh_key.ssh_key](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/is_ssh_key) | resource | -| [ibm_is_vpc.vpc](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/is_vpc) | resource | -| [tls_private_key.tls_key](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) | resource | +| [ibm_resource_group.resource_group](https://registry.terraform.io/providers/ibm-cloud/ibm/latest/docs/resources/resource_group) | resource | ### Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| [classic\_access](#input\_classic\_access) | Enable VPC Classic Access. Note: only one VPC per region can have classic access | `bool` | `false` | no | -| [name](#input\_name) | Name of the SSH Key. | `string` | n/a | yes | -| [resource\_group\_id](#input\_resource\_group\_id) | ID of resource group. If not specified, Default resource group used. | `string` | `null` | no | -| [tags](#input\_tags) | List of Tags for the SSH Key. | `list(string)` | `[]` | no | +| [resource\_group\_names](#input\_resource\_group\_names) | List of resource group names to be created. | `list(string)` | `[]` | no | ### Outputs | Name | Description | |------|-------------| -| [fingerprint](#output\_fingerprint) | SSH key Fingerprint info | -| [ssh\_key\_id](#output\_ssh\_key\_id) | The ID of the ssh key | -| [vpc\_crn](#output\_vpc\_crn) | CRN of VPC created | -| [vpc\_id](#output\_vpc\_id) | ID of VPC created | +| [resource\_group](#output\_resource\_group) | Resource Group Names | diff --git a/common-dev-assets b/common-dev-assets index 2015ae9..247369d 160000 --- a/common-dev-assets +++ b/common-dev-assets @@ -1 +1 @@ -Subproject commit 2015ae9933bef5947865c5251e49009bfd06e66c +Subproject commit 247369df3a2cb75981553d7895ed2b4d651d5aed diff --git a/examples/basic/catalogValidationValues.json.template b/examples/basic/catalogValidationValues.json.template index f89a1d5..0a521fd 100644 --- a/examples/basic/catalogValidationValues.json.template +++ b/examples/basic/catalogValidationValues.json.template @@ -1 +1,6 @@ -{"ibmcloud_api_key": $VALIDATION_APIKEY, "resource_group": $RG_NAME, "resource_tags": $TAGS, "prefix": $PREFIX} +{ + "ibmcloud_api_key": $VALIDATION_APIKEY, + "resource_group": $RG_NAME, + "resource_tags": $TAGS, + "prefix": $PREFIX +} diff --git a/examples/complete/catalogValidationValues.json.template b/examples/complete/catalogValidationValues.json.template index f89a1d5..0a521fd 100644 --- a/examples/complete/catalogValidationValues.json.template +++ b/examples/complete/catalogValidationValues.json.template @@ -1 +1,6 @@ -{"ibmcloud_api_key": $VALIDATION_APIKEY, "resource_group": $RG_NAME, "resource_tags": $TAGS, "prefix": $PREFIX} +{ + "ibmcloud_api_key": $VALIDATION_APIKEY, + "resource_group": $RG_NAME, + "resource_tags": $TAGS, + "prefix": $PREFIX +} diff --git a/ibm_catalog.json b/ibm_catalog.json index f5e39e1..fe4e56e 100644 --- a/ibm_catalog.json +++ b/ibm_catalog.json @@ -203,20 +203,6 @@ } ] }, - "configuration": [ - { - "custom_config": { - "config_constraints": { - "generationType": "2" - }, - "grouping": "deployment", - "original_grouping": "deployment", - "type": "vpc_region" - }, - "key": "region", - "required": true - } - ], "iam_permissions": [ { "role_crns": [ diff --git a/main.tf b/main.tf index ae91e5e..3c22631 100644 --- a/main.tf +++ b/main.tf @@ -1,25 +1,14 @@ -# Create RSA key of size 4096 bits -resource "tls_private_key" "tls_key" { - algorithm = "RSA" - rsa_bits = 4096 +locals { + rg_map = { + for rg in var.resource_group_names : + "${rg}-rg" => { + name = rg + } + } + tags = var.tags != null ? join(",", var.tags) : "none" } - -# Import SSH key to IBM Cloud -resource "ibm_is_ssh_key" "ssh_key" { - name = var.name - resource_group = var.resource_group_id - public_key = resource.tls_private_key.tls_key.public_key_openssh - tags = var.tags -} - -# Create a VPC -resource "ibm_is_vpc" "vpc" { - name = "${var.name}-vpc" - resource_group = var.resource_group_id - classic_access = var.classic_access - default_network_acl_name = "${var.name}-edge-acl" - default_security_group_name = "${var.name}-default-sg" - default_routing_table_name = "${var.name}-default-table" - address_prefix_management = "manual" - tags = var.tags +resource "ibm_resource_group" "resource_group" { + for_each = local.rg_map + name = each.value.name + quota_id = null } diff --git a/outputs.tf b/outputs.tf index 2bfeb3f..ab36e9a 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,19 +1,7 @@ -output "ssh_key_id" { - description = "The ID of the ssh key" - value = ibm_is_ssh_key.ssh_key.id -} - -output "fingerprint" { - description = "SSH key Fingerprint info" - value = ibm_is_ssh_key.ssh_key.fingerprint -} - -output "vpc_id" { - description = "ID of VPC created" - value = ibm_is_vpc.vpc.id -} - -output "vpc_crn" { - description = "CRN of VPC created" - value = ibm_is_vpc.vpc.crn +output "resource_group" { + description = "Resource Group Names" + value = [ + for rg_names in ibm_resource_group.resource_group : + rg_names.id + ] } diff --git a/solutions/mock-da-extension/catalogValidationValues.json.template b/solutions/mock-da-extension/catalogValidationValues.json.template index f89a1d5..0a521fd 100644 --- a/solutions/mock-da-extension/catalogValidationValues.json.template +++ b/solutions/mock-da-extension/catalogValidationValues.json.template @@ -1 +1,6 @@ -{"ibmcloud_api_key": $VALIDATION_APIKEY, "resource_group": $RG_NAME, "resource_tags": $TAGS, "prefix": $PREFIX} +{ + "ibmcloud_api_key": $VALIDATION_APIKEY, + "resource_group": $RG_NAME, + "resource_tags": $TAGS, + "prefix": $PREFIX +} diff --git a/solutions/mock-da-extension/version.tf b/solutions/mock-da-extension/version.tf index 77f5438..39d40c5 100644 --- a/solutions/mock-da-extension/version.tf +++ b/solutions/mock-da-extension/version.tf @@ -3,7 +3,7 @@ terraform { required_providers { ibm = { source = "IBM-Cloud/ibm" - version = ">= 1.65.1" + version = ">= 1.66.0" } } } diff --git a/solutions/mock-da-quickstart/catalogValidationValues.json.template b/solutions/mock-da-quickstart/catalogValidationValues.json.template index f89a1d5..0a521fd 100644 --- a/solutions/mock-da-quickstart/catalogValidationValues.json.template +++ b/solutions/mock-da-quickstart/catalogValidationValues.json.template @@ -1 +1,6 @@ -{"ibmcloud_api_key": $VALIDATION_APIKEY, "resource_group": $RG_NAME, "resource_tags": $TAGS, "prefix": $PREFIX} +{ + "ibmcloud_api_key": $VALIDATION_APIKEY, + "resource_group": $RG_NAME, + "resource_tags": $TAGS, + "prefix": $PREFIX +} diff --git a/solutions/mock-da-quickstart/version.tf b/solutions/mock-da-quickstart/version.tf index 77f5438..39d40c5 100644 --- a/solutions/mock-da-quickstart/version.tf +++ b/solutions/mock-da-quickstart/version.tf @@ -3,7 +3,7 @@ terraform { required_providers { ibm = { source = "IBM-Cloud/ibm" - version = ">= 1.65.1" + version = ">= 1.66.0" } } } diff --git a/solutions/mock-da/catalogValidationValues.json.template b/solutions/mock-da/catalogValidationValues.json.template index f89a1d5..f48a7e3 100644 --- a/solutions/mock-da/catalogValidationValues.json.template +++ b/solutions/mock-da/catalogValidationValues.json.template @@ -1 +1,3 @@ -{"ibmcloud_api_key": $VALIDATION_APIKEY, "resource_group": $RG_NAME, "resource_tags": $TAGS, "prefix": $PREFIX} +{ + "ibmcloud_api_key": $VALIDATION_APIKEY +} diff --git a/solutions/mock-da/main.tf b/solutions/mock-da/main.tf index 4eb443f..5e6aa80 100644 --- a/solutions/mock-da/main.tf +++ b/solutions/mock-da/main.tf @@ -1,30 +1,9 @@ -############################################################################## -# Resource Group -# (if var.resource_group is null, create a new RG using var.prefix) -############################################################################## - -resource "ibm_resource_group" "resource_group" { - count = var.resource_group != null ? 0 : 1 - name = "${var.prefix}-rg" - quota_id = null -} - -data "ibm_resource_group" "existing_resource_group" { - count = var.resource_group != null ? 1 : 0 - name = var.resource_group -} - -locals { - resource_group_id = var.resource_group != null ? data.ibm_resource_group.existing_resource_group[0].id : ibm_resource_group.resource_group[0].id -} - ############################################################################# -# Call root level module to create SSH key +# Call root level module ############################################################################# module "mock_module" { - source = "../.." - name = var.prefix - resource_group_id = local.resource_group_id - tags = var.resource_tags + source = "../.." + resource_group_names = var.resource_group_names + tags = var.tags } diff --git a/solutions/mock-da/outputs.tf b/solutions/mock-da/outputs.tf index 95d5439..a01156c 100644 --- a/solutions/mock-da/outputs.tf +++ b/solutions/mock-da/outputs.tf @@ -2,37 +2,7 @@ # Outputs ############################################################################## -output "ssh_key_id" { - description = "The ID of the ssh key" - value = module.mock_module.ssh_key_id -} - -output "fingerprint" { - description = "SSH key Fingerprint info" - value = module.mock_module.fingerprint -} - -output "test" { - description = "test" - value = var.testing -} - -output "vpc_id" { - description = "ID of VPC created" - value = module.mock_module.vpc_id -} - -output "vpc_crn" { - description = "CRN of VPC created" - value = module.mock_module.vpc_crn -} - output "resource_group" { - description = "Resource Group Name" - value = var.resource_group != null ? var.resource_group : "${var.prefix}-rg" -} - -output "resource_group_id" { - description = "Resource Group ID" - value = var.resource_group != null ? data.ibm_resource_group.existing_resource_group[0].id : ibm_resource_group.resource_group[0].id + description = "Resource Group Names" + value = module.mock_module.resource_group } diff --git a/solutions/mock-da/variables.tf b/solutions/mock-da/variables.tf index 31fac44..2477b0d 100644 --- a/solutions/mock-da/variables.tf +++ b/solutions/mock-da/variables.tf @@ -10,26 +10,14 @@ variable "region" { default = "us-south" } -variable "prefix" { - type = string - description = "Prefix to append to all resources created by this example" - default = "mock" -} - -variable "resource_group" { - type = string - description = "An existing resource group name to use for this example, if unset a new resource group will be created" - default = null +variable "resource_group_names" { + type = list(string) + description = "List of resource group names to be created." + default = ["mock1", "mock2"] } -variable "resource_tags" { +variable "tags" { type = list(string) description = "Optional list of tags to be added to created resources" default = [] } - -variable "testing" { - type = list(string) - description = "Test variable to test setting list of strings to null" - default = null -} diff --git a/solutions/mock-da/version.tf b/solutions/mock-da/version.tf index 77f5438..39d40c5 100644 --- a/solutions/mock-da/version.tf +++ b/solutions/mock-da/version.tf @@ -3,7 +3,7 @@ terraform { required_providers { ibm = { source = "IBM-Cloud/ibm" - version = ">= 1.65.1" + version = ">= 1.66.0" } } } diff --git a/tests/go.mod b/tests/go.mod index 55514ce..ad47a33 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -6,7 +6,7 @@ toolchain go1.22.3 require ( github.com/stretchr/testify v1.9.0 - github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.31.8 + github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.34.1 ) require ( @@ -16,7 +16,7 @@ require ( cloud.google.com/go/iam v1.1.1 // indirect cloud.google.com/go/storage v1.30.1 // indirect dario.cat/mergo v1.0.0 // indirect - github.com/IBM-Cloud/bluemix-go v0.0.0-20240402122236-5c5b994a3f1a // indirect + github.com/IBM-Cloud/bluemix-go v0.0.0-20240423071914-9e96525baef4 // indirect github.com/IBM-Cloud/power-go-client v1.6.0 // indirect github.com/IBM/cloud-databases-go-sdk v0.7.0 // indirect github.com/IBM/go-sdk-core/v5 v5.17.2 // indirect diff --git a/tests/go.sum b/tests/go.sum index 9c41e7a..35990f2 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -189,8 +189,8 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/IBM-Cloud/bluemix-go v0.0.0-20240402122236-5c5b994a3f1a h1:s/KeK5F3xm3xGeqXzCtqMl3nvqQ2my4N5ppxAD+cShY= -github.com/IBM-Cloud/bluemix-go v0.0.0-20240402122236-5c5b994a3f1a/go.mod h1:/7hMjdZA6fEpd/dQAOEABxKEwN0t72P3PlpEDu0Y7bE= +github.com/IBM-Cloud/bluemix-go v0.0.0-20240423071914-9e96525baef4 h1:43l8CU5cW4pOea10+jWtqRJj/4F4Ghfn6Oc82jB9RhM= +github.com/IBM-Cloud/bluemix-go v0.0.0-20240423071914-9e96525baef4/go.mod h1:/7hMjdZA6fEpd/dQAOEABxKEwN0t72P3PlpEDu0Y7bE= github.com/IBM-Cloud/power-go-client v1.6.0 h1:X+QX+WSF66+aouyaf4r+IeBLXUurAJj9+Bd+vH7G5I0= github.com/IBM-Cloud/power-go-client v1.6.0/go.mod h1:0ad5Lcq1utoYVJx0uqooMjCpUaYaK0ItP9QJYtY6k0Y= github.com/IBM/cloud-databases-go-sdk v0.7.0 h1:prvLebKD1kcIk81D6yRhOr/TWp1VQJGLhGAasQr7RtA= @@ -606,8 +606,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.31.8 h1:tphVylXH3w/IQ/3BQcMdnOApxpbBiVrXuhP1YQ5DyAY= -github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.31.8/go.mod h1:6kBsZGhfJEV5L0lOJI+e1jzj8D2E+eltAYZFmYw3Q9s= +github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.34.1 h1:hw5Pivm1fbjpbloEjRcM68178DdAGguwJCF6ZD8UhWs= +github.com/terraform-ibm-modules/ibmcloud-terratest-wrapper v1.34.1/go.mod h1:2fA+HDax1ZxE6o9qR1331MT67nRC/WVYgxpVLyB/ovw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmccombs/hcl2json v0.5.0 h1:cT2sXStOzKL06c8ZTf9vh+0N8GKGzV7+9RUaY5/iUP8= github.com/tmccombs/hcl2json v0.5.0/go.mod h1:B0ZpBthAKbQur6yZRKrtaqDmYLCvgnwHOBApE0faCpU= diff --git a/variables.tf b/variables.tf index 8822412..ed34087 100644 --- a/variables.tf +++ b/variables.tf @@ -1,12 +1,7 @@ -variable "name" { - description = "Name of the SSH Key." - type = string -} - -variable "resource_group_id" { - description = "ID of resource group. If not specified, Default resource group used." - type = string - default = null +variable "resource_group_names" { + type = list(string) + description = "List of resource group names to be created." + default = [] } variable "tags" { @@ -14,13 +9,3 @@ variable "tags" { type = list(string) default = [] } - -############################################################################# -# VPC Variables -############################################################################## - -variable "classic_access" { - description = "Enable VPC Classic Access. Note: only one VPC per region can have classic access" - type = bool - default = false -} diff --git a/version.tf b/version.tf index 5ab5b2c..4ca7f47 100644 --- a/version.tf +++ b/version.tf @@ -5,9 +5,5 @@ terraform { source = "ibm-cloud/ibm" version = ">= 1.58.1, < 2.0.0" } - tls = { - source = "hashicorp/tls" - version = ">= 4.0.4, < 5.0.0" - } } }