Skip to content

Commit

Permalink
feat: support for deploying in existing resource group (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreainnocenti authored Apr 3, 2024
1 parent b2a2bea commit 0073b9b
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 188 deletions.
11 changes: 11 additions & 0 deletions .catalog-onboard-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: v1
offerings:
- name: deploy-arch-ibm-watsonx-ai-saas
kind: solution
catalog_id: b5c105a0-04ac-4418-ab2a-3696f7f1d96d
offering_id: 268199b0-46f8-4717-83ce-600e292c5361
variations:
- name: standard
mark_ready: true
install_type: fullstack
3 changes: 3 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
}],
["@semantic-release/exec", {
"successCmd": "echo \"SEMVER_VERSION=${nextRelease.version}\" >> $GITHUB_ENV"
}],
["@semantic-release/exec",{
"publishCmd": "./ci/trigger-catalog-onboarding-pipeline.sh --version=v${nextRelease.version}"
}]
]
}
134 changes: 0 additions & 134 deletions CHANGELOG.md

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ statement instead the previous block.
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.0, <1.7.0 |
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.62.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | 3.6.0 |
| <a name="requirement_restapi"></a> [restapi](#requirement\_restapi) | >= 1.19.1 |

### Modules
Expand All @@ -134,7 +133,6 @@ statement instead the previous block.
| [ibm_resource_instance.governance_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
| [ibm_resource_instance.machine_learning_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
| [ibm_resource_instance.studio_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
| [random_string.unique_identifier](https://registry.terraform.io/providers/hashicorp/random/3.6.0/docs/resources/string) | resource |
| [ibm_iam_auth_token.tokendata](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/iam_auth_token) | data source |

### Inputs
Expand All @@ -147,8 +145,9 @@ statement instead the previous block.
| <a name="input_project_description"></a> [project\_description](#input\_project\_description) | Description of the watson project to create. | `string` | `"Watson Project created via watsonx-ai SaaS DA"` | no |
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Name of the watson project to create. | `string` | `"demo"` | no |
| <a name="input_project_tags"></a> [project\_tags](#input\_project\_tags) | Tags to attach to the watson project to create. | `list(string)` | <pre>[<br> "watsonx-ai-SaaS"<br>]</pre> | no |
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | Name of the IBM Cloud resource group in which resources should be created | `string` | `null` | no |
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | The name of a new or an existing resource group in which to provision resources to. | `string` | n/a | yes |
| <a name="input_resource_prefix"></a> [resource\_prefix](#input\_resource\_prefix) | Name to be used on all Watson resource as prefix | `string` | `"watsonx-poc"` | no |
| <a name="input_use_existing_resource_group"></a> [use\_existing\_resource\_group](#input\_use\_existing\_resource\_group) | Whether to use an existing resource group. | `bool` | `false` | no |
| <a name="input_watson_assistant_plan"></a> [watson\_assistant\_plan](#input\_watson\_assistant\_plan) | Resource plan used to provision the watsonx Assistance instance. | `string` | `"do not install"` | no |
| <a name="input_watson_discovery_plan"></a> [watson\_discovery\_plan](#input\_watson\_discovery\_plan) | Resource plan used to provision the Watson Discovery instance. | `string` | `"do not install"` | no |
| <a name="input_watson_governance_plan"></a> [watson\_governance\_plan](#input\_watson\_governance\_plan) | Resource plan used to provision the watsonx Governance instance. | `string` | `"do not install"` | no |
Expand All @@ -161,6 +160,7 @@ statement instead the previous block.
|------|-------------|
| <a name="output_project_id"></a> [project\_id](#output\_project\_id) | ID of the created project |
| <a name="output_project_url"></a> [project\_url](#output\_project\_url) | URL of the created project |
| <a name="output_resource_group_id"></a> [resource\_group\_id](#output\_resource\_group\_id) | ID of the resource group used to provision the resources |
| <a name="output_watson_governance_crn"></a> [watson\_governance\_crn](#output\_watson\_governance\_crn) | CRN of the Watson Governance instance |
| <a name="output_watson_governance_dashboard_url"></a> [watson\_governance\_dashboard\_url](#output\_watson\_governance\_dashboard\_url) | Dashboard URL of the Watson Governance instance |
| <a name="output_watson_governance_guid"></a> [watson\_governance\_guid](#output\_watson\_governance\_guid) | GUID of the Watson Governance instance |
Expand Down
3 changes: 3 additions & 0 deletions catalogValidationValues.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ibmcloud_api_key": $VALIDATION_APIKEY,
}
21 changes: 17 additions & 4 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
locals {
unique_identifier = random_string.unique_identifier.result
}

# Access random string generated with random_string.unique_identifier.result
resource "random_string" "unique_identifier" {
length = 6
special = false
upper = false
}


module "watson_saas" {
source = "../.."
ibmcloud_api_key = var.ibmcloud_api_key
resource_prefix = "example-basic-test"
project_name = "project-basic-test"
source = "../.."
ibmcloud_api_key = var.ibmcloud_api_key
resource_prefix = "example-basic-test"
resource_group_name = local.unique_identifier
project_name = "project-basic-test"
}
4 changes: 4 additions & 0 deletions examples/basic/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ terraform {
source = "IBM-Cloud/ibm"
version = ">= 1.62.0"
}
random = {
source = "hashicorp/random"
version = "3.6.0"
}
}
}
13 changes: 13 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
locals {
unique_identifier = random_string.unique_identifier.result
}

# Access random string generated with random_string.unique_identifier.result
resource "random_string" "unique_identifier" {
length = 6
special = false
upper = false
}


module "watson_saas" {
source = "../.."
ibmcloud_api_key = var.ibmcloud_api_key
resource_group_name = local.unique_identifier
resource_prefix = "example-complete-test"
project_name = "project-complete-test"
watson_discovery_plan = "plus"
Expand Down
4 changes: 4 additions & 0 deletions examples/complete/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ terraform {
source = "IBM-Cloud/ibm"
version = ">= 1.62.0"
}
random = {
source = "hashicorp/random"
version = "3.6.0"
}
}
}
31 changes: 6 additions & 25 deletions ibm_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"products": [
{
"label": "watsonx SaaS",
"name": "watsonx-ai-SaaS",
"version": "0.3.0",
"name": "deploy-arch-ibm-watsonx-ai-saas",
"product_kind": "solution",
"tags": [
"watson",
Expand Down Expand Up @@ -58,9 +57,7 @@
"diagrams": [
{
"diagram": {
"url_proxy": {
"url": "https://github.com/terraform-ibm-modules/terraform-ibm-watsonx-saas-da/blob/main/assets/architecture.svg"
},
"url": "https://raw.githubusercontent.com/terraform-ibm-modules/terraform-ibm-watsonx-saas-da/main/assets/architecture.svg",
"caption": "WatsonX.ai SaaS instances",
"type": "image/svg+xml"
},
Expand Down Expand Up @@ -121,14 +118,6 @@

}
},
{
"key": "resource_group_name",
"type": "string"
},
{
"key": "resource_prefix",
"type": "string"
},
{
"key": "cos_plan",
"type": "string",
Expand Down Expand Up @@ -280,18 +269,6 @@
"custom_config": {

}
},
{
"key": "project_name",
"type": "string"
},
{
"key": "project_description",
"type": "string"
},
{
"key": "project_tags",
"type": "string"
}
],
"outputs": [
Expand Down Expand Up @@ -406,6 +383,10 @@
{
"key": "project_url",
"description": "URL of the Watson project to create"
},
{
"key": "resource_group_id",
"description": "ID of the resource group used to provision the resources"
}
]
}
Expand Down
20 changes: 4 additions & 16 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
locals {
unique_identifier = random_string.unique_identifier.result
}

data "ibm_iam_auth_token" "tokendata" {}

# Access random string generated with random_string.unique_identifier.result
resource "random_string" "unique_identifier" {
length = 6
special = false
upper = false
}

module "resource_group" {
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.1.5"
# If an existing resource group is not set (null), then create a new one
resource_group_name = var.resource_group_name == null ? local.unique_identifier : null
existing_resource_group_name = var.resource_group_name
source = "terraform-ibm-modules/resource-group/ibm"
version = "1.1.5"
resource_group_name = var.use_existing_resource_group == false ? var.resource_group_name : null
existing_resource_group_name = var.use_existing_resource_group == true ? var.resource_group_name : null
}

module "cos" {
Expand Down
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,8 @@ output "project_url" {
value = "https://dataplatform.cloud.ibm.com/projects/${module.configure_project.project_id}?context=wx&sync_account_id=${ibm_resource_instance.machine_learning_instance.account_id}"
description = "URL of the created project"
}

output "resource_group_id" {
value = module.resource_group.resource_group_id
description = "ID of the resource group used to provision the resources"
}
9 changes: 7 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ variable "location" {
}
}

variable "use_existing_resource_group" {
type = bool
description = "Whether to use an existing resource group."
default = false
}

variable "resource_group_name" {
default = null
description = "Name of the IBM Cloud resource group in which resources should be created"
type = string
description = "The name of a new or an existing resource group in which to provision resources to."
}

variable "resource_prefix" {
Expand Down
4 changes: 0 additions & 4 deletions version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ terraform {
source = "IBM-Cloud/ibm"
version = ">= 1.62.0"
}
random = {
source = "hashicorp/random"
version = "3.6.0"
}
restapi = {
source = "Mastercard/restapi"
version = ">= 1.19.1"
Expand Down

0 comments on commit 0073b9b

Please sign in to comment.