Skip to content

Commit ea3f756

Browse files
Setup ibm-watsonx-saas-da (#4)
* Initial repo population * Update readme * Initial repo population * fix configure_project repo * fix configure_project repo * update architecture diagram * added examples and test * update readme * fixed test * fixed test * updated catalog details * Addressing reviewer comments --------- Co-authored-by: Michele Crudele <michele.crudele@it.ibm.com>
1 parent 55981ca commit ea3f756

35 files changed

+1676
-197
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ terraform.rc
5151

5252
# Visual Studio Code
5353
.vscode/
54+
55+
# venv
56+
venv/*

CHANGELOG.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## 0.3.0
6+
7+
### Added
8+
9+
- Added unit test
10+
11+
### Changed
12+
13+
- Lite plan for COS is not accepted anymore
14+
15+
### Fixed
16+
17+
## 0.2.0
18+
19+
### Added
20+
21+
### Changed
22+
23+
- Replaced custom code to provision a COS instance with https://github.com/terraform-ibm-modules/terraform-ibm-cos/tree/main
24+
25+
### Fixed
26+
27+
- Project URL now redirect to target account
28+
29+
## 0.1.7
30+
31+
### Added
32+
33+
### Changed
34+
35+
### Fixed
36+
37+
- Patch the ML instance in the project configuration if the user deletes and recreated the ML instance
38+
- Fixed force_account_scope account settings
39+
40+
## 0.1.6
41+
42+
### Added
43+
44+
### Changed
45+
46+
### Fixed
47+
48+
- Changed default plan of optional services to "do not install"
49+
50+
## 0.1.5
51+
52+
### Added
53+
54+
### Changed
55+
56+
### Fixed
57+
58+
- Input plans are now null in Projects UI
59+
60+
## 0.1.4
61+
62+
### Added
63+
64+
### Changed
65+
66+
### Fixed
67+
68+
- Outputs of optional services were arrays, now outputs are string agains
69+
70+
## 0.1.3
71+
72+
### Added
73+
74+
- Restrict resources to the current target account
75+
76+
### Changed
77+
78+
- Watson Conversation, Discover, and Governance are now optional services
79+
80+
### Fixed
81+
82+
## 0.1.2
83+
84+
### Added
85+
86+
- Added dashboard URL for the provisioned services
87+
- Add Watson project URL
88+
89+
### Changed
90+
91+
### Fixed
92+
93+
## 0.1.1
94+
95+
### Added
96+
97+
- Project creation in Watson
98+
- User can specify a prefix to use for the resource names
99+
100+
### Changed
101+
102+
### Fixed
103+
104+
- Fixed the plan names
105+
106+
## 0.1.0
107+
108+
### Added
109+
110+
- User is configured in watsonx platform if it is not already configured
111+
112+
### Changed
113+
114+
### Fixed
115+
116+
## 0.0.2
117+
118+
### Added
119+
120+
- New variables to set the plan for each resource
121+
122+
### Changed
123+
124+
### Fixed
125+
126+
## 0.0.1
127+
128+
### Added
129+
130+
- First release
131+
132+
### Changed
133+
134+
### Fixed

README.md

Lines changed: 110 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- Update the title -->
2-
# Terraform Modules Template Project
2+
# Watsonx SaaS Deployable Architecture (DA)
33

44
<!--
55
Update status and "latest release" badges:
@@ -13,8 +13,11 @@ Update status and "latest release" badges:
1313
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
1414

1515
<!-- Add a description of module(s) in this repo -->
16-
TODO: Replace me with description of the module(s) in this repo
17-
16+
The **Watsonx SaaS Deployment Architecture (Watsonx DA)** is designed to automate the deployment and
17+
configuration of the **IBM watsonx** platform in an IBM Cloud Account.
18+
The **IBM watsonx** platform is made of several services working together to offer AI capabilities to end users, who can explore them using [IBM watsonx projects](https://dataplatform.cloud.ibm.com/docs/content/wsj/manage-data/manage-projects.html?context=wx&audience=wdp).
19+
On that purpose, the **Watsonx DA** also
20+
configures a *starter project* for an IBM Cloud user.
1821

1922
<!-- Below content is automatically populated via pre-commit hook -->
2023
<!-- BEGIN OVERVIEW HOOK -->
@@ -37,20 +40,28 @@ https://terraform-ibm-modules.github.io/documentation/#/implementation-guideline
3740

3841

3942
<!-- This heading should always match the name of the root level module (aka the repo name) -->
40-
## terraform-ibm-module-template
43+
## terraform-ibm-watsonx-saas-da
4144

42-
### Usage
45+
The solution supports the following:
4346

44-
<!--
45-
Add an example of the use of the module in the following code block.
47+
- Creating a new resource group, or taking an existing one.
48+
- Provisioning the services
49+
- `Watson Machine Learning`
50+
- `Watson Studio`
51+
- `Cloud Object Storage`.
52+
- Configuring the `IBM watsonx profile` and creating a *starter* `IBM watsonx project`
53+
for an IBM Cloud user, who becomes the `admin` of the `IBM watsonx project` (`IBM watsonx admin` in the following).
4654

47-
Use real values instead of "var.<var_name>" or other placeholder values
48-
unless real values don't help users know what to change.
49-
-->
55+
As result the `IBM watsonx admin` can log into [IBM watsonx](https://dataplatform.cloud.ibm.com/login) in the target account and start experimenting
56+
with the *starter* project.
5057

51-
```hcl
58+
Optionally, the solution supports:
5259

53-
```
60+
- Provisioning of one or more of the services, with a selectable
61+
service plan:
62+
- `watsonx.governance`
63+
- `watsonx Assistant`
64+
- `Watson Discovery`.
5465

5566
### Required IAM access policies
5667

@@ -62,17 +73,29 @@ information in the console at
6273
Manage > Access (IAM) > Access groups > Access policies.
6374
-->
6475

65-
<!--
66-
You need the following permissions to run this module.
67-
68-
- Account Management
69-
- **Sample Account Service** service
70-
- `Editor` platform access
71-
- `Manager` service access
72-
- IAM Services
73-
- **Sample Cloud Service** service
74-
- `Administrator` platform access
75-
-->
76+
You need the following permissions to deploy this solution.
77+
78+
- All Account Management services
79+
- Administrator (only if you must create a new resource group)
80+
- Watson Machine Learning
81+
- Editor platform role (to create and delete the service)
82+
- Watson Studio
83+
- Editor platform role (to create and delete the service)
84+
- Cloud Object Storage
85+
- Editor platform role (to create and delete the service)
86+
- watsonx.governance
87+
- Editor platform role (only if you must provision)
88+
- watsonx Assistant
89+
- Editor platform role (only if you must provision)
90+
- Watson Discovery
91+
- Editor platform role (only if you must provision)
92+
93+
The `IBM watsonx admin` needs the following permissions.
94+
95+
- All Account Management services
96+
- Administrator
97+
- All Identity and Access enabled services
98+
- Administrator
7699

77100
<!-- NO PERMISSIONS FOR MODULE
78101
If no permissions are required for the module, uncomment the following
@@ -88,23 +111,82 @@ statement instead the previous block.
88111

89112
| Name | Version |
90113
|------|---------|
91-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0, <1.7.0 |
114+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.0, <1.7.0 |
115+
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.62.0 |
116+
| <a name="requirement_random"></a> [random](#requirement\_random) | 3.6.0 |
117+
| <a name="requirement_restapi"></a> [restapi](#requirement\_restapi) | >= 1.19.1 |
92118

93119
### Modules
94120

95-
No modules.
121+
| Name | Source | Version |
122+
|------|--------|---------|
123+
| <a name="module_configure_project"></a> [configure\_project](#module\_configure\_project) | ./configure_project | n/a |
124+
| <a name="module_configure_user"></a> [configure\_user](#module\_configure\_user) | ./configure_user | n/a |
125+
| <a name="module_cos"></a> [cos](#module\_cos) | terraform-ibm-modules/cos/ibm//modules/fscloud | 7.5.3 |
126+
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | terraform-ibm-modules/resource-group/ibm | 1.1.5 |
96127

97128
### Resources
98129

99-
No resources.
130+
| Name | Type |
131+
|------|------|
132+
| [ibm_resource_instance.assistant_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
133+
| [ibm_resource_instance.discovery_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
134+
| [ibm_resource_instance.governance_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
135+
| [ibm_resource_instance.machine_learning_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
136+
| [ibm_resource_instance.studio_instance](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/resource_instance) | resource |
137+
| [random_string.unique_identifier](https://registry.terraform.io/providers/hashicorp/random/3.6.0/docs/resources/string) | resource |
138+
| [ibm_iam_auth_token.tokendata](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/iam_auth_token) | data source |
100139

101140
### Inputs
102141

103-
No inputs.
142+
| Name | Description | Type | Default | Required |
143+
|------|-------------|------|---------|:--------:|
144+
| <a name="input_cos_plan"></a> [cos\_plan](#input\_cos\_plan) | Resource plan used to provision the Cloud Object Storage instance. | `string` | `"standard"` | no |
145+
| <a name="input_ibmcloud_api_key"></a> [ibmcloud\_api\_key](#input\_ibmcloud\_api\_key) | Used with the Terraform IBM-Cloud/ibm provider | `string` | n/a | yes |
146+
| <a name="input_location"></a> [location](#input\_location) | Used with the Terraform IBM-Cloud/ibm provider as well as resource creation. | `string` | `"us-south"` | no |
147+
| <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 |
148+
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Name of the watson project to create. | `string` | `"demo"` | no |
149+
| <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 |
150+
| <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 |
151+
| <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 |
152+
| <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 |
153+
| <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 |
154+
| <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 |
155+
| <a name="input_watson_machine_learning_plan"></a> [watson\_machine\_learning\_plan](#input\_watson\_machine\_learning\_plan) | Resource plan used to provision the Watson Machine Learning instance. | `string` | `"lite"` | no |
156+
| <a name="input_watson_studio_plan"></a> [watson\_studio\_plan](#input\_watson\_studio\_plan) | Resource plan used to provision the Watson Studio instance. | `string` | `"free-v1"` | no |
104157

105158
### Outputs
106159

107-
No outputs.
160+
| Name | Description |
161+
|------|-------------|
162+
| <a name="output_project_id"></a> [project\_id](#output\_project\_id) | ID of the created project |
163+
| <a name="output_project_url"></a> [project\_url](#output\_project\_url) | URL of the created project |
164+
| <a name="output_watson_governance_crn"></a> [watson\_governance\_crn](#output\_watson\_governance\_crn) | CRN of the Watson Governance instance |
165+
| <a name="output_watson_governance_dashboard_url"></a> [watson\_governance\_dashboard\_url](#output\_watson\_governance\_dashboard\_url) | Dashboard URL of the Watson Governance instance |
166+
| <a name="output_watson_governance_guid"></a> [watson\_governance\_guid](#output\_watson\_governance\_guid) | GUID of the Watson Governance instance |
167+
| <a name="output_watson_governance_name"></a> [watson\_governance\_name](#output\_watson\_governance\_name) | Name of the Watson Governance instance |
168+
| <a name="output_watson_governance_plan_id"></a> [watson\_governance\_plan\_id](#output\_watson\_governance\_plan\_id) | Plan ID of the Watson Governance instance |
169+
| <a name="output_watson_machine_learning_crn"></a> [watson\_machine\_learning\_crn](#output\_watson\_machine\_learning\_crn) | CRN of the Watson Machine Learning instance |
170+
| <a name="output_watson_machine_learning_dashboard_url"></a> [watson\_machine\_learning\_dashboard\_url](#output\_watson\_machine\_learning\_dashboard\_url) | Dashboard URL of the Watson Machine Learning instance |
171+
| <a name="output_watson_machine_learning_guid"></a> [watson\_machine\_learning\_guid](#output\_watson\_machine\_learning\_guid) | GUID of the Watson Machine Learning instance |
172+
| <a name="output_watson_machine_learning_name"></a> [watson\_machine\_learning\_name](#output\_watson\_machine\_learning\_name) | Name of the Watson Machine Learning instance |
173+
| <a name="output_watson_machine_learning_plan_id"></a> [watson\_machine\_learning\_plan\_id](#output\_watson\_machine\_learning\_plan\_id) | Plan ID of the Watson Machine Learning instance |
174+
| <a name="output_watson_platform_endpoint"></a> [watson\_platform\_endpoint](#output\_watson\_platform\_endpoint) | Endpoint of the Watson platform |
175+
| <a name="output_watson_studio_crn"></a> [watson\_studio\_crn](#output\_watson\_studio\_crn) | CRN of the Watson Studio instance |
176+
| <a name="output_watson_studio_dashboard_url"></a> [watson\_studio\_dashboard\_url](#output\_watson\_studio\_dashboard\_url) | Dashboard URL of the Watson Studio instance |
177+
| <a name="output_watson_studio_guid"></a> [watson\_studio\_guid](#output\_watson\_studio\_guid) | GUID of the Watson Studio instance |
178+
| <a name="output_watson_studio_name"></a> [watson\_studio\_name](#output\_watson\_studio\_name) | Name of the Watson Studio instance |
179+
| <a name="output_watson_studio_plan_id"></a> [watson\_studio\_plan\_id](#output\_watson\_studio\_plan\_id) | Plan ID of the Watson Studio instance |
180+
| <a name="output_watsonx_assistant_crn"></a> [watsonx\_assistant\_crn](#output\_watsonx\_assistant\_crn) | CRN of the WatsonX Assistant instance |
181+
| <a name="output_watsonx_assistant_dashboard_url"></a> [watsonx\_assistant\_dashboard\_url](#output\_watsonx\_assistant\_dashboard\_url) | Dashboard URL of the WatsonX Assistant instance |
182+
| <a name="output_watsonx_assistant_guid"></a> [watsonx\_assistant\_guid](#output\_watsonx\_assistant\_guid) | GUID of the WatsonX Assistant instance |
183+
| <a name="output_watsonx_assistant_name"></a> [watsonx\_assistant\_name](#output\_watsonx\_assistant\_name) | Name of the WatsonX Assistant instance |
184+
| <a name="output_watsonx_assistant_plan_id"></a> [watsonx\_assistant\_plan\_id](#output\_watsonx\_assistant\_plan\_id) | Plan ID of the WatsonX Assistant instance |
185+
| <a name="output_watsonx_discovery_crn"></a> [watsonx\_discovery\_crn](#output\_watsonx\_discovery\_crn) | CRN of the WatsonX Discovery instance |
186+
| <a name="output_watsonx_discovery_dashboard_url"></a> [watsonx\_discovery\_dashboard\_url](#output\_watsonx\_discovery\_dashboard\_url) | Dashboard URL of the WatsonX Discovery instance |
187+
| <a name="output_watsonx_discovery_guid"></a> [watsonx\_discovery\_guid](#output\_watsonx\_discovery\_guid) | GUID of the WatsonX Discovery instance |
188+
| <a name="output_watsonx_discovery_name"></a> [watsonx\_discovery\_name](#output\_watsonx\_discovery\_name) | Name of the WatsonX Discovery instance |
189+
| <a name="output_watsonx_discovery_plan_id"></a> [watsonx\_discovery\_plan\_id](#output\_watsonx\_discovery\_plan\_id) | Plan ID of the WatsonX Discovery instance |
108190
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
109191

110192
<!-- Leave this section as is so that your module has a link to local development environment set up steps for contributors to follow -->

assets/architecture.svg

Lines changed: 1 addition & 0 deletions
Loading

configure_project/data.tf

Whitespace-only changes.

configure_project/main.tf

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
resource "restapi_object" "configure_project" {
2+
count = var.project_name == null ? 0 : 1
3+
path = "//api.dataplatform.cloud.ibm.com"
4+
read_path = "//api.dataplatform.cloud.ibm.com{id}"
5+
read_method = "GET"
6+
create_path = "//api.dataplatform.cloud.ibm.com/transactional/v2/projects?verify_unique_name=true"
7+
create_method = "POST"
8+
id_attribute = "location"
9+
destroy_method = "DELETE"
10+
destroy_path = "//api.dataplatform.cloud.ibm.com/transactional{id}"
11+
data = <<-EOT
12+
{
13+
"name": "${var.project_name}",
14+
"generator": "watsonx-saas-da",
15+
"type": "wx",
16+
"storage": {
17+
"type": "bmcos_object_storage",
18+
"guid": "${var.cos_guid}",
19+
"resource_crn": "${var.cos_crn}"
20+
},
21+
"description": "${var.project_description}",
22+
"public": true,
23+
"tags": ${jsonencode(var.project_tags)},
24+
"compute": [
25+
{
26+
"name": "${var.machine_learning_name}",
27+
"guid": "${var.machine_learning_guid}",
28+
"type": "machine_learning",
29+
"crn": "${var.machine_learning_crn}"
30+
}
31+
]
32+
}
33+
EOT
34+
update_method = "PATCH"
35+
update_path = "//api.dataplatform.cloud.ibm.com{id}"
36+
update_data = <<-EOT
37+
{
38+
"name": "${var.project_name}",
39+
"type": "wx",
40+
"description": "${var.project_description}",
41+
"public": true,
42+
"compute": [
43+
{
44+
"name": "${var.machine_learning_name}",
45+
"guid": "${var.machine_learning_guid}",
46+
"type": "machine_learning",
47+
"crn": "${var.machine_learning_crn}",
48+
"credentials": {}
49+
}
50+
]
51+
}
52+
EOT
53+
}

configure_project/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "project_id" {
2+
value = trim(resource.restapi_object.configure_project[0].id, "/v2/projects/")
3+
description = "ID of the created project"
4+
}

configure_project/provider.tf

Whitespace-only changes.

0 commit comments

Comments
 (0)