From fa9b52fec97dbf8a70dea45c811bb63fcb9320de Mon Sep 17 00:00:00 2001 From: Riccardo Angelilli Date: Thu, 28 Dec 2023 06:40:29 +0100 Subject: [PATCH 1/7] Regenerate projects provider based off the latest go sdk (#5003) * new version * new version * new version * update code to the latest SDK level * fix integration tests * fix integration tests * fix integration tests * fix integration tests * address PR comment * typo * typo * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * add wait for create and delete * add wait for create and delete * . * fix integration tests * fix integration tests * fix integration tests * fix integration tests * fix integration tests * regenerate * new code generation * new generated code * point to latest sdk * point to latest sdk * adjust test cases and doc * adjust samples * update to latest node sdk * merge with master * Update project_instance.html.markdown Fixing formatting issues * Update project_event_notification.html.markdown * Update README.md * Update variables.tf * Update project_event_notification.html.markdown * new version * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * terraform * feat: projects graph fragment pattern * align with origin/master * update test cases * restore README.md and versions.tf to master branch * remove duplicated entries * feat: graph fragment pattern poc * feat: restore definition blocks * regenerate the terraform code based on latest YAML * regenerate the terraform code based on latest YAML * regenerate the terraform code based on latest YAML * update doc * update doc * fix test cases * commit generated code * commit fix * commit fix * test cases * test cases * test cases * test cases * updates * upgrade to latest go sdk * update generated doc * update generated code * updated secrets baseline * update code to latest API changes * secrets * fix secrets * update samples with real values * update secrets * update secrets * update generated code to the latest API definition * update secrets baseline * merge with master * merge with master * merge with master * update code to the latest SDK level * address some review comments * address PR comments * address PR comments * update to latest sdk level * update to latest sdk level * update to latest sdk level * merge with master * update to the latest sdk level * format test case * regenerate the code with generator fixes * regenerate code * fix "inputs" and "settings" properties * regenerated doc and samples * fix samples * terraform * terraform * terraform * terraform * terraform --------- Co-authored-by: dvesperini Co-authored-by: knee-na <130502432+knee-na@users.noreply.github.com> Co-authored-by: Mark-Kulube --- .secrets.baseline | 34 +- examples/ibm-project/README.md | 213 ++++++-- examples/ibm-project/main.tf | 4 +- examples/ibm-project/variables.tf | 10 +- go.mod | 2 +- go.sum | 4 +- .../project/data_source_ibm_project.go | 17 + .../project/data_source_ibm_project_config.go | 242 +++++++-- .../data_source_ibm_project_config_test.go | 2 +- .../data_source_ibm_project_environment.go | 9 + ...ata_source_ibm_project_environment_test.go | 1 + .../project/data_source_ibm_project_test.go | 1 + ibm/service/project/resource_ibm_project.go | 207 +++++++- .../project/resource_ibm_project_config.go | 499 +++++++++++++++--- .../resource_ibm_project_environment.go | 20 +- website/docs/d/project.html.markdown | 7 +- website/docs/d/project_config.html.markdown | 11 +- .../docs/d/project_environment.html.markdown | 3 + website/docs/r/project.html.markdown | 6 +- website/docs/r/project_config.html.markdown | 14 +- .../docs/r/project_environment.html.markdown | 2 + 21 files changed, 1085 insertions(+), 223 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index cb30966a3b..13208250a4 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-12-14T01:01:48Z", + "generated_at": "2023-12-20T09:37:58Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -760,7 +760,7 @@ "hashed_secret": "731438016c5ab94431f61820f35e3ae5f8ad6004", "is_secret": false, "is_verified": false, - "line_number": 426, + "line_number": 428, "type": "Secret Keyword", "verified_result": null }, @@ -768,7 +768,7 @@ "hashed_secret": "12da2e35d6b50c902c014f1ab9e3032650368df7", "is_secret": false, "is_verified": false, - "line_number": 432, + "line_number": 434, "type": "Secret Keyword", "verified_result": null }, @@ -776,7 +776,7 @@ "hashed_secret": "813274ccae5b6b509379ab56982d862f7b5969b6", "is_secret": false, "is_verified": false, - "line_number": 1143, + "line_number": 1157, "type": "Base64 High Entropy String", "verified_result": null } @@ -2056,7 +2056,7 @@ "hashed_secret": "deab23f996709b4e3d14e5499d1cc2de677bfaa8", "is_secret": false, "is_verified": false, - "line_number": 1367, + "line_number": 1372, "type": "Secret Keyword", "verified_result": null }, @@ -2064,7 +2064,7 @@ "hashed_secret": "20a25bac21219ffff1904bde871ded4027eca2f8", "is_secret": false, "is_verified": false, - "line_number": 1957, + "line_number": 1962, "type": "Secret Keyword", "verified_result": null }, @@ -2072,7 +2072,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 1976, + "line_number": 1981, "type": "Secret Keyword", "verified_result": null }, @@ -2080,7 +2080,7 @@ "hashed_secret": "1f5e25be9b575e9f5d39c82dfd1d9f4d73f1975c", "is_secret": false, "is_verified": false, - "line_number": 2189, + "line_number": 2194, "type": "Secret Keyword", "verified_result": null } @@ -2900,7 +2900,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 335, + "line_number": 342, "type": "Secret Keyword", "verified_result": null }, @@ -2908,7 +2908,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 663, + "line_number": 700, "type": "Secret Keyword", "verified_result": null } @@ -2928,7 +2928,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 120, + "line_number": 125, "type": "Secret Keyword", "verified_result": null }, @@ -2936,7 +2936,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 298, + "line_number": 307, "type": "Secret Keyword", "verified_result": null } @@ -2946,7 +2946,7 @@ "hashed_secret": "347cd9c53ff77d41a7b22aa56c7b4efaf54658e3", "is_secret": false, "is_verified": false, - "line_number": 55, + "line_number": 56, "type": "Secret Keyword", "verified_result": null } @@ -2956,7 +2956,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 237, + "line_number": 236, "type": "Secret Keyword", "verified_result": null }, @@ -2964,7 +2964,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 875, + "line_number": 1091, "type": "Secret Keyword", "verified_result": null } @@ -2992,7 +2992,7 @@ "hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd", "is_secret": false, "is_verified": false, - "line_number": 499, + "line_number": 509, "type": "Secret Keyword", "verified_result": null } @@ -5034,7 +5034,7 @@ } ] }, - "version": "0.13.1+ibm.51.dss", + "version": "0.13.1+ibm.61.dss", "word_list": { "file": null, "hash": null diff --git a/examples/ibm-project/README.md b/examples/ibm-project/README.md index 479c92419c..51bef0de0e 100644 --- a/examples/ibm-project/README.md +++ b/examples/ibm-project/README.md @@ -1,12 +1,16 @@ -# Example for ProjectV1 +# Examples for Projects API -This example illustrates how to use the ProjectV1 +These examples illustrate how to use the resources and data sources associated with Projects API. -The following types of resources are supported: +The following resources are supported: +* ibm_project_config +* ibm_project +* ibm_project_environment -* project_config -* project -* project_environment +The following data sources are supported: +* ibm_project_config +* ibm_project +* ibm_project_environment ## Usage @@ -20,61 +24,200 @@ $ terraform apply Run `terraform destroy` when you don't need these resources. +## Projects API resources -## ProjectV1 resources - -project_config resource: +### Resource: ibm_project_config ```hcl -resource "project_config" "project_config_instance" { - project_id = ibm_project.project_instance.project_id +resource "ibm_project_config" "project_config_instance" { + project_id = ibm_project.project_instance.id definition = var.project_config_definition } ``` -project resource: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| project_id | The unique project ID. | `string` | true | +| schematics | A schematics workspace associated to a project configuration, with scripts. | `` | false | +| definition | | `` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| version | The version of the configuration. | +| is_draft | The flag that indicates whether the version of the configuration is draft, or active. | +| needs_attention_state | The needs attention state of a configuration. | +| created_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| modified_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| last_saved_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| outputs | The outputs of a Schematics template property. | +| project | The project referenced by this resource. | +| state | The state of the configuration. | +| update_available | The flag that indicates whether a configuration update is available. | +| href | A URL. | +| project_config_id | The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. | + +### Resource: ibm_project ```hcl -resource "project" "project_instance" { +resource "ibm_project" "project_instance" { location = var.project_location resource_group = var.project_resource_group definition = var.project_definition } ``` -project_environment resource: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| location | The IBM Cloud location where a resource is deployed. | `string` | true | +| resource_group | The resource group name where the project's data and tools are created. | `string` | true | +| definition | The definition of the project. | `` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| crn | An IBM Cloud resource name, which uniquely identifies a resource. | +| created_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| cumulative_needs_attention_view | The cumulative list of needs attention items for a project. If the view is successfully retrieved, an array which could be empty is returned. | +| cumulative_needs_attention_view_error | True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. | +| resource_group_id | The resource group id where the project's data and tools are created. | +| state | The project status value. | +| href | A URL. | +| event_notifications_crn | The CRN of the event notifications instance if one is connected to this project. | +| configs | The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. | +| environments | The project environments. These environments are only included in the response if project environments were created on the project. | + +### Resource: ibm_project_environment ```hcl -resource "project_environment" "project_environment_instance" { - project_id = ibm_project.project_instance.project_id +resource "ibm_project_environment" "project_environment_instance" { + project_id = ibm_project.project_instance.id definition = var.project_environment_definition } ``` -## ProjectV1 data sources +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| project_id | The unique project ID. | `string` | true | +| definition | The environment definition. | `` | true | -project_config data source: +#### Outputs + +| Name | Description | +|------|-------------| +| project | The project referenced by this resource. | +| created_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| target_account | The target account ID derived from the authentication block values. | +| modified_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| href | A URL. | +| project_environment_id | The environment id as a friendly name. | + +## Projects API data sources + +### Data source: ibm_project_config ```hcl -data "project_config" "project_config_instance" { +data "ibm_project_config" "project_config_instance" { project_id = ibm_project.project_instance.id project_config_id = ibm_project_config.project_config_instance.project_config_id } ``` -project data source: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| project_id | The unique project ID. | `string` | true | +| project_config_id | The unique config ID. | `string` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| version | The version of the configuration. | +| is_draft | The flag that indicates whether the version of the configuration is draft, or active. | +| needs_attention_state | The needs attention state of a configuration. | +| created_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| modified_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| last_saved_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| outputs | The outputs of a Schematics template property. | +| project | The project referenced by this resource. | +| schematics | A schematics workspace associated to a project configuration, with scripts. | +| state | The state of the configuration. | +| update_available | The flag that indicates whether a configuration update is available. | +| href | A URL. | +| definition | | + +### Data source: ibm_project ```hcl -data "project" "project_instance" { +data "ibm_project" "project_instance" { project_id = ibm_project.project_instance.id } ``` -project_environment data source: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| project_id | The unique project ID. | `string` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| crn | An IBM Cloud resource name, which uniquely identifies a resource. | +| created_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| cumulative_needs_attention_view | The cumulative list of needs attention items for a project. If the view is successfully retrieved, an array which could be empty is returned. | +| cumulative_needs_attention_view_error | True indicates that the fetch of the needs attention items failed. It only exists if there was an error while retrieving the cumulative needs attention view. | +| location | The IBM Cloud location where a resource is deployed. | +| resource_group_id | The resource group id where the project's data and tools are created. | +| state | The project status value. | +| href | A URL. | +| resource_group | The resource group name where the project's data and tools are created. | +| event_notifications_crn | The CRN of the event notifications instance if one is connected to this project. | +| configs | The project configurations. These configurations are only included in the response of creating a project if a configs array is specified in the request payload. | +| environments | The project environments. These environments are only included in the response if project environments were created on the project. | +| definition | The definition of the project. | + +### Data source: ibm_project_environment ```hcl -data "project_environment" "project_environment_instance" { +data "ibm_project_environment" "project_environment_instance" { project_id = ibm_project.project_instance.id project_environment_id = ibm_project_environment.project_environment_instance.project_environment_id } ``` +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| project_id | The unique project ID. | `string` | true | +| project_environment_id | The environment ID. | `string` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| project | The project referenced by this resource. | +| created_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| target_account | The target account ID derived from the authentication block values. | +| modified_at | A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. | +| href | A URL. | +| definition | The environment definition. | + ## Assumptions 1. TODO @@ -94,27 +237,3 @@ data "project_environment" "project_environment_instance" { | Name | Version | |------|---------| | ibm | 1.13.1 | - -## Inputs - -| Name | Description | Type | Required | -|------|-------------|------|---------| -| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | -| project_id | The unique project ID. | `string` | true | -| schematics | A schematics workspace associated to a project configuration, with scripts. | `` | false | -| definition | The name and description of a project configuration. | `` | true | -| location | The IBM Cloud location where a resource is deployed. | `string` | true | -| resource_group | The resource group name where the project's data and tools are created. | `string` | true | -| definition | The definition of the project. | `` | true | -| definition | The environment definition. | `` | true | -| project_id | The unique project ID. | `string` | true | -| project_config_id | The unique config ID. | `string` | true | -| project_environment_id | The environment ID. | `string` | true | - -## Outputs - -| Name | Description | -|------|-------------| -| project_config | project_config object | -| project | project object | -| project_environment | project_environment object | diff --git a/examples/ibm-project/main.tf b/examples/ibm-project/main.tf index f07c03de9e..99f42bbc15 100644 --- a/examples/ibm-project/main.tf +++ b/examples/ibm-project/main.tf @@ -14,7 +14,7 @@ resource "ibm_project_config" "project_config_instance" { } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" inputs = { - name = "app_repo_name" + app_repo_name = "static-website-repo" } } } @@ -45,7 +45,7 @@ resource "ibm_project_environment" "project_environment_instance" { // Create project_config data source data "ibm_project_config" "project_config_instance" { - project_id = ibm_project_config.project_config_instance.project_id + project_id = ibm_project.project_instance.id project_config_id = ibm_project_config.project_config_instance.project_config_id } diff --git a/examples/ibm-project/variables.tf b/examples/ibm-project/variables.tf index 82c28185f4..6ddd1b127b 100644 --- a/examples/ibm-project/variables.tf +++ b/examples/ibm-project/variables.tf @@ -30,31 +30,31 @@ variable "project_environment_project_id" { } // Data source arguments for project_config -variable "project_config_project_id" { +variable "data_project_config_project_id" { description = "The unique project ID." type = string default = "project_id" } -variable "project_config_id" { +variable "data_project_config_project_config_id" { description = "The unique config ID." type = string default = "project_config_id" } // Data source arguments for project -variable "project_id" { +variable "data_project_project_id" { description = "The unique project ID." type = string default = "project_id" } // Data source arguments for project_environment -variable "project_environment_project_id" { +variable "data_project_environment_project_id" { description = "The unique project ID." type = string default = "project_id" } -variable "project_environment_id" { +variable "data_project_environment_project_environment_id" { description = "The environment ID." type = string default = "project_environment_id" diff --git a/go.mod b/go.mod index 511405cb97..9b8b6a6517 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/keyprotect-go-client v0.12.2 github.com/IBM/networking-go-sdk v0.42.2 github.com/IBM/platform-services-go-sdk v0.55.0 - github.com/IBM/project-go-sdk v0.1.4 + github.com/IBM/project-go-sdk v0.1.6 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v5 v5.1.3 github.com/IBM/schematics-go-sdk v0.2.2 diff --git a/go.sum b/go.sum index e472724d60..7640e1266d 100644 --- a/go.sum +++ b/go.sum @@ -160,8 +160,8 @@ github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCB github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.55.0 h1:W598xZanL61bwd8O2DQexr4qjIr+/tP0Y845zoms5yA= github.com/IBM/platform-services-go-sdk v0.55.0/go.mod h1:CWSprvsCsXWvujmBzbtoJSmbRZS9FVV3O594b0t/GiM= -github.com/IBM/project-go-sdk v0.1.4 h1:QGehJxpp/QqfrBYSmN2FRYwuGejlHlVscB/9QGQfdLk= -github.com/IBM/project-go-sdk v0.1.4/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= +github.com/IBM/project-go-sdk v0.1.6 h1:sGrR0ej5wgBDhR2Xvf8Tgi5NmgMAJ77yep/CPGhvOx8= +github.com/IBM/project-go-sdk v0.1.6/go.mod h1:lqe0M4cKvABI1iHR1b+KfasVcxQL6nl2VJ8eOyQs8Ig= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:NPUhkoOCRuv3OFWt19PmwjXGGTKlvmbuPg9fUrBUNe4= github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5/go.mod h1:b07XHUVh0XYnQE9s2mqgjYST1h9buaQNqN4EcKhOsX0= github.com/IBM/sarama v1.41.2 h1:ZDBZfGPHAD4uuAtSv4U22fRZBgst0eEwGFzLj0fb85c= diff --git a/ibm/service/project/data_source_ibm_project.go b/ibm/service/project/data_source_ibm_project.go index 1ba775f958..2f662c1745 100644 --- a/ibm/service/project/data_source_ibm_project.go +++ b/ibm/service/project/data_source_ibm_project.go @@ -85,6 +85,11 @@ func DataSourceIbmProject() *schema.Resource { Computed: true, Description: "The project status value.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A URL.", + }, "resource_group": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -188,6 +193,11 @@ func DataSourceIbmProject() *schema.Resource { }, }, }, + "deployment_model": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The configuration type.", + }, }, }, }, @@ -356,6 +366,10 @@ func dataSourceIbmProjectRead(context context.Context, d *schema.ResourceData, m return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } + if err = d.Set("href", project.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("resource_group", project.ResourceGroup); err != nil { return diag.FromErr(fmt.Errorf("Error setting resource_group: %s", err)) } @@ -456,6 +470,9 @@ func dataSourceIbmProjectProjectConfigSummaryToMap(model *projectv1.ProjectConfi return modelMap, err } modelMap["project"] = []map[string]interface{}{projectMap} + if model.DeploymentModel != nil { + modelMap["deployment_model"] = model.DeploymentModel + } return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config.go b/ibm/service/project/data_source_ibm_project_config.go index 8fadc48a9f..b9b7dc91b1 100644 --- a/ibm/service/project/data_source_ibm_project_config.go +++ b/ibm/service/project/data_source_ibm_project_config.go @@ -82,9 +82,12 @@ func DataSourceIbmProjectConfig() *schema.Resource { Description: "A short explanation of the output value.", }, "value": &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeMap, Computed: true, Description: "Can be any value - a string, number, boolean, array, or object.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, @@ -295,10 +298,14 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The flag that indicates whether a configuration update is available.", }, - "definition": &schema.Schema{ - Type: schema.TypeList, + "href": &schema.Schema{ + Type: schema.TypeString, Computed: true, - Description: "The name and description of a project configuration.", + Description: "A URL.", + }, + "definition": &schema.Schema{ + Type: schema.TypeList, + Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -341,6 +348,22 @@ func DataSourceIbmProjectConfig() *schema.Resource { }, }, }, + "inputs": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "The input variables for configuration definition and environment.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "settings": &schema.Schema{ + Type: schema.TypeMap, + Computed: true, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "compliance_profile": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -380,18 +403,10 @@ func DataSourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "A unique concatenation of catalogID.versionID that identifies the DA in the catalog. Either schematics.workspace_crn, definition.locator_id, or both must be specified.", }, - "inputs": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "The input variables for configuration definition and environment.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "settings": &schema.Schema{ - Type: schema.TypeMap, + "resource_crns": &schema.Schema{ + Type: schema.TypeList, Computed: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "The CRNs of resources associated with this configuration.", Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -430,10 +445,6 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting is_draft: %s", err)) } - if err = d.Set("needs_attention_state", projectConfig.NeedsAttentionState); err != nil { - return diag.FromErr(fmt.Errorf("Error setting needs_attention_state: %s", err)) - } - if err = d.Set("created_at", flex.DateTimeToString(projectConfig.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) } @@ -492,6 +503,10 @@ func dataSourceIbmProjectConfigRead(context context.Context, d *schema.ResourceD return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) } + if err = d.Set("href", projectConfig.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + definition := []map[string]interface{}{} if projectConfig.Definition != nil { modelMap, err := dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(projectConfig.Definition) @@ -514,7 +529,15 @@ func dataSourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (m modelMap["description"] = model.Description } if model.Value != nil { - modelMap["value"] = model.Value + value := make(map[string]interface{}) + for k, v := range model.Value { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + value[k] = string(bytes) + } + modelMap["value"] = value } return modelMap, nil } @@ -602,9 +625,108 @@ func dataSourceIbmProjectConfigScriptToMap(model *projectv1.Script) (map[string] return modelMap, nil } -func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *projectv1.ProjectConfigResponseDefinition) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model projectv1.ProjectConfigResponseDefinitionIntf) (map[string]interface{}, error) { + if _, ok := model.(*projectv1.ProjectConfigResponseDefinitionDAConfigDefinitionProperties); ok { + return dataSourceIbmProjectConfigProjectConfigResponseDefinitionDAConfigDefinitionPropertiesToMap(model.(*projectv1.ProjectConfigResponseDefinitionDAConfigDefinitionProperties)) + } else if _, ok := model.(*projectv1.ProjectConfigResponseDefinitionResourceConfigDefinitionProperties); ok { + return dataSourceIbmProjectConfigProjectConfigResponseDefinitionResourceConfigDefinitionPropertiesToMap(model.(*projectv1.ProjectConfigResponseDefinitionResourceConfigDefinitionProperties)) + } else if _, ok := model.(*projectv1.ProjectConfigResponseDefinition); ok { + modelMap := make(map[string]interface{}) + model := model.(*projectv1.ProjectConfigResponseDefinition) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.EnvironmentID != nil { + modelMap["environment_id"] = model.EnvironmentID + } + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + if model.Inputs != nil { + inputs := make(map[string]interface{}) + for k, v := range model.Inputs { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + inputs[k] = string(bytes) + } + modelMap["inputs"] = inputs + } + if model.Settings != nil { + settings := make(map[string]interface{}) + for k, v := range model.Settings { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + settings[k] = string(bytes) + } + modelMap["settings"] = settings + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectConfigProjectComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.ResourceCrns != nil { + modelMap["resource_crns"] = model.ResourceCrns + } + return modelMap, nil + } else { + return nil, fmt.Errorf("Unrecognized projectv1.ProjectConfigResponseDefinitionIntf subtype encountered") + } +} + +func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.TrustedProfileID != nil { + modelMap["trusted_profile_id"] = model.TrustedProfileID + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func dataSourceIbmProjectConfigProjectConfigResponseDefinitionDAConfigDefinitionPropertiesToMap(model *projectv1.ProjectConfigResponseDefinitionDAConfigDefinitionProperties) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } if model.Description != nil { modelMap["description"] = model.Description } @@ -618,14 +740,6 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *proje } modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.ComplianceProfile != nil { - complianceProfileMap, err := dataSourceIbmProjectConfigProjectComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} - } - modelMap["locator_id"] = model.LocatorID if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { @@ -648,39 +762,61 @@ func dataSourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *proje } modelMap["settings"] = settings } - return modelMap, nil -} - -func dataSourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.TrustedProfileID != nil { - modelMap["trusted_profile_id"] = model.TrustedProfileID - } - if model.Method != nil { - modelMap["method"] = model.Method + if model.ComplianceProfile != nil { + complianceProfileMap, err := dataSourceIbmProjectConfigProjectComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} } - if model.ApiKey != nil { - modelMap["api_key"] = model.ApiKey + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID } return modelMap, nil } -func dataSourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { +func dataSourceIbmProjectConfigProjectConfigResponseDefinitionResourceConfigDefinitionPropertiesToMap(model *projectv1.ProjectConfigResponseDefinitionResourceConfigDefinitionProperties) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID + if model.Name != nil { + modelMap["name"] = model.Name } - if model.InstanceID != nil { - modelMap["instance_id"] = model.InstanceID + if model.Description != nil { + modelMap["description"] = model.Description } - if model.InstanceLocation != nil { - modelMap["instance_location"] = model.InstanceLocation + if model.EnvironmentID != nil { + modelMap["environment_id"] = model.EnvironmentID } - if model.AttachmentID != nil { - modelMap["attachment_id"] = model.AttachmentID + if model.Authorizations != nil { + authorizationsMap, err := dataSourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.ProfileName != nil { - modelMap["profile_name"] = model.ProfileName + if model.Inputs != nil { + inputs := make(map[string]interface{}) + for k, v := range model.Inputs { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + inputs[k] = string(bytes) + } + modelMap["inputs"] = inputs + } + if model.Settings != nil { + settings := make(map[string]interface{}) + for k, v := range model.Settings { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + settings[k] = string(bytes) + } + modelMap["settings"] = settings + } + if model.ResourceCrns != nil { + modelMap["resource_crns"] = model.ResourceCrns } return modelMap, nil } diff --git a/ibm/service/project/data_source_ibm_project_config_test.go b/ibm/service/project/data_source_ibm_project_config_test.go index e009ba0704..0b78bca324 100644 --- a/ibm/service/project/data_source_ibm_project_config_test.go +++ b/ibm/service/project/data_source_ibm_project_config_test.go @@ -29,7 +29,7 @@ func TestAccIbmProjectConfigDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "modified_at"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "project.#"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "state"), - resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "update_available"), + resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "href"), resource.TestCheckResourceAttrSet("data.ibm_project_config.project_config_instance", "definition.#"), ), }, diff --git a/ibm/service/project/data_source_ibm_project_environment.go b/ibm/service/project/data_source_ibm_project_environment.go index dc095eea94..4e052b847b 100644 --- a/ibm/service/project/data_source_ibm_project_environment.go +++ b/ibm/service/project/data_source_ibm_project_environment.go @@ -85,6 +85,11 @@ func DataSourceIbmProjectEnvironment() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A URL.", + }, "definition": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -218,6 +223,10 @@ func dataSourceIbmProjectEnvironmentRead(context context.Context, d *schema.Reso return diag.FromErr(fmt.Errorf("Error setting modified_at: %s", err)) } + if err = d.Set("href", environment.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + definition := []map[string]interface{}{} if environment.Definition != nil { modelMap, err := dataSourceIbmProjectEnvironmentEnvironmentDefinitionRequiredPropertiesToMap(environment.Definition) diff --git a/ibm/service/project/data_source_ibm_project_environment_test.go b/ibm/service/project/data_source_ibm_project_environment_test.go index 7edd07a90e..2f2d111aba 100644 --- a/ibm/service/project/data_source_ibm_project_environment_test.go +++ b/ibm/service/project/data_source_ibm_project_environment_test.go @@ -26,6 +26,7 @@ func TestAccIbmProjectEnvironmentDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project_environment.project_environment_instance", "project.#"), resource.TestCheckResourceAttrSet("data.ibm_project_environment.project_environment_instance", "created_at"), resource.TestCheckResourceAttrSet("data.ibm_project_environment.project_environment_instance", "modified_at"), + resource.TestCheckResourceAttrSet("data.ibm_project_environment.project_environment_instance", "href"), resource.TestCheckResourceAttrSet("data.ibm_project_environment.project_environment_instance", "definition.#"), ), }, diff --git a/ibm/service/project/data_source_ibm_project_test.go b/ibm/service/project/data_source_ibm_project_test.go index e8e3ade5c8..6ac9472a3c 100644 --- a/ibm/service/project/data_source_ibm_project_test.go +++ b/ibm/service/project/data_source_ibm_project_test.go @@ -30,6 +30,7 @@ func TestAccIbmProjectDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "location"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group_id"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "state"), + resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "href"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "resource_group"), resource.TestCheckResourceAttrSet("data.ibm_project.project_instance", "definition.#"), ), diff --git a/ibm/service/project/resource_ibm_project.go b/ibm/service/project/resource_ibm_project.go index 4e51734983..d428f33c91 100644 --- a/ibm/service/project/resource_ibm_project.go +++ b/ibm/service/project/resource_ibm_project.go @@ -121,6 +121,11 @@ func ResourceIbmProject() *schema.Resource { Computed: true, Description: "The project status value.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A URL.", + }, "event_notifications_crn": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -219,6 +224,11 @@ func ResourceIbmProject() *schema.Resource { }, }, }, + "deployment_model": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "The configuration type.", + }, }, }, }, @@ -349,6 +359,30 @@ func resourceIbmProjectCreate(context context.Context, d *schema.ResourceData, m createProjectOptions.SetDefinition(definitionModel) createProjectOptions.SetLocation(d.Get("location").(string)) createProjectOptions.SetResourceGroup(d.Get("resource_group").(string)) + if _, ok := d.GetOk("configs"); ok { + var configs []projectv1.ProjectConfigPrototype + for _, v := range d.Get("configs").([]interface{}) { + value := v.(map[string]interface{}) + configsItem, err := resourceIbmProjectMapToProjectConfigPrototype(value) + if err != nil { + return diag.FromErr(err) + } + configs = append(configs, *configsItem) + } + createProjectOptions.SetConfigs(configs) + } + if _, ok := d.GetOk("environments"); ok { + var environments []projectv1.EnvironmentPrototype + for _, v := range d.Get("environments").([]interface{}) { + value := v.(map[string]interface{}) + environmentsItem, err := resourceIbmProjectMapToEnvironmentPrototype(value) + if err != nil { + return diag.FromErr(err) + } + environments = append(environments, *environmentsItem) + } + createProjectOptions.SetEnvironments(environments) + } project, response, err := projectClient.CreateProjectWithContext(context, createProjectOptions) if err != nil { @@ -424,6 +458,9 @@ func resourceIbmProjectRead(context context.Context, d *schema.ResourceData, met if err = d.Set("state", project.State); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } + if err = d.Set("href", project.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } if !core.IsNil(project.EventNotificationsCrn) { if err = d.Set("event_notifications_crn", project.EventNotificationsCrn); err != nil { return diag.FromErr(fmt.Errorf("Error setting event_notifications_crn: %s", err)) @@ -541,7 +578,7 @@ func resourceIbmProjectMapToProjectConfigPrototype(modelMap map[string]interface return model, nil } -func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypeDefinitionBlock, error) { +func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[string]interface{}) (projectv1.ProjectConfigPrototypeDefinitionBlockIntf, error) { model := &projectv1.ProjectConfigPrototypeDefinitionBlock{} model.Name = core.StringPtr(modelMap["name"].(string)) if modelMap["description"] != nil && modelMap["description"].(string) != "" { @@ -557,6 +594,22 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s } model.Authorizations = AuthorizationsModel } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Settings = newMap + } + } if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { ComplianceProfileModel, err := resourceIbmProjectMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -567,17 +620,12 @@ func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlock(modelMap map[s if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } - if modelMap["inputs"] != nil { - bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) - newMap := make(map[string]interface{}) - json.Unmarshal(bytes, &newMap) - model.Inputs = newMap - } - if modelMap["settings"] != nil { - bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) - newMap := make(map[string]interface{}) - json.Unmarshal(bytes, &newMap) - model.Settings = newMap + if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 { + resourceCrns := []string{} + for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) { + resourceCrns = append(resourceCrns, resourceCrnsItem.(string)) + } + model.ResourceCrns = resourceCrns } return model, nil } @@ -616,6 +664,97 @@ func resourceIbmProjectMapToProjectComplianceProfile(modelMap map[string]interfa return model, nil } +func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlockDAConfigDefinitionProperties(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypeDefinitionBlockDAConfigDefinitionProperties, error) { + model := &projectv1.ProjectConfigPrototypeDefinitionBlockDAConfigDefinitionProperties{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["environment_id"] != nil && modelMap["environment_id"].(string) != "" { + model.EnvironmentID = core.StringPtr(modelMap["environment_id"].(string)) + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Settings = newMap + } + } + if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { + ComplianceProfileModel, err := resourceIbmProjectMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.ComplianceProfile = ComplianceProfileModel + } + if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + } + return model, nil +} + +func resourceIbmProjectMapToProjectConfigPrototypeDefinitionBlockResourceConfigDefinitionProperties(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypeDefinitionBlockResourceConfigDefinitionProperties, error) { + model := &projectv1.ProjectConfigPrototypeDefinitionBlockResourceConfigDefinitionProperties{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["environment_id"] != nil && modelMap["environment_id"].(string) != "" { + model.EnvironmentID = core.StringPtr(modelMap["environment_id"].(string)) + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Settings = newMap + } + } + if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 { + resourceCrns := []string{} + for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) { + resourceCrns = append(resourceCrns, resourceCrnsItem.(string)) + } + model.ResourceCrns = resourceCrns + } + return model, nil +} + func resourceIbmProjectMapToSchematicsWorkspace(modelMap map[string]interface{}) (*projectv1.SchematicsWorkspace, error) { model := &projectv1.SchematicsWorkspace{} if modelMap["workspace_crn"] != nil && modelMap["workspace_crn"].(string) != "" { @@ -624,6 +763,47 @@ func resourceIbmProjectMapToSchematicsWorkspace(modelMap map[string]interface{}) return model, nil } +func resourceIbmProjectMapToEnvironmentPrototype(modelMap map[string]interface{}) (*projectv1.EnvironmentPrototype, error) { + model := &projectv1.EnvironmentPrototype{} + DefinitionModel, err := resourceIbmProjectMapToEnvironmentDefinitionRequiredProperties(modelMap["definition"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Definition = DefinitionModel + return model, nil +} + +func resourceIbmProjectMapToEnvironmentDefinitionRequiredProperties(modelMap map[string]interface{}) (*projectv1.EnvironmentDefinitionRequiredProperties, error) { + model := &projectv1.EnvironmentDefinitionRequiredProperties{} + model.Name = core.StringPtr(modelMap["name"].(string)) + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { + ComplianceProfileModel, err := resourceIbmProjectMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.ComplianceProfile = ComplianceProfileModel + } + return model, nil +} + func resourceIbmProjectMapToProjectPatchDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectPatchDefinitionBlock, error) { model := &projectv1.ProjectPatchDefinitionBlock{} if modelMap["name"] != nil && modelMap["name"].(string) != "" { @@ -697,6 +877,9 @@ func resourceIbmProjectProjectConfigSummaryToMap(model *projectv1.ProjectConfigS return modelMap, err } modelMap["project"] = []map[string]interface{}{projectMap} + if model.DeploymentModel != nil { + modelMap["deployment_model"] = model.DeploymentModel + } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_config.go b/ibm/service/project/resource_ibm_project_config.go index 161c7a41f1..f0ef27eeef 100644 --- a/ibm/service/project/resource_ibm_project_config.go +++ b/ibm/service/project/resource_ibm_project_config.go @@ -195,11 +195,10 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, "definition": &schema.Schema{ - Type: schema.TypeList, - MinItems: 1, - MaxItems: 1, - Required: true, - Description: "The name and description of a project configuration.", + Type: schema.TypeList, + MinItems: 1, + MaxItems: 1, + Required: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -243,6 +242,18 @@ func ResourceIbmProjectConfig() *schema.Resource { }, }, }, + "inputs": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "The input variables for configuration definition and environment.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "settings": &schema.Schema{ + Type: schema.TypeMap, + Optional: true, + Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, "compliance_profile": &schema.Schema{ Type: schema.TypeList, MaxItems: 1, @@ -280,20 +291,14 @@ func ResourceIbmProjectConfig() *schema.Resource { }, "locator_id": &schema.Schema{ Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, Description: "A unique concatenation of catalogID.versionID that identifies the DA in the catalog. Either schematics.workspace_crn, definition.locator_id, or both must be specified.", }, - "inputs": &schema.Schema{ - Type: schema.TypeMap, - Optional: true, - Description: "The input variables for configuration definition and environment.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "settings": &schema.Schema{ - Type: schema.TypeMap, + "resource_crns": &schema.Schema{ + Type: schema.TypeList, Optional: true, - Description: "Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created.", + Description: "The CRNs of resources associated with this configuration.", Elem: &schema.Schema{Type: schema.TypeString}, }, }, @@ -313,7 +318,7 @@ func ResourceIbmProjectConfig() *schema.Resource { Type: schema.TypeList, Computed: true, Description: "The needs attention state of a configuration.", - Elem: &schema.Schema{Type: schema.TypeString}, + Elem: &schema.Schema{Type: schema.TypeMap, Elem: &schema.Schema{Type: schema.TypeString}}, }, "created_at": &schema.Schema{ Type: schema.TypeString, @@ -347,9 +352,10 @@ func ResourceIbmProjectConfig() *schema.Resource { Description: "A short explanation of the output value.", }, "value": &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeMap, Computed: true, Description: "Can be any value - a string, number, boolean, array, or object.", + Elem: &schema.Schema{Type: schema.TypeString}, }, }, }, @@ -402,6 +408,11 @@ func ResourceIbmProjectConfig() *schema.Resource { Computed: true, Description: "The flag that indicates whether a configuration update is available.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A URL.", + }, "project_config_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -543,8 +554,13 @@ func resourceIbmProjectConfigRead(context context.Context, d *schema.ResourceDat if err = d.Set("state", projectConfig.State); err != nil { return diag.FromErr(fmt.Errorf("Error setting state: %s", err)) } - if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { - return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + if !core.IsNil(projectConfig.UpdateAvailable) { + if err = d.Set("update_available", projectConfig.UpdateAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting update_available: %s", err)) + } + } + if err = d.Set("href", projectConfig.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) } if err = d.Set("project_config_id", projectConfig.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_config_id: %s", err)) @@ -571,6 +587,10 @@ func resourceIbmProjectConfigUpdate(context context.Context, d *schema.ResourceD hasChange := false + if d.HasChange("project_id") { + return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ + " The resource must be re-created to update this property.", "project_id")) + } if d.HasChange("definition") { definition, err := resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlock(d.Get("definition.0").(map[string]interface{})) if err != nil { @@ -618,7 +638,7 @@ func resourceIbmProjectConfigDelete(context context.Context, d *schema.ResourceD return nil } -func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypeDefinitionBlock, error) { +func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap map[string]interface{}) (projectv1.ProjectConfigPrototypeDefinitionBlockIntf, error) { model := &projectv1.ProjectConfigPrototypeDefinitionBlock{} model.Name = core.StringPtr(modelMap["name"].(string)) if modelMap["description"] != nil && modelMap["description"].(string) != "" { @@ -634,6 +654,22 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap } model.Authorizations = AuthorizationsModel } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Settings = newMap + } + } if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -644,17 +680,12 @@ func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlock(modelMap if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } - if modelMap["inputs"] != nil { - bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) - newMap := make(map[string]interface{}) - json.Unmarshal(bytes, &newMap) - model.Inputs = newMap - } - if modelMap["settings"] != nil { - bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) - newMap := make(map[string]interface{}) - json.Unmarshal(bytes, &newMap) - model.Settings = newMap + if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 { + resourceCrns := []string{} + for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) { + resourceCrns = append(resourceCrns, resourceCrnsItem.(string)) + } + model.ResourceCrns = resourceCrns } return model, nil } @@ -693,6 +724,97 @@ func resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap map[string]i return model, nil } +func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlockDAConfigDefinitionProperties(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypeDefinitionBlockDAConfigDefinitionProperties, error) { + model := &projectv1.ProjectConfigPrototypeDefinitionBlockDAConfigDefinitionProperties{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["environment_id"] != nil && modelMap["environment_id"].(string) != "" { + model.EnvironmentID = core.StringPtr(modelMap["environment_id"].(string)) + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Settings = newMap + } + } + if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { + ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.ComplianceProfile = ComplianceProfileModel + } + if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + } + return model, nil +} + +func resourceIbmProjectConfigMapToProjectConfigPrototypeDefinitionBlockResourceConfigDefinitionProperties(modelMap map[string]interface{}) (*projectv1.ProjectConfigPrototypeDefinitionBlockResourceConfigDefinitionProperties, error) { + model := &projectv1.ProjectConfigPrototypeDefinitionBlockResourceConfigDefinitionProperties{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["environment_id"] != nil && modelMap["environment_id"].(string) != "" { + model.EnvironmentID = core.StringPtr(modelMap["environment_id"].(string)) + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Settings = newMap + } + } + if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 { + resourceCrns := []string{} + for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) { + resourceCrns = append(resourceCrns, resourceCrnsItem.(string)) + } + model.ResourceCrns = resourceCrns + } + return model, nil +} + func resourceIbmProjectConfigMapToSchematicsWorkspace(modelMap map[string]interface{}) (*projectv1.SchematicsWorkspace, error) { model := &projectv1.SchematicsWorkspace{} if modelMap["workspace_crn"] != nil && modelMap["workspace_crn"].(string) != "" { @@ -701,7 +823,7 @@ func resourceIbmProjectConfigMapToSchematicsWorkspace(modelMap map[string]interf return model, nil } -func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlock(modelMap map[string]interface{}) (*projectv1.ProjectConfigPatchDefinitionBlock, error) { +func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlock(modelMap map[string]interface{}) (projectv1.ProjectConfigPatchDefinitionBlockIntf, error) { model := &projectv1.ProjectConfigPatchDefinitionBlock{} if modelMap["name"] != nil && modelMap["name"].(string) != "" { model.Name = core.StringPtr(modelMap["name"].(string)) @@ -719,6 +841,22 @@ func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlock(modelMap map } model.Authorizations = AuthorizationsModel } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Settings = newMap + } + } if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) if err != nil { @@ -729,17 +867,103 @@ func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlock(modelMap map if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) } + if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 { + resourceCrns := []string{} + for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) { + resourceCrns = append(resourceCrns, resourceCrnsItem.(string)) + } + model.ResourceCrns = resourceCrns + } + return model, nil +} + +func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlockDAConfigDefinitionProperties(modelMap map[string]interface{}) (*projectv1.ProjectConfigPatchDefinitionBlockDAConfigDefinitionProperties, error) { + model := &projectv1.ProjectConfigPatchDefinitionBlockDAConfigDefinitionProperties{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["environment_id"] != nil && modelMap["environment_id"].(string) != "" { + model.EnvironmentID = core.StringPtr(modelMap["environment_id"].(string)) + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } if modelMap["inputs"] != nil { bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) newMap := make(map[string]interface{}) json.Unmarshal(bytes, &newMap) - model.Inputs = newMap + if len(newMap) > 0 { + model.Inputs = newMap + } } if modelMap["settings"] != nil { bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) newMap := make(map[string]interface{}) json.Unmarshal(bytes, &newMap) - model.Settings = newMap + if len(newMap) > 0 { + model.Settings = newMap + } + } + if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { + ComplianceProfileModel, err := resourceIbmProjectConfigMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.ComplianceProfile = ComplianceProfileModel + } + if modelMap["locator_id"] != nil && modelMap["locator_id"].(string) != "" { + model.LocatorID = core.StringPtr(modelMap["locator_id"].(string)) + } + return model, nil +} + +func resourceIbmProjectConfigMapToProjectConfigPatchDefinitionBlockResourceConfigDefinitionProperties(modelMap map[string]interface{}) (*projectv1.ProjectConfigPatchDefinitionBlockResourceConfigDefinitionProperties, error) { + model := &projectv1.ProjectConfigPatchDefinitionBlockResourceConfigDefinitionProperties{} + if modelMap["name"] != nil && modelMap["name"].(string) != "" { + model.Name = core.StringPtr(modelMap["name"].(string)) + } + if modelMap["description"] != nil && modelMap["description"].(string) != "" { + model.Description = core.StringPtr(modelMap["description"].(string)) + } + if modelMap["environment_id"] != nil && modelMap["environment_id"].(string) != "" { + model.EnvironmentID = core.StringPtr(modelMap["environment_id"].(string)) + } + if modelMap["authorizations"] != nil && len(modelMap["authorizations"].([]interface{})) > 0 { + AuthorizationsModel, err := resourceIbmProjectConfigMapToProjectConfigAuth(modelMap["authorizations"].([]interface{})[0].(map[string]interface{})) + if err != nil { + return model, err + } + model.Authorizations = AuthorizationsModel + } + if modelMap["inputs"] != nil { + bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Inputs = newMap + } + } + if modelMap["settings"] != nil { + bytes, _ := json.Marshal(modelMap["settings"].(map[string]interface{})) + newMap := make(map[string]interface{}) + json.Unmarshal(bytes, &newMap) + if len(newMap) > 0 { + model.Settings = newMap + } + } + if modelMap["resource_crns"] != nil && len(modelMap["resource_crns"].([]interface{})) > 0 { + resourceCrns := []string{} + for _, resourceCrnsItem := range modelMap["resource_crns"].([]interface{}) { + resourceCrns = append(resourceCrns, resourceCrnsItem.(string)) + } + model.ResourceCrns = resourceCrns } return model, nil } @@ -808,9 +1032,116 @@ func resourceIbmProjectConfigScriptToMap(model *projectv1.Script) (map[string]in return modelMap, nil } -func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *projectv1.ProjectConfigResponseDefinition) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model projectv1.ProjectConfigResponseDefinitionIntf) (map[string]interface{}, error) { + if _, ok := model.(*projectv1.ProjectConfigResponseDefinitionDAConfigDefinitionProperties); ok { + return resourceIbmProjectConfigProjectConfigResponseDefinitionDAConfigDefinitionPropertiesToMap(model.(*projectv1.ProjectConfigResponseDefinitionDAConfigDefinitionProperties)) + } else if _, ok := model.(*projectv1.ProjectConfigResponseDefinitionResourceConfigDefinitionProperties); ok { + return resourceIbmProjectConfigProjectConfigResponseDefinitionResourceConfigDefinitionPropertiesToMap(model.(*projectv1.ProjectConfigResponseDefinitionResourceConfigDefinitionProperties)) + } else if _, ok := model.(*projectv1.ProjectConfigResponseDefinition); ok { + modelMap := make(map[string]interface{}) + model := model.(*projectv1.ProjectConfigResponseDefinition) + modelMap["name"] = model.Name + if model.Description != nil { + modelMap["description"] = model.Description + } + if model.EnvironmentID != nil { + modelMap["environment_id"] = model.EnvironmentID + } + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + if len(authorizationsMap) > 0 { + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } + } + if model.Inputs != nil { + inputs := make(map[string]interface{}) + for k, v := range model.Inputs { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + inputs[k] = string(bytes) + } + if len(inputs) > 0 { + modelMap["inputs"] = inputs + } + } + if model.Settings != nil { + settings := make(map[string]interface{}) + for k, v := range model.Settings { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + settings[k] = string(bytes) + } + if len(settings) > 0 { + modelMap["settings"] = settings + } + } + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectConfigProjectComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + if len(complianceProfileMap) > 0 { + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } + } + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID + } + if model.ResourceCrns != nil && len(model.ResourceCrns) > 0 { + modelMap["resource_crns"] = model.ResourceCrns + } + return modelMap, nil + } else { + return nil, fmt.Errorf("Unrecognized projectv1.ProjectConfigResponseDefinitionIntf subtype encountered") + } +} + +func resourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name + if model.TrustedProfileID != nil { + modelMap["trusted_profile_id"] = model.TrustedProfileID + } + if model.Method != nil { + modelMap["method"] = model.Method + } + if model.ApiKey != nil { + modelMap["api_key"] = model.ApiKey + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.ID != nil { + modelMap["id"] = model.ID + } + if model.InstanceID != nil { + modelMap["instance_id"] = model.InstanceID + } + if model.InstanceLocation != nil { + modelMap["instance_location"] = model.InstanceLocation + } + if model.AttachmentID != nil { + modelMap["attachment_id"] = model.AttachmentID + } + if model.ProfileName != nil { + modelMap["profile_name"] = model.ProfileName + } + return modelMap, nil +} + +func resourceIbmProjectConfigProjectConfigResponseDefinitionDAConfigDefinitionPropertiesToMap(model *projectv1.ProjectConfigResponseDefinitionDAConfigDefinitionProperties) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + if model.Name != nil { + modelMap["name"] = model.Name + } if model.Description != nil { modelMap["description"] = model.Description } @@ -822,18 +1153,10 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} - } - if model.ComplianceProfile != nil { - complianceProfileMap, err := resourceIbmProjectConfigProjectComplianceProfileToMap(model.ComplianceProfile) - if err != nil { - return modelMap, err - } - if len(complianceProfileMap) > 0 { - modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + if len(authorizationsMap) > 0 { + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } } - modelMap["locator_id"] = model.LocatorID if model.Inputs != nil { inputs := make(map[string]interface{}) for k, v := range model.Inputs { @@ -860,39 +1183,67 @@ func resourceIbmProjectConfigProjectConfigResponseDefinitionToMap(model *project modelMap["settings"] = settings } } - return modelMap, nil -} - -func resourceIbmProjectConfigProjectConfigAuthToMap(model *projectv1.ProjectConfigAuth) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.TrustedProfileID != nil { - modelMap["trusted_profile_id"] = model.TrustedProfileID - } - if model.Method != nil { - modelMap["method"] = model.Method + if model.ComplianceProfile != nil { + complianceProfileMap, err := resourceIbmProjectConfigProjectComplianceProfileToMap(model.ComplianceProfile) + if err != nil { + return modelMap, err + } + if len(complianceProfileMap) > 0 { + modelMap["compliance_profile"] = []map[string]interface{}{complianceProfileMap} + } } - if model.ApiKey != nil { - modelMap["api_key"] = model.ApiKey + if model.LocatorID != nil { + modelMap["locator_id"] = model.LocatorID } return modelMap, nil } -func resourceIbmProjectConfigProjectComplianceProfileToMap(model *projectv1.ProjectComplianceProfile) (map[string]interface{}, error) { +func resourceIbmProjectConfigProjectConfigResponseDefinitionResourceConfigDefinitionPropertiesToMap(model *projectv1.ProjectConfigResponseDefinitionResourceConfigDefinitionProperties) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID + if model.Name != nil { + modelMap["name"] = model.Name } - if model.InstanceID != nil { - modelMap["instance_id"] = model.InstanceID + if model.Description != nil { + modelMap["description"] = model.Description } - if model.InstanceLocation != nil { - modelMap["instance_location"] = model.InstanceLocation + if model.EnvironmentID != nil { + modelMap["environment_id"] = model.EnvironmentID } - if model.AttachmentID != nil { - modelMap["attachment_id"] = model.AttachmentID + if model.Authorizations != nil { + authorizationsMap, err := resourceIbmProjectConfigProjectConfigAuthToMap(model.Authorizations) + if err != nil { + return modelMap, err + } + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} } - if model.ProfileName != nil { - modelMap["profile_name"] = model.ProfileName + if model.Inputs != nil { + inputs := make(map[string]interface{}) + for k, v := range model.Inputs { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + inputs[k] = string(bytes) + } + if len(inputs) > 0 { + modelMap["inputs"] = inputs + } + } + if model.Settings != nil { + settings := make(map[string]interface{}) + for k, v := range model.Settings { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + settings[k] = string(bytes) + } + if len(settings) > 0 { + modelMap["settings"] = settings + } + } + if model.ResourceCrns != nil && len(model.ResourceCrns) > 0 { + modelMap["resource_crns"] = model.ResourceCrns } return modelMap, nil } @@ -904,7 +1255,15 @@ func resourceIbmProjectConfigOutputValueToMap(model *projectv1.OutputValue) (map modelMap["description"] = model.Description } if model.Value != nil { - modelMap["value"] = model.Value + value := make(map[string]interface{}) + for k, v := range model.Value { + bytes, err := json.Marshal(v) + if err != nil { + return modelMap, err + } + value[k] = string(bytes) + } + modelMap["value"] = value } return modelMap, nil } diff --git a/ibm/service/project/resource_ibm_project_environment.go b/ibm/service/project/resource_ibm_project_environment.go index d9fa73b4d9..615895028e 100644 --- a/ibm/service/project/resource_ibm_project_environment.go +++ b/ibm/service/project/resource_ibm_project_environment.go @@ -176,6 +176,11 @@ func ResourceIbmProjectEnvironment() *schema.Resource { Computed: true, Description: "A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "A URL.", + }, "project_environment_id": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -279,6 +284,9 @@ func resourceIbmProjectEnvironmentRead(context context.Context, d *schema.Resour if err = d.Set("modified_at", flex.DateTimeToString(environment.ModifiedAt)); err != nil { return diag.FromErr(fmt.Errorf("Error setting modified_at: %s", err)) } + if err = d.Set("href", environment.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } if err = d.Set("project_environment_id", environment.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting project_environment_id: %s", err)) } @@ -372,7 +380,9 @@ func resourceIbmProjectEnvironmentMapToEnvironmentDefinitionRequiredProperties(m bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) newMap := make(map[string]interface{}) json.Unmarshal(bytes, &newMap) - model.Inputs = newMap + if len(newMap) > 0 { + model.Inputs = newMap + } } if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { ComplianceProfileModel, err := resourceIbmProjectEnvironmentMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) @@ -437,7 +447,9 @@ func resourceIbmProjectEnvironmentMapToEnvironmentDefinitionProperties(modelMap bytes, _ := json.Marshal(modelMap["inputs"].(map[string]interface{})) newMap := make(map[string]interface{}) json.Unmarshal(bytes, &newMap) - model.Inputs = newMap + if len(newMap) > 0 { + model.Inputs = newMap + } } if modelMap["compliance_profile"] != nil && len(modelMap["compliance_profile"].([]interface{})) > 0 { ComplianceProfileModel, err := resourceIbmProjectEnvironmentMapToProjectComplianceProfile(modelMap["compliance_profile"].([]interface{})[0].(map[string]interface{})) @@ -460,7 +472,9 @@ func resourceIbmProjectEnvironmentEnvironmentDefinitionRequiredPropertiesToMap(m if err != nil { return modelMap, err } - modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + if len(authorizationsMap) > 0 { + modelMap["authorizations"] = []map[string]interface{}{authorizationsMap} + } } if model.Inputs != nil { inputs := make(map[string]interface{}) diff --git a/website/docs/d/project.html.markdown b/website/docs/d/project.html.markdown index 6cac923733..7960495c97 100644 --- a/website/docs/d/project.html.markdown +++ b/website/docs/d/project.html.markdown @@ -40,6 +40,8 @@ Nested schema for **configs**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. * `name` - (String) The configuration name. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `deployment_model` - (String) The configuration type. + * Constraints: Allowable values are: `project_deployed`, `user_deployed`. * `href` - (String) A URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. @@ -58,7 +60,7 @@ Nested schema for **configs**: * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`, `applied`, `apply_failed`. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -118,6 +120,9 @@ Nested schema for **environments**: * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. +* `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `location` - (Forces new resource, String) The IBM Cloud location where a resource is deployed. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]*$/`. diff --git a/website/docs/d/project_config.html.markdown b/website/docs/d/project_config.html.markdown index 8a3b1e183b..21021df943 100644 --- a/website/docs/d/project_config.html.markdown +++ b/website/docs/d/project_config.html.markdown @@ -35,7 +35,7 @@ After your data source is created, you can read values from the following attrib * `id` - The unique identifier of the project_config. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. -* `definition` - (List) The name and description of a project configuration. +* `definition` - (List) Nested schema for **definition**: * `authorizations` - (List) The authorization details. You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: @@ -66,8 +66,13 @@ Nested schema for **definition**: * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (String) The configuration name. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `resource_crns` - (List) The CRNs of resources associated with this configuration. + * Constraints: The list items must match regular expression `/(?!\\s)(?!.*\\s$)^(crn)[^'"`<>{}\\s\\x00-\\x1F]*/`. The maximum length is `110` items. The minimum length is `0` items. * `settings` - (Map) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. +* `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `last_saved_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -84,7 +89,7 @@ Nested schema for **outputs**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `value` - (Map) Can be any value - a string, number, boolean, array, or object. * `project` - (List) The project referenced by this resource. Nested schema for **project**: @@ -153,7 +158,7 @@ Nested schema for **schematics**: * Constraints: The maximum length is `512` characters. The minimum length is `4` characters. The value must match regular expression `/(?!\\s)(?!.*\\s$)^(crn)[^'"`<>{}\\s\\x00-\\x1F]*/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`, `applied`, `apply_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. diff --git a/website/docs/d/project_environment.html.markdown b/website/docs/d/project_environment.html.markdown index e7c6fd774c..a975ff2fb4 100644 --- a/website/docs/d/project_environment.html.markdown +++ b/website/docs/d/project_environment.html.markdown @@ -63,6 +63,9 @@ Nested schema for **definition**: * `name` - (String) The name of the environment. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[^'"`<>{}\\x00-\\x1F]+$/`. +* `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. + * `modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `project` - (List) The project referenced by this resource. diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index b447a1d627..3f0b5d0280 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -55,6 +55,8 @@ Nested schema for **configs**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. * `name` - (String) The configuration name. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `deployment_model` - (String) The configuration type. + * Constraints: Allowable values are: `project_deployed`, `user_deployed`. * `href` - (String) A URL. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. @@ -73,7 +75,7 @@ Nested schema for **configs**: * `id` - (String) The unique ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`, `applied`, `apply_failed`. * `version` - (Integer) The version of the configuration. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. @@ -118,6 +120,8 @@ Nested schema for **environments**: * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `event_notifications_crn` - (String) The CRN of the event notifications instance if one is connected to this project. * Constraints: The maximum length is `512` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^crn:v[0-9](:([A-Za-z0-9\\-._~!$&'()*+,;=@\/]|%[0-9A-Z]{2})*){8}$/`. +* `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `resource_group_id` - (String) The resource group id where the project's data and tools are created. * Constraints: The maximum length is `64` characters. The minimum length is `0` characters. The value must match regular expression `/^[0-9a-zA-Z]+$/`. * `state` - (String) The project status value. diff --git a/website/docs/r/project_config.html.markdown b/website/docs/r/project_config.html.markdown index 86be477768..ab71abbf40 100644 --- a/website/docs/r/project_config.html.markdown +++ b/website/docs/r/project_config.html.markdown @@ -23,7 +23,7 @@ resource "ibm_project_config" "project_config_instance" { } locator_id = "1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.145be7c1-9ec4-4719-b586-584ee52fbed0-global" inputs = { - name = "app_repo_name" + app_repo_name = "static-website-repo" } } project_id = ibm_project.project_instance.id @@ -34,7 +34,7 @@ resource "ibm_project_config" "project_config_instance" { You can specify the following arguments for this resource. -* `definition` - (Required, List) The name and description of a project configuration. +* `definition` - (Required, List) Nested schema for **definition**: * `authorizations` - (Optional, List) The authorization details. You can authorize by using a trusted profile or an API key in Secrets Manager. Nested schema for **authorizations**: @@ -61,10 +61,12 @@ Nested schema for **definition**: * `environment_id` - (Optional, String) The ID of the project environment. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `inputs` - (Optional, Map) The input variables for configuration definition and environment. - * `locator_id` - (Required, Forces new resource, String) A unique concatenation of catalogID.versionID that identifies the DA in the catalog. Either schematics.workspace_crn, definition.locator_id, or both must be specified. + * `locator_id` - (Optional, Forces new resource, String) A unique concatenation of catalogID.versionID that identifies the DA in the catalog. Either schematics.workspace_crn, definition.locator_id, or both must be specified. * Constraints: The maximum length is `512` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$)[\\.0-9a-z-A-Z_-]+$/`. * `name` - (Required, String) The configuration name. It is unique within the account across projects and regions. * Constraints: The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][a-zA-Z0-9-_ ]*$/`. + * `resource_crns` - (Optional, List) The CRNs of resources associated with this configuration. + * Constraints: The list items must match regular expression `/(?!\\s)(?!.*\\s$)^(crn)[^'"`<>{}\\s\\x00-\\x1F]*/`. The maximum length is `110` items. The minimum length is `0` items. * `settings` - (Optional, Map) Schematics environment variables to use to deploy the configuration. Settings are only available if they were specified when the configuration was initially created. * `project_id` - (Required, Forces new resource, String) The unique project ID. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. @@ -127,6 +129,8 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the project_config. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `is_draft` - (Boolean) The flag that indicates whether the version of the configuration is draft, or active. * `last_saved_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. @@ -139,7 +143,7 @@ Nested schema for **outputs**: * Constraints: The maximum length is `1024` characters. The minimum length is `0` characters. The value must match regular expression `/^$|^(?!\\s)(?!.*\\s$)[^\\x00-\\x1F]*$/`. * `name` - (String) The variable name. * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(?!\\s)(?!.*\\s$).+$/`. - * `value` - (String) Can be any value - a string, number, boolean, array, or object. + * `value` - (Map) Can be any value - a string, number, boolean, array, or object. * `project` - (List) The project referenced by this resource. Nested schema for **project**: * `crn` - (String) An IBM Cloud resource name, which uniquely identifies a resource. @@ -155,7 +159,7 @@ Nested schema for **project**: * `project_config_id` - (String) The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration. * Constraints: The maximum length is `128` characters. The value must match regular expression `/^[\\.\\-0-9a-zA-Z]+$/`. * `state` - (String) The state of the configuration. - * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`. + * Constraints: Allowable values are: `approved`, `deleted`, `deleting`, `deleting_failed`, `discarded`, `draft`, `deployed`, `deploying_failed`, `deploying`, `superseded`, `undeploying`, `undeploying_failed`, `validated`, `validating`, `validating_failed`, `applied`, `apply_failed`. * `update_available` - (Boolean) The flag that indicates whether a configuration update is available. * `version` - (Integer) The version of the configuration. diff --git a/website/docs/r/project_environment.html.markdown b/website/docs/r/project_environment.html.markdown index 99299f2fd4..218a8dfa38 100644 --- a/website/docs/r/project_environment.html.markdown +++ b/website/docs/r/project_environment.html.markdown @@ -66,6 +66,8 @@ After your resource is created, you can read values from the listed arguments an * `id` - The unique identifier of the project_environment. * `created_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. +* `href` - (String) A URL. + * Constraints: The maximum length is `256` characters. The minimum length is `1` character. The value must match regular expression `/^(http(s)?:\/\/)[a-zA-Z0-9\\$\\-_\\.+!\\*'\\(\\),=&?\/]+$/`. * `modified_at` - (String) A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time format as specified by RFC 3339. * `project` - (List) The project referenced by this resource. Nested schema for **project**: From f2f674eb3947c47838b08728daf40a6df17252cf Mon Sep 17 00:00:00 2001 From: sreekarbvibm <139211144+sreekarbvibm@users.noreply.github.com> Date: Thu, 28 Dec 2023 11:12:35 +0530 Subject: [PATCH 2/7] Feature(vpc Advertise routes): Support route advertising in vpc (#5005) * added advertised route support * doc updates for routing table/s * Change advertise_routes_to from List to HashSet and modify create, update and read methods accordingly * Add latest generated go sdk * update with latest sdk * add beta maturity to sdk * corrected docs as per review comment * updated go mod * Update resource_ibm_is_bare_metal_server.go * rm common --------- Co-authored-by: Bhavesh Shrivastav Co-authored-by: Ujjwal Kumar --- go.mod | 3 +- go.sum | 4 +- .../data_source_ibm_is_vpc_routing_table.go | 11 ++++++ ...a_source_ibm_is_vpc_routing_table_route.go | 9 +++++ ..._source_ibm_is_vpc_routing_table_routes.go | 8 ++++ .../data_source_ibm_is_vpc_routing_tables.go | 11 ++++++ .../vpc/resource_ibm_is_bare_metal_server.go | 11 +++--- .../vpc/resource_ibm_is_vpc_routing_table.go | 37 +++++++++++++++++++ ...resource_ibm_is_vpc_routing_table_route.go | 29 +++++++++++++++ ...rce_ibm_is_vpc_routing_table_route_test.go | 15 ++++++-- .../resource_ibm_is_vpc_routing_table_test.go | 32 ++++++++++++++++ .../docs/d/is_vpc_routing_table.html.markdown | 5 +++ .../is_vpc_routing_table_route.html.markdown | 1 + .../is_vpc_routing_table_routes.html.markdown | 1 + .../d/is_vpc_routing_tables.html.markdown | 5 +++ .../docs/r/is_vpc_routing_table.html.markdown | 25 ++++++++++++- .../is_vpc_routing_table_route.html.markdown | 5 ++- 17 files changed, 198 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 9b8b6a6517..f90c4389cf 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/IBM/schematics-go-sdk v0.2.2 github.com/IBM/secrets-manager-go-sdk/v2 v2.0.2 github.com/IBM/vpc-beta-go-sdk v0.6.0 - github.com/IBM/vpc-go-sdk v0.46.0 + github.com/IBM/vpc-go-sdk v0.47.0 github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5 github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2 github.com/akamai/AkamaiOPEN-edgegrid-golang/v5 v5.0.0 @@ -235,6 +235,7 @@ replace github.com/softlayer/softlayer-go v1.0.3 => github.com/IBM-Cloud/softlay replace github.com/dgrijalva/jwt-go v3.2.0+incompatible => github.com/golang-jwt/jwt v3.2.1+incompatible +// add sdk changes. replace github.com/portworx/sched-ops v0.0.0-20200831185134-3e8010dc7056 => github.com/portworx/sched-ops v0.20.4-openstorage-rc3 // required by rook v1.7 exclude ( diff --git a/go.sum b/go.sum index 7640e1266d..b3be0e1e92 100644 --- a/go.sum +++ b/go.sum @@ -174,8 +174,8 @@ github.com/IBM/secrets-manager-go-sdk/v2 v2.0.2 h1:+Svh1OmoFxMBnZQSOUtp2UUzrOGFs github.com/IBM/secrets-manager-go-sdk/v2 v2.0.2/go.mod h1:WII+LS4VkQYykmq65NWSuPb5xGNvsqkcK1aCWZoU2x4= github.com/IBM/vpc-beta-go-sdk v0.6.0 h1:wfM3AcW3zOM3xsRtZ+EA6+sESlGUjQ6Yf4n5QQyz4uc= github.com/IBM/vpc-beta-go-sdk v0.6.0/go.mod h1:fzHDAQIqH/5yJmYsKodKHLcqxMDT+yfH6vZjdiw8CQA= -github.com/IBM/vpc-go-sdk v0.46.0 h1:OwXH3oaYgYmzt559n77AteSpNsW4H1PoeHcR4EOolzk= -github.com/IBM/vpc-go-sdk v0.46.0/go.mod h1:4Hs5d/aClmsxAzwDQkwG+ri0vW2ykPJdpM6hDLRwKcA= +github.com/IBM/vpc-go-sdk v0.47.0 h1:2Qcjd4zQQRYjz+y4ZMDP6+aWGifyXCZ9uMmlpW7p9To= +github.com/IBM/vpc-go-sdk v0.47.0/go.mod h1:4Hs5d/aClmsxAzwDQkwG+ri0vW2ykPJdpM6hDLRwKcA= github.com/Jeffail/gabs v1.1.1 h1:V0uzR08Hj22EX8+8QMhyI9sX2hwRu+/RJhJUmnwda/E= github.com/Jeffail/gabs v1.1.1/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0= diff --git a/ibm/service/vpc/data_source_ibm_is_vpc_routing_table.go b/ibm/service/vpc/data_source_ibm_is_vpc_routing_table.go index c3023bba21..7293a719fd 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpc_routing_table.go +++ b/ibm/service/vpc/data_source_ibm_is_vpc_routing_table.go @@ -60,6 +60,14 @@ func DataSourceIBMIBMIsVPCRoutingTable() *schema.Resource { Description: "The routing table identifier.", }, + "advertise_routes_to": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The ingress sources to advertise routes to. Routes in the table with `advertise` enabled will be advertised to these sources.The enumerated values for this property are expected to expand in the future. When processing this property, check for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the unexpected property value was encountered.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, rtCreateAt: &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -297,6 +305,9 @@ func dataSourceIBMIBMIsVPCRoutingTableRead(context context.Context, d *schema.Re return diag.FromErr(fmt.Errorf("[ERROR] Error setting route_vpc_zone_ingress: %s", err)) } + if err = d.Set("advertise_routes_to", routingTable.AdvertiseRoutesTo); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting value of advertise_routes_to: %s", err)) + } routes := []map[string]interface{}{} if routingTable.Routes != nil { for _, modelItem := range routingTable.Routes { diff --git a/ibm/service/vpc/data_source_ibm_is_vpc_routing_table_route.go b/ibm/service/vpc/data_source_ibm_is_vpc_routing_table_route.go index 2798f27aa8..da18a18571 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpc_routing_table_route.go +++ b/ibm/service/vpc/data_source_ibm_is_vpc_routing_table_route.go @@ -57,6 +57,11 @@ func DataSourceIBMIBMIsVPCRoutingTableRoute() *schema.Resource { Computed: true, Description: "The action to perform with a packet matching the route:- `delegate`: delegate to the system's built-in routes- `delegate_vpc`: delegate to the system's built-in routes, ignoring Internet-bound routes- `deliver`: deliver the packet to the specified `next_hop`- `drop`: drop the packet.", }, + "advertise": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether this route will be advertised to the ingress sources specified by the `advertise_routes_to` routing table property.", + }, rtCreateAt: &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -271,6 +276,10 @@ func dataSourceIBMIBMIsVPCRoutingTableRouteRead(context context.Context, d *sche return diag.FromErr(fmt.Errorf("[ERROR] Error setting action: %s", err)) } + if err = d.Set("advertise", route.Advertise); err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error setting advertise: %s", err)) + } + if err = d.Set(rtCreateAt, flex.DateTimeToString(route.CreatedAt)); err != nil { return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) } diff --git a/ibm/service/vpc/data_source_ibm_is_vpc_routing_table_routes.go b/ibm/service/vpc/data_source_ibm_is_vpc_routing_table_routes.go index a1a5ac299a..205d002bdc 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpc_routing_table_routes.go +++ b/ibm/service/vpc/data_source_ibm_is_vpc_routing_table_routes.go @@ -126,6 +126,11 @@ func DataSourceIBMISVPCRoutingTableRoutes() *schema.Resource { Computed: true, Description: "Routing Table Route Action", }, + "advertise": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether this route will be advertised to the ingress sources specified by the `advertise_routes_to` routing table property.", + }, isRoutingTableRouteDestination: { Type: schema.TypeString, Computed: true, @@ -216,6 +221,9 @@ func dataSourceIBMISVPCRoutingTableRoutesList(d *schema.ResourceData, meta inter if instance.LifecycleState != nil { route[isRoutingTableRouteLifecycleState] = *instance.LifecycleState } + if instance.Advertise != nil { + route["advertise"] = *instance.Advertise + } if instance.Destination != nil { route[isRoutingTableRouteDestination] = *instance.Destination } diff --git a/ibm/service/vpc/data_source_ibm_is_vpc_routing_tables.go b/ibm/service/vpc/data_source_ibm_is_vpc_routing_tables.go index b157c50f04..ffec0e8c74 100644 --- a/ibm/service/vpc/data_source_ibm_is_vpc_routing_tables.go +++ b/ibm/service/vpc/data_source_ibm_is_vpc_routing_tables.go @@ -72,6 +72,14 @@ func DataSourceIBMISVPCRoutingTables() *schema.Resource { Computed: true, Description: "Routing Table ID", }, + "advertise_routes_to": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "The ingress sources to advertise routes to. Routes in the table with `advertise` enabled will be advertised to these sources.The enumerated values for this property are expected to expand in the future. When processing this property, check for and log unknown values. Optionally halt processing and surface the error, or bypass the resource on which the unexpected property value was encountered.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, isRoutingTableHref: { Type: schema.TypeString, Computed: true, @@ -241,6 +249,9 @@ func dataSourceIBMISVPCRoutingTablesList(d *schema.ResourceData, meta interface{ if routingTable.RouteVPCZoneIngress != nil { rtable[isRoutingTableVPCZoneIngress] = *routingTable.RouteVPCZoneIngress } + if routingTable.AdvertiseRoutesTo != nil { + rtable["advertise_routes_to"] = routingTable.AdvertiseRoutesTo + } if routingTable.IsDefault != nil { rtable[isRoutingTableDefault] = *routingTable.IsDefault } diff --git a/ibm/service/vpc/resource_ibm_is_bare_metal_server.go b/ibm/service/vpc/resource_ibm_is_bare_metal_server.go index 94c1ede67f..8e419168b9 100644 --- a/ibm/service/vpc/resource_ibm_is_bare_metal_server.go +++ b/ibm/service/vpc/resource_ibm_is_bare_metal_server.go @@ -696,7 +696,8 @@ func resourceIBMISBareMetalServerCreate(context context.Context, d *schema.Resou if err != nil { return diag.FromErr(err) } - options := &vpcv1.CreateBareMetalServerOptions{} + createbmsoptions := &vpcv1.CreateBareMetalServerOptions{} + options := &vpcv1.BareMetalServerPrototype{} var imageStr string if image, ok := d.GetOk(isBareMetalServerImage); ok { imageStr = image.(string) @@ -705,7 +706,7 @@ func resourceIBMISBareMetalServerCreate(context context.Context, d *schema.Resou // enable secure boot if _, ok := d.GetOkExists(isBareMetalServerEnableSecureBoot); ok { - options.SetEnableSecureBoot(d.Get(isBareMetalServerEnableSecureBoot).(bool)) + options.EnableSecureBoot = core.BoolPtr(d.Get(isBareMetalServerEnableSecureBoot).(bool)) } // trusted_platform_module @@ -715,7 +716,7 @@ func resourceIBMISBareMetalServerCreate(context context.Context, d *schema.Resou if err != nil { return diag.FromErr(err) } - options.SetTrustedPlatformModule(trustedPlatformModuleModel) + options.TrustedPlatformModule = trustedPlatformModuleModel } keySet := d.Get(isBareMetalServerKeys).(*schema.Set) @@ -1300,8 +1301,8 @@ func resourceIBMISBareMetalServerCreate(context context.Context, d *schema.Resou ID: &vpc, } } - - bms, response, err := sess.CreateBareMetalServerWithContext(context, options) + createbmsoptions.BareMetalServerPrototype = options + bms, response, err := sess.CreateBareMetalServerWithContext(context, createbmsoptions) if err != nil { return diag.FromErr(fmt.Errorf("[DEBUG] Create bare metal server err %s\n%s", err, response)) } diff --git a/ibm/service/vpc/resource_ibm_is_vpc_routing_table.go b/ibm/service/vpc/resource_ibm_is_vpc_routing_table.go index 50c6a9c8ce..2935d1817b 100644 --- a/ibm/service/vpc/resource_ibm_is_vpc_routing_table.go +++ b/ibm/service/vpc/resource_ibm_is_vpc_routing_table.go @@ -65,6 +65,14 @@ func ResourceIBMISVPCRoutingTable() *schema.Resource { Set: schema.HashString, Description: "The filters specifying the resources that may create routes in this routing table, The resource type: vpn_gateway or vpn_server", }, + "advertise_routes_to": &schema.Schema{ + Type: schema.TypeSet, + Optional: true, + Computed: true, + Set: schema.HashString, + Description: "The ingress sources to advertise routes to. Routes in the table with `advertise` enabled will be advertised to these sources.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, rtRouteDirectLinkIngress: { Type: schema.TypeBool, ForceNew: false, @@ -209,6 +217,15 @@ func resourceIBMISVPCRoutingTableCreate(d *schema.ResourceData, meta interface{} } createVpcRoutingTableOptions.AcceptRoutesFrom = aroutes } + if _, ok := d.GetOk("advertise_routes_to"); ok { + var advertiseRoutesToList []string + advertiseRoutesTo := d.Get("advertise_routes_to").(*schema.Set) + + for _, val := range advertiseRoutesTo.List() { + advertiseRoutesToList = append(advertiseRoutesToList, val.(string)) + } + createVpcRoutingTableOptions.AdvertiseRoutesTo = advertiseRoutesToList + } if _, ok := d.GetOk(rtRouteInternetIngress); ok { rtRouteInternetIngress := d.Get(rtRouteInternetIngress).(bool) @@ -263,12 +280,22 @@ func resourceIBMISVPCRoutingTableRead(d *schema.ResourceData, meta interface{}) d.Set(rtRouteVPCZoneIngress, routeTable.RouteVPCZoneIngress) d.Set(rtIsDefault, routeTable.IsDefault) acceptRoutesFromArray := make([]string, 0) + advertiseRoutesToArray := make([]string, 0) for i := 0; i < len(routeTable.AcceptRoutesFrom); i++ { acceptRoutesFromArray = append(acceptRoutesFromArray, string(*(routeTable.AcceptRoutesFrom[i].ResourceType))) } if err = d.Set("accept_routes_from_resource_type", acceptRoutesFromArray); err != nil { return fmt.Errorf("[ERROR] Error setting accept_routes_from_resource_type: %s", err) } + + for i := 0; i < len(routeTable.AdvertiseRoutesTo); i++ { + advertiseRoutesToArray = append(advertiseRoutesToArray, routeTable.AdvertiseRoutesTo[i]) + } + + if err = d.Set("advertise_routes_to", advertiseRoutesToArray); err != nil { + return fmt.Errorf("[ERROR] Error setting advertise_routes_to: %s", err) + } + subnets := make([]map[string]interface{}, 0) for _, s := range routeTable.Subnets { @@ -320,6 +347,16 @@ func resourceIBMISVPCRoutingTableUpdate(d *schema.ResourceData, meta interface{} routingTablePatchModel.AcceptRoutesFrom = aroutes hasChange = true } + if d.HasChange("advertise_routes_to") { + var advertiseRoutesToList []string + advertiseRoutesTo := d.Get("advertise_routes_to").(*schema.Set) + + for _, val := range advertiseRoutesTo.List() { + advertiseRoutesToList = append(advertiseRoutesToList, val.(string)) + } + routingTablePatchModel.AdvertiseRoutesTo = advertiseRoutesToList + hasChange = true + } if d.HasChange(rtRouteDirectLinkIngress) { routeDirectLinkIngress := d.Get(rtRouteDirectLinkIngress).(bool) routingTablePatchModel.RouteDirectLinkIngress = core.BoolPtr(routeDirectLinkIngress) diff --git a/ibm/service/vpc/resource_ibm_is_vpc_routing_table_route.go b/ibm/service/vpc/resource_ibm_is_vpc_routing_table_route.go index 2a0495e69c..2862c247f6 100644 --- a/ibm/service/vpc/resource_ibm_is_vpc_routing_table_route.go +++ b/ibm/service/vpc/resource_ibm_is_vpc_routing_table_route.go @@ -78,6 +78,12 @@ func ResourceIBMISVPCRoutingTableRoute() *schema.Resource { Description: "The action to perform with a packet matching the route.", ValidateFunc: validate.InvokeValidator("ibm_is_vpc_routing_table_route", rAction), }, + "advertise": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Indicates whether this route will be advertised to the ingress sources specified by the `advertise_routes_to` routing table property.", + }, rName: { Type: schema.TypeString, Optional: true, @@ -242,6 +248,11 @@ func resourceIBMISVPCRoutingTableRouteCreate(d *schema.ResourceData, meta interf createVpcRoutingTableRouteOptions.SetAction(routeAction) } + if advertiseVal, ok := d.GetOk("advertise"); ok { + advertise := advertiseVal.(bool) + createVpcRoutingTableRouteOptions.SetAdvertise(advertise) + } + if name, ok := d.GetOk(rName); ok { routeName := name.(string) createVpcRoutingTableRouteOptions.SetName(routeName) @@ -282,6 +293,9 @@ func resourceIBMISVPCRoutingTableRouteRead(d *schema.ResourceData, meta interfac } d.Set(rID, *route.ID) + if route.Advertise != nil { + d.Set("Advertise", route.Advertise) + } d.Set(rName, *route.Name) d.Set(rDestination, *route.Destination) if route.NextHop != nil { @@ -329,6 +343,21 @@ func resourceIBMISVPCRoutingTableRouteUpdate(d *schema.ResourceData, meta interf // Construct an instance of the RoutePatch model routePatchModel := new(vpcv1.RoutePatch) + if d.HasChange(rName) || d.HasChange("advertise") { + // Construct an instance of the RoutePatch model + routePatchModel := new(vpcv1.RoutePatch) + if d.HasChange(rName) { + name := d.Get(rName).(string) + routePatchModel.Name = &name + hasChange = true + } + + if d.HasChange("advertise") { + advertiseVal := d.Get("advertise").(bool) + routePatchModel.Advertise = &advertiseVal + hasChange = true + } + } if d.HasChange(rName) { name := d.Get(rName).(string) routePatchModel.Name = &name diff --git a/ibm/service/vpc/resource_ibm_is_vpc_routing_table_route_test.go b/ibm/service/vpc/resource_ibm_is_vpc_routing_table_route_test.go index 5157cbcf68..4ce678bd24 100644 --- a/ibm/service/vpc/resource_ibm_is_vpc_routing_table_route_test.go +++ b/ibm/service/vpc/resource_ibm_is_vpc_routing_table_route_test.go @@ -24,6 +24,8 @@ func TestAccIBMISVPCRoutingTableRoute_basic(t *testing.T) { routeName1 := fmt.Sprintf("tfvpcuat-create-%d", acctest.RandIntRange(10, 100)) routeTableName := fmt.Sprintf("tfvpcrt-create-%d", acctest.RandIntRange(10, 100)) routeTableName1 := fmt.Sprintf("tfvpcrt-up-create-%d", acctest.RandIntRange(10, 100)) + advertiseVal := fmt.Sprintf("tfpvpcuat-create-%d", acctest.RandIntRange(10, 50)) + advertiseValUpd := fmt.Sprintf("tfpvpcuat-update-%d", acctest.RandIntRange(60, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -31,19 +33,23 @@ func TestAccIBMISVPCRoutingTableRoute_basic(t *testing.T) { CheckDestroy: testAccCheckIBMISVPCRouteTableRouteDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckIBMISVPCRouteTableRouteConfig(routeTableName, name1, subnetName, routeName), + Config: testAccCheckIBMISVPCRouteTableRouteConfig(routeTableName, name1, subnetName, routeName, advertiseVal), Check: resource.ComposeTestCheckFunc( testAccCheckIBMISVPCRouteTableRouteExists("ibm_is_vpc_routing_table_route.test_custom_route1", vpcRouteTables), resource.TestCheckResourceAttr( "ibm_is_vpc_routing_table_route.test_custom_route1", "name", routeName), + resource.TestCheckResourceAttr( + "ibm_is_vpc_routing_table_route.test_custom_route1", "advertise", advertiseVal), ), }, { - Config: testAccCheckIBMISVPCRouteTableRouteConfig(routeTableName1, name1, subnetName, routeName1), + Config: testAccCheckIBMISVPCRouteTableRouteConfig(routeTableName1, name1, subnetName, routeName1, advertiseValUpd), Check: resource.ComposeTestCheckFunc( testAccCheckIBMISVPCRouteTableRouteExists("ibm_is_vpc_routing_table_route.test_custom_route1", vpcRouteTables), resource.TestCheckResourceAttr( "ibm_is_vpc_routing_table_route.test_custom_route1", "name", routeName1), + resource.TestCheckResourceAttr( + "ibm_is_vpc_routing_table_route.test_custom_route1", "advertise", advertiseValUpd), ), }, }, @@ -114,7 +120,7 @@ func testAccCheckIBMISVPCRouteTableRouteExists(n, vpcrouteTableID string) resour } } -func testAccCheckIBMISVPCRouteTableRouteConfig(rtName, name, subnetName, routeName string) string { +func testAccCheckIBMISVPCRouteTableRouteConfig(rtName, name, subnetName, routeName, advertise string) string { return fmt.Sprintf(` resource "ibm_is_vpc" "testacc_vpc" { name = "%s" @@ -137,10 +143,11 @@ resource "ibm_is_vpc_routing_table_route" "test_custom_route1" { depends_on = [ibm_is_vpc_routing_table.test_ibm_is_vpc_routing_table, ibm_is_subnet.test_cr_subnet1] vpc = ibm_is_vpc.testacc_vpc.id routing_table = ibm_is_vpc_routing_table.test_ibm_is_vpc_routing_table.routing_table + advertise = "%s" name = "%s" zone = "%s" next_hop = "%s" destination = ibm_is_subnet.test_cr_subnet1.ipv4_cidr_block } -`, name, rtName, subnetName, acc.ISZoneName, acc.ISCIDR, routeName, acc.ISZoneName, acc.ISRouteNextHop) +`, name, rtName, subnetName, acc.ISZoneName, acc.ISCIDR, advertise, routeName, acc.ISZoneName, acc.ISRouteNextHop) } diff --git a/ibm/service/vpc/resource_ibm_is_vpc_routing_table_test.go b/ibm/service/vpc/resource_ibm_is_vpc_routing_table_test.go index 3068c21d0a..39007bf996 100644 --- a/ibm/service/vpc/resource_ibm_is_vpc_routing_table_test.go +++ b/ibm/service/vpc/resource_ibm_is_vpc_routing_table_test.go @@ -89,6 +89,38 @@ func TestAccIBMISVPCRoutingTable_acceptRoutesFrom(t *testing.T) { }) } +// advertise_routes_to +func TestAccIBMISVPCRoutingTable_advertiseRoutesTO(t *testing.T) { + var vpcRouteTables string + name1 := fmt.Sprintf("tfvpc-create-%d", acctest.RandIntRange(10, 100)) + routeTableName := fmt.Sprintf("tfvpcrt-create-%d", acctest.RandIntRange(10, 100)) + routeTableName1 := fmt.Sprintf("tfvpcrt-up-create-%d", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMISVPCRouteTableDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMISVPCRouteTableConfig(routeTableName, name1), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMISVPCRouteTableExists("ibm_is_vpc_routing_table.test_ibm_is_vpc_routing_table", vpcRouteTables), + resource.TestCheckResourceAttrSet( + "ibm_is_vpc_routing_table.test_ibm_is_vpc_routing_table", "advertise_routes_to"), + ), + }, + { + Config: testAccCheckIBMISVPCRouteTableConfig(routeTableName1, name1), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMISVPCRouteTableExists("ibm_is_vpc_routing_table.test_ibm_is_vpc_routing_table", vpcRouteTables), + resource.TestCheckResourceAttrSet( + "ibm_is_vpc_routing_table.test_ibm_is_vpc_routing_table", "advertise_routes_to"), + ), + }, + }, + }) +} + func testAccCheckIBMISVPCRouteTableDestroy(s *terraform.State) error { //userDetails, _ := acc.TestAccProvider.Meta().(conns.ClientSession).BluemixUserDetails() diff --git a/website/docs/d/is_vpc_routing_table.html.markdown b/website/docs/d/is_vpc_routing_table.html.markdown index 752281c49c..04f6388bcd 100644 --- a/website/docs/d/is_vpc_routing_table.html.markdown +++ b/website/docs/d/is_vpc_routing_table.html.markdown @@ -52,6 +52,11 @@ In addition to all argument references listed, you can access the following attr - `accept_routes_from` - (List) The filters specifying the resources that may create routes in this routing table.At present, only the `resource_type` filter is permitted, and only the `vpn_gateway` value is supported, but filter support is expected to expand in the future. Nested scheme for **accept_routes_from**: - `resource_type` - (String) The resource type. +- `advertise_routes_to` - (Optional, List) The ingress sources to advertise routes to. Routes in the table with `advertise` enabled will be advertised to these sources. + + ->**Options** An ingress source that routes can be advertised to:
+ **•** `direct_link` (requires `route_direct_link_ingress` be set to `true`)
+ **•** `transit_gateway` (requires `route_transit_gateway_ingress` be set to `true`) - `created_at` - (String) The date and time that this routing table was created. - `href` - (String) The URL for this routing table. - `id` - (String) The unique identifier of the RoutingTable. diff --git a/website/docs/d/is_vpc_routing_table_route.html.markdown b/website/docs/d/is_vpc_routing_table_route.html.markdown index 858af62286..ace775cc16 100644 --- a/website/docs/d/is_vpc_routing_table_route.html.markdown +++ b/website/docs/d/is_vpc_routing_table_route.html.markdown @@ -54,6 +54,7 @@ Review the argument reference that you can specify for your data source. In addition to all argument references listed, you can access the following attribute references after your data source is created. - `action` - (String) The action to perform with a packet matching the route, allowable values are: `delegate`, `delegate_vpc`, `deliver`, `drop`. +- `advertise` - (Boolean) Indicates whether this route will be advertised to the ingress sources specified by the `advertise_routes_to` routing table property. - `delegate`: delegate to the system's built-in routes - `delegate_vpc`: delegate to the system's built-in routes, ignoring Internet-bound routes - `deliver`: deliver the packet to the specified `next_hop` diff --git a/website/docs/d/is_vpc_routing_table_routes.html.markdown b/website/docs/d/is_vpc_routing_table_routes.html.markdown index 2d906396de..7ada595c45 100644 --- a/website/docs/d/is_vpc_routing_table_routes.html.markdown +++ b/website/docs/d/is_vpc_routing_table_routes.html.markdown @@ -72,6 +72,7 @@ In addition to all argument reference list, you can access the following attribu - `resource_type` - (String) The resource type. - Constraints: Allowable values are: `vpn_gateway`. The maximum length is `128` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z][a-z0-9]*(_[a-z0-9]+)*$/`. - `action` - (String) The action to perform with a packet matching the route. + - `advertise` - (Boolean) Indicates whether this route will be advertised to the ingress sources specified by the `advertise_routes_to` routing table property. - `destination` - (String) The destination of the route. - `next_hop` - (String) The next hop address of the route. - `origin` - (String) The origin of this route:- `service`: route was directly created by a service - `user`: route was directly created by a userThe enumerated values for this property are expected to expand in the future. When processing this property, check for and log unknown values. Optionally halt processing and surface the error, or bypass the route on which the unexpected property value was encountered. diff --git a/website/docs/d/is_vpc_routing_tables.html.markdown b/website/docs/d/is_vpc_routing_tables.html.markdown index b38983b1be..d7b750a62d 100644 --- a/website/docs/d/is_vpc_routing_tables.html.markdown +++ b/website/docs/d/is_vpc_routing_tables.html.markdown @@ -48,6 +48,11 @@ In addition to the argument reference list, you can access the following attribu - `accept_routes_from` - (List) The filters specifying the resources that may create routes in this routing table.At present, only the `resource_type` filter is permitted, and only the `vpn_gateway` value is supported, but filter support is expected to expand in the future. Nested scheme for **accept_routes_from**: - `resource_type` - (String) The resource type. + - `advertise_routes_to` - (Optional, List) The ingress sources to advertise routes to. Routes in the table with `advertise` enabled will be advertised to these sources. + + ->**Options** An ingress source that routes can be advertised to:
+ **•** `direct_link` (requires `route_direct_link_ingress` be set to `true`)
+ **•** `transit_gateway` (requires `route_transit_gateway_ingress` be set to `true`) - `created_at` - (Timestamp) The date and time the routing table was created. - `href` - (String) The routing table URL. - `is_default` - (String) Indicates whether the default routing table. diff --git a/website/docs/r/is_vpc_routing_table.html.markdown b/website/docs/r/is_vpc_routing_table.html.markdown index e84b962497..ace815208c 100644 --- a/website/docs/r/is_vpc_routing_table.html.markdown +++ b/website/docs/r/is_vpc_routing_table.html.markdown @@ -38,11 +38,27 @@ resource "ibm_is_vpc_routing_table" "example" { ``` +## Example usage: Advertising routes +``` +resource "ibm_is_vpc" "example" { + name = "example-vpc" +} +resource "ibm_is_vpc_routing_table" "is_vpc_routing_table_instance" { + vpc = ibm_is_vpc.example.id + name = "example-vpc-routing-table" + route_direct_link_ingress = true + route_transit_gateway_ingress = false + route_vpc_zone_ingress = false + advertise_routes_to = ["direct_link", "transit_gateway"] + +} +``` # Example usage for accept_routes_from_resource_type ```terraform resource "ibm_is_vpc" "example" { name = "example-vpc" } + resource "ibm_is_vpc_routing_table" "example" { vpc = ibm_is_vpc.example.id name = "example-vpc-routing-table" @@ -51,10 +67,17 @@ resource "ibm_is_vpc_routing_table" "example" { route_vpc_zone_ingress = false accept_routes_from_resource_type = ["vpn_server"] } - ``` + + ## Argument reference Review the argument references that you can specify for your resource. + +- `advertise_routes_to` - (Optional, List) The ingress sources to advertise routes to. Routes in the table with `advertise` enabled will be advertised to these sources. + + ->**Options** An ingress source that routes can be advertised to:
+ **•** `direct_link` (requires `route_direct_link_ingress` be set to `true`)
+ **•** `transit_gateway` (requires `route_transit_gateway_ingress` be set to `true`) - `accept_routes_from_resource_type` - (Optional, List) The resource type filter specifying the resources that may create routes in this routing table. Ex: `vpn_server`, `vpn_gateway` - `created_at` - (Timestamp) The date and time when the routing table was created. - `name` - (Optional, String) The routing table name. diff --git a/website/docs/r/is_vpc_routing_table_route.html.markdown b/website/docs/r/is_vpc_routing_table_route.html.markdown index 234faacca6..b17eec3634 100644 --- a/website/docs/r/is_vpc_routing_table_route.html.markdown +++ b/website/docs/r/is_vpc_routing_table_route.html.markdown @@ -30,7 +30,8 @@ resource "ibm_is_vpc" "example" { resource "ibm_is_vpc_routing_table" "example" { vpc = ibm_is_vpc.example.id name = "example-routing-table" - route_direct_link_ingress = false + advertise_routes_to = ["direct_link", "transit_gateway"] + route_direct_link_ingress = true route_transit_gateway_ingress = false route_vpc_zone_ingress = false } @@ -41,6 +42,7 @@ resource "ibm_is_vpc_routing_table_route" "example" { name = "custom-route-2" destination = "192.168.4.0/24" action = "deliver" + advertise = true next_hop = ibm_is_vpn_gateway_connection.example.gateway_connection // Example value "10.0.0.4" } ``` @@ -63,6 +65,7 @@ resource "ibm_is_vpc_routing_table_route" "example" { Review the argument references that you can specify for your resource. - `action` - (Optional, String) The action to perform with a packet matching the route `delegate`, `delegate_vpc`, `deliver`, `drop`. +- `advertise` - (Optional, Bool) Indicates whether this route will be advertised to the ingress sources specified by the `advertise_routes_to` routing table's property. - `destination` - (Required, Forces new resource, String) The destination of the route. - `name` - (Optional, String) The user-defined name of the route. If unspecified, the name will be a hyphenated list of randomly selected words. You need to provide unique name within the VPC routing table the route resides in. - `next_hop` - (Required, String) The next hop of the route. It accepts IP address or a VPN gateway connection ID (`ibm_is_vpn_gateway_connection`) of a VPN Gateway (`ibm_is_vpn_gateway`) with the `mode = "route"` argument and in the same VPC as the route table for this route for an egress route. For action other than deliver, you must specify `0.0.0.0`. From ab4912c3d834062af38f613b074431c7ffbbcca9 Mon Sep 17 00:00:00 2001 From: yonatanyell <69857977+yonatanyell@users.noreply.github.com> Date: Fri, 29 Dec 2023 12:31:51 +0200 Subject: [PATCH 3/7] Bugs fixes for Secrets Manager (#5008) * SC addition * SC addition * SC addition * update function updated * SC unit tests added * SC unit tests added * d * tests fixes * tests fixes * update sdk * .secrets.baseline update * .secrets.baseline update * .secrets.baseline update * Update sm_service_credentials_secret_metadata.html.markdown * bugs fixes * bugs fixes * bugs fixes --------- Co-authored-by: Yonathan-Yellin Co-authored-by: Avi Ribchinsky Co-authored-by: Tatyana Co-authored-by: Idan Adar --- .secrets.baseline | 60 ++++++++++++------- ...ta_source_ibm_sm_iam_credentials_secret.go | 8 --- ..._ibm_sm_iam_credentials_secret_metadata.go | 8 --- .../data_source_ibm_sm_private_certificate.go | 8 --- ...rce_ibm_sm_private_certificate_metadata.go | 8 --- ..._source_ibm_sm_username_password_secret.go | 8 --- ...bm_sm_username_password_secret_metadata.go | 8 --- .../resource_ibm_sm_iam_credentials_secret.go | 12 ---- .../resource_ibm_sm_private_certificate.go | 3 +- .../d/sm_iam_credentials_secret.html.markdown | 1 - ..._credentials_secret_metadata.html.markdown | 1 - .../d/sm_private_certificate.html.markdown | 1 - ...private_certificate_metadata.html.markdown | 1 - .../sm_username_password_secret.html.markdown | 1 - ...ame_password_secret_metadata.html.markdown | 1 - .../r/sm_iam_credentials_secret.html.markdown | 1 - .../r/sm_private_certificate.html.markdown | 1 - ...icate_configuration_template.html.markdown | 2 + .../sm_username_password_secret.html.markdown | 1 - 19 files changed, 42 insertions(+), 92 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 13208250a4..dae78c7d80 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-12-20T09:37:58Z", + "generated_at": "2023-12-26T12:35:45Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -3224,7 +3224,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 185, + "line_number": 180, "type": "Secret Keyword", "verified_result": null }, @@ -3232,7 +3232,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 312, + "line_number": 307, "type": "Secret Keyword", "verified_result": null } @@ -3250,7 +3250,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 291, + "line_number": 286, "type": "Secret Keyword", "verified_result": null } @@ -3298,7 +3298,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 235, + "line_number": 230, "type": "Secret Keyword", "verified_result": null }, @@ -3306,7 +3306,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 414, + "line_number": 409, "type": "Secret Keyword", "verified_result": null } @@ -3510,7 +3510,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 162, + "line_number": 157, "type": "Secret Keyword", "verified_result": null }, @@ -3518,7 +3518,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 278, + "line_number": 273, "type": "Secret Keyword", "verified_result": null } @@ -3556,7 +3556,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 204, + "line_number": 198, "type": "Secret Keyword", "verified_result": null }, @@ -3564,7 +3564,7 @@ "hashed_secret": "108b310facc1a193833fc2971fd83081f775ea0c", "is_secret": false, "is_verified": false, - "line_number": 395, + "line_number": 389, "type": "Secret Keyword", "verified_result": null }, @@ -3572,7 +3572,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 398, + "line_number": 392, "type": "Secret Keyword", "verified_result": null } @@ -3636,7 +3636,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 298, + "line_number": 297, "type": "Secret Keyword", "verified_result": null }, @@ -3644,7 +3644,7 @@ "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", "is_secret": false, "is_verified": false, - "line_number": 539, + "line_number": 538, "type": "Secret Keyword", "verified_result": null } @@ -3831,6 +3831,24 @@ "verified_result": null } ], + "ibm/service/secretsmanager/resource_ibm_sm_service_credentilas_secret.go": [ + { + "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", + "is_secret": false, + "is_verified": false, + "line_number": 190, + "type": "Secret Keyword", + "verified_result": null + }, + { + "hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f", + "is_secret": false, + "is_verified": false, + "line_number": 443, + "type": "Secret Keyword", + "verified_result": null + } + ], "ibm/service/secretsmanager/resource_ibm_sm_username_password_secret.go": [ { "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", @@ -4736,7 +4754,7 @@ "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", "is_secret": false, "is_verified": false, - "line_number": 128, + "line_number": 127, "type": "Secret Keyword", "verified_result": null }, @@ -4744,7 +4762,7 @@ "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", "is_secret": false, "is_verified": false, - "line_number": 130, + "line_number": 129, "type": "Secret Keyword", "verified_result": null } @@ -4790,7 +4808,7 @@ "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", "is_secret": false, "is_verified": false, - "line_number": 148, + "line_number": 147, "type": "Secret Keyword", "verified_result": null }, @@ -4798,7 +4816,7 @@ "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", "is_secret": false, "is_verified": false, - "line_number": 150, + "line_number": 149, "type": "Secret Keyword", "verified_result": null } @@ -4844,7 +4862,7 @@ "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", "is_secret": false, "is_verified": false, - "line_number": 137, + "line_number": 139, "type": "Secret Keyword", "verified_result": null }, @@ -4852,7 +4870,7 @@ "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", "is_secret": false, "is_verified": false, - "line_number": 139, + "line_number": 141, "type": "Secret Keyword", "verified_result": null } @@ -5010,7 +5028,7 @@ "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", "is_secret": false, "is_verified": false, - "line_number": 122, + "line_number": 121, "type": "Secret Keyword", "verified_result": null }, @@ -5018,7 +5036,7 @@ "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", "is_secret": false, "is_verified": false, - "line_number": 124, + "line_number": 123, "type": "Secret Keyword", "verified_result": null } diff --git a/ibm/service/secretsmanager/data_source_ibm_sm_iam_credentials_secret.go b/ibm/service/secretsmanager/data_source_ibm_sm_iam_credentials_secret.go index 75ad6a8306..bce495303b 100644 --- a/ibm/service/secretsmanager/data_source_ibm_sm_iam_credentials_secret.go +++ b/ibm/service/secretsmanager/data_source_ibm_sm_iam_credentials_secret.go @@ -169,11 +169,6 @@ func DataSourceIbmSmIamCredentialsSecret() *schema.Resource { Computed: true, Description: "The units for the secret rotation time interval.", }, - "rotate_keys": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate.", - }, }, }, }, @@ -330,9 +325,6 @@ func dataSourceIbmSmIamCredentialsSecretRotationPolicyToMap(model secretsmanager if model.Unit != nil { modelMap["unit"] = *model.Unit } - if model.RotateKeys != nil { - modelMap["rotate_keys"] = *model.RotateKeys - } return modelMap, nil } else { return nil, fmt.Errorf("Unrecognized secretsmanagerv2.RotationPolicyIntf subtype encountered") diff --git a/ibm/service/secretsmanager/data_source_ibm_sm_iam_credentials_secret_metadata.go b/ibm/service/secretsmanager/data_source_ibm_sm_iam_credentials_secret_metadata.go index d1124752b9..f58be6333d 100644 --- a/ibm/service/secretsmanager/data_source_ibm_sm_iam_credentials_secret_metadata.go +++ b/ibm/service/secretsmanager/data_source_ibm_sm_iam_credentials_secret_metadata.go @@ -161,11 +161,6 @@ func DataSourceIbmSmIamCredentialsSecretMetadata() *schema.Resource { Computed: true, Description: "The units for the secret rotation time interval.", }, - "rotate_keys": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate.", - }, }, }, }, @@ -325,9 +320,6 @@ func dataSourceIbmSmIamCredentialsSecretMetadataRotationPolicyToMap(model secret if model.Unit != nil { modelMap["unit"] = *model.Unit } - if model.RotateKeys != nil { - modelMap["rotate_keys"] = *model.RotateKeys - } return modelMap, nil } else { return nil, fmt.Errorf("Unrecognized secretsmanagerv2.RotationPolicyIntf subtype encountered") diff --git a/ibm/service/secretsmanager/data_source_ibm_sm_private_certificate.go b/ibm/service/secretsmanager/data_source_ibm_sm_private_certificate.go index 31043b4a78..59ce4a1fa8 100644 --- a/ibm/service/secretsmanager/data_source_ibm_sm_private_certificate.go +++ b/ibm/service/secretsmanager/data_source_ibm_sm_private_certificate.go @@ -184,11 +184,6 @@ func DataSourceIbmSmPrivateCertificate() *schema.Resource { Computed: true, Description: "The units for the secret rotation time interval.", }, - "rotate_keys": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate.", - }, }, }, }, @@ -436,9 +431,6 @@ func dataSourceIbmSmPrivateCertificateRotationPolicyToMap(model secretsmanagerv2 if model.Unit != nil { modelMap["unit"] = *model.Unit } - if model.RotateKeys != nil { - modelMap["rotate_keys"] = *model.RotateKeys - } return modelMap, nil } else { return nil, fmt.Errorf("Unrecognized secretsmanagerv2.RotationPolicyIntf subtype encountered") diff --git a/ibm/service/secretsmanager/data_source_ibm_sm_private_certificate_metadata.go b/ibm/service/secretsmanager/data_source_ibm_sm_private_certificate_metadata.go index 1585e1a831..a1afb4a638 100644 --- a/ibm/service/secretsmanager/data_source_ibm_sm_private_certificate_metadata.go +++ b/ibm/service/secretsmanager/data_source_ibm_sm_private_certificate_metadata.go @@ -176,11 +176,6 @@ func DataSourceIbmSmPrivateCertificateMetadata() *schema.Resource { Computed: true, Description: "The units for the secret rotation time interval.", }, - "rotate_keys": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate.", - }, }, }, }, @@ -403,9 +398,6 @@ func dataSourceIbmSmPrivateCertificateMetadataRotationPolicyToMap(model secretsm if model.Unit != nil { modelMap["unit"] = *model.Unit } - if model.RotateKeys != nil { - modelMap["rotate_keys"] = *model.RotateKeys - } return modelMap, nil } else { return nil, fmt.Errorf("Unrecognized secretsmanagerv2.RotationPolicyIntf subtype encountered") diff --git a/ibm/service/secretsmanager/data_source_ibm_sm_username_password_secret.go b/ibm/service/secretsmanager/data_source_ibm_sm_username_password_secret.go index 5a9fa84aff..a1119f17e0 100644 --- a/ibm/service/secretsmanager/data_source_ibm_sm_username_password_secret.go +++ b/ibm/service/secretsmanager/data_source_ibm_sm_username_password_secret.go @@ -136,11 +136,6 @@ func DataSourceIbmSmUsernamePasswordSecret() *schema.Resource { Computed: true, Description: "The units for the secret rotation time interval.", }, - "rotate_keys": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate.", - }, }, }, }, @@ -296,9 +291,6 @@ func dataSourceIbmSmUsernamePasswordSecretRotationPolicyToMap(model secretsmanag if model.Unit != nil { modelMap["unit"] = *model.Unit } - if model.RotateKeys != nil { - modelMap["rotate_keys"] = *model.RotateKeys - } return modelMap, nil } else { return nil, fmt.Errorf("Unrecognized secretsmanagerv2.RotationPolicyIntf subtype encountered") diff --git a/ibm/service/secretsmanager/data_source_ibm_sm_username_password_secret_metadata.go b/ibm/service/secretsmanager/data_source_ibm_sm_username_password_secret_metadata.go index 35d24ef67b..6eada6eb8b 100644 --- a/ibm/service/secretsmanager/data_source_ibm_sm_username_password_secret_metadata.go +++ b/ibm/service/secretsmanager/data_source_ibm_sm_username_password_secret_metadata.go @@ -128,11 +128,6 @@ func DataSourceIbmSmUsernamePasswordSecretMetadata() *schema.Resource { Computed: true, Description: "The units for the secret rotation time interval.", }, - "rotate_keys": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate.", - }, }, }, }, @@ -282,9 +277,6 @@ func dataSourceIbmSmUsernamePasswordSecretMetadataRotationPolicyToMap(model secr if model.Unit != nil { modelMap["unit"] = *model.Unit } - if model.RotateKeys != nil { - modelMap["rotate_keys"] = *model.RotateKeys - } return modelMap, nil } else { return nil, fmt.Errorf("Unrecognized secretsmanagerv2.RotationPolicyIntf subtype encountered") diff --git a/ibm/service/secretsmanager/resource_ibm_sm_iam_credentials_secret.go b/ibm/service/secretsmanager/resource_ibm_sm_iam_credentials_secret.go index e47da2cee7..542275b142 100644 --- a/ibm/service/secretsmanager/resource_ibm_sm_iam_credentials_secret.go +++ b/ibm/service/secretsmanager/resource_ibm_sm_iam_credentials_secret.go @@ -113,12 +113,6 @@ func ResourceIbmSmIamCredentialsSecret() *schema.Resource { Description: "The units for the secret rotation time interval.", DiffSuppressFunc: rotationAttributesDiffSuppress, }, - "rotate_keys": &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Computed: true, - Description: "Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate.", - }, }, }, }, @@ -576,9 +570,6 @@ func resourceIbmSmIamCredentialsSecretMapToRotationPolicy(modelMap map[string]in if modelMap["unit"] != nil && modelMap["unit"].(string) != "" { model.Unit = core.StringPtr(modelMap["unit"].(string)) } - if modelMap["rotate_keys"] != nil { - model.RotateKeys = core.BoolPtr(modelMap["rotate_keys"].(bool)) - } return model, nil } @@ -594,8 +585,5 @@ func resourceIbmSmIamCredentialsSecretRotationPolicyToMap(modelIntf secretsmanag if model.Unit != nil { modelMap["unit"] = model.Unit } - if model.RotateKeys != nil { - modelMap["rotate_keys"] = model.RotateKeys - } return modelMap, nil } diff --git a/ibm/service/secretsmanager/resource_ibm_sm_private_certificate.go b/ibm/service/secretsmanager/resource_ibm_sm_private_certificate.go index dfbbc39e69..7fe6c10bd6 100644 --- a/ibm/service/secretsmanager/resource_ibm_sm_private_certificate.go +++ b/ibm/service/secretsmanager/resource_ibm_sm_private_certificate.go @@ -245,9 +245,8 @@ func ResourceIbmSmPrivateCertificate() *schema.Resource { }, "key_algorithm": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, ForceNew: true, - Default: "RSA2048", Description: "The identifier for the cryptographic algorithm to be used to generate the public key that is associated with the certificate.The algorithm that you select determines the encryption algorithm (`RSA` or `ECDSA`) and key size to be used to generate keys and sign certificates. For longer living certificates, it is recommended to use longer keys to provide more encryption protection. Allowed values: RSA2048, RSA4096, EC256, EC384.", }, "next_rotation_date": &schema.Schema{ diff --git a/website/docs/d/sm_iam_credentials_secret.html.markdown b/website/docs/d/sm_iam_credentials_secret.html.markdown index 8355a081f0..79fe4ce3c0 100644 --- a/website/docs/d/sm_iam_credentials_secret.html.markdown +++ b/website/docs/d/sm_iam_credentials_secret.html.markdown @@ -93,7 +93,6 @@ Nested scheme for **rotation**: * `auto_rotate` - (Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. diff --git a/website/docs/d/sm_iam_credentials_secret_metadata.html.markdown b/website/docs/d/sm_iam_credentials_secret_metadata.html.markdown index e429c1892f..1db8123221 100644 --- a/website/docs/d/sm_iam_credentials_secret_metadata.html.markdown +++ b/website/docs/d/sm_iam_credentials_secret_metadata.html.markdown @@ -74,7 +74,6 @@ Nested scheme for **rotation**: * `auto_rotate` - (Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. diff --git a/website/docs/d/sm_private_certificate.html.markdown b/website/docs/d/sm_private_certificate.html.markdown index 22bc586770..abecd98dc0 100644 --- a/website/docs/d/sm_private_certificate.html.markdown +++ b/website/docs/d/sm_private_certificate.html.markdown @@ -119,7 +119,6 @@ In addition to all argument references listed, you can access the following attr * `auto_rotate` - (Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. diff --git a/website/docs/d/sm_private_certificate_metadata.html.markdown b/website/docs/d/sm_private_certificate_metadata.html.markdown index caf491c86c..4d16d2b1a8 100644 --- a/website/docs/d/sm_private_certificate_metadata.html.markdown +++ b/website/docs/d/sm_private_certificate_metadata.html.markdown @@ -90,7 +90,6 @@ Nested scheme for **rotation**: * `auto_rotate` - (Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. diff --git a/website/docs/d/sm_username_password_secret.html.markdown b/website/docs/d/sm_username_password_secret.html.markdown index c18a55df9c..64768e067f 100644 --- a/website/docs/d/sm_username_password_secret.html.markdown +++ b/website/docs/d/sm_username_password_secret.html.markdown @@ -88,7 +88,6 @@ Nested scheme for **rotation**: * `auto_rotate` - (Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. diff --git a/website/docs/d/sm_username_password_secret_metadata.html.markdown b/website/docs/d/sm_username_password_secret_metadata.html.markdown index e4a10d832b..781f524f1a 100644 --- a/website/docs/d/sm_username_password_secret_metadata.html.markdown +++ b/website/docs/d/sm_username_password_secret_metadata.html.markdown @@ -69,7 +69,6 @@ Nested scheme for **rotation**: * `auto_rotate` - (Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. diff --git a/website/docs/r/sm_iam_credentials_secret.html.markdown b/website/docs/r/sm_iam_credentials_secret.html.markdown index 2f3e78f8f6..3c108eb82c 100644 --- a/website/docs/r/sm_iam_credentials_secret.html.markdown +++ b/website/docs/r/sm_iam_credentials_secret.html.markdown @@ -55,7 +55,6 @@ Nested scheme for **rotation**: * `auto_rotate` - (Optional, Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Optional, Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Optional, Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (Optional, String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. * `secret_group_id` - (Optional, Forces new resource, String) A v4 UUID identifier, or `default` secret group. diff --git a/website/docs/r/sm_private_certificate.html.markdown b/website/docs/r/sm_private_certificate.html.markdown index 64f1bb83b7..98c1d2c122 100644 --- a/website/docs/r/sm_private_certificate.html.markdown +++ b/website/docs/r/sm_private_certificate.html.markdown @@ -56,7 +56,6 @@ Nested scheme for **rotation**: * `auto_rotate` - (Optional, Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Optional, Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Optional, Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (Optional, String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. * `secret_group_id` - (Optional, Forces new resource, String) A v4 UUID identifier, or `default` secret group. diff --git a/website/docs/r/sm_private_certificate_configuration_template.html.markdown b/website/docs/r/sm_private_certificate_configuration_template.html.markdown index d34b20e904..00f6d033fd 100644 --- a/website/docs/r/sm_private_certificate_configuration_template.html.markdown +++ b/website/docs/r/sm_private_certificate_configuration_template.html.markdown @@ -67,6 +67,7 @@ Review the argument reference that you can specify for your resource. * Constraints: The list items must match regular expression `/^[a-zA-Z]+$/`. The maximum length is `100` items. The minimum length is `0` items. * `locality` - (Optional, Forces new resource, List) The Locality (L) values to define in the subject field of the resulting certificate. * Constraints: The list items must match regular expression `/(.*?)/`. The maximum length is `10` items. The minimum length is `0` items. +* `max_ttl` - (Optional, String) The maximum time-to-live (TTL) for certificates that are created by this template. * `name` - (Required, String) A human-readable unique name to assign to your configuration. * `organization` - (Optional, Forces new resource, List) The Organization (O) values to define in the subject field of the resulting certificate. * Constraints: The list items must match regular expression `/(.*?)/`. The maximum length is `10` items. The minimum length is `0` items. @@ -84,6 +85,7 @@ Review the argument reference that you can specify for your resource. * Constraints: The maximum length is `64` characters. The minimum length is `32` characters. The value must match regular expression `/[^a-fA-F0-9]/`. * `street_address` - (Optional, Forces new resource, List) The street address values to define in the subject field of the resulting certificate. * Constraints: The list items must match regular expression `/(.*?)/`. The maximum length is `10` items. The minimum length is `0` items. +* `ttl` - The requested time-to-live (TTL) for certificates that are created by this template. This field's value can't be longer than the max_ttl limit. * `use_csr_common_name` - (Optional, Boolean) When used with the `private_cert_configuration_action_sign_csr` action, this field determines whether to use the common name (CN) from a certificate signing request (CSR) instead of the CN that's included in the data of the certificate.Does not include any requested Subject Alternative Names (SANs) in the CSR. To use the alternative names, include the `use_csr_sans` property. * `use_csr_sans` - (Optional, Boolean) When used with the `private_cert_configuration_action_sign_csr` action, this field determines whether to use the Subject Alternative Names(SANs) from a certificate signing request (CSR) instead of the SANs that are included in the data of the certificate.Does not include the common name in the CSR. To use the common name, include the `use_csr_common_name` property. diff --git a/website/docs/r/sm_username_password_secret.html.markdown b/website/docs/r/sm_username_password_secret.html.markdown index b8a07c3af0..fdb4605f15 100644 --- a/website/docs/r/sm_username_password_secret.html.markdown +++ b/website/docs/r/sm_username_password_secret.html.markdown @@ -55,7 +55,6 @@ Nested scheme for **rotation**: * `auto_rotate` - (Optional, Boolean) Determines whether Secrets Manager rotates your secret automatically.Default is `false`. If `auto_rotate` is set to `true` the service rotates your secret based on the defined interval. * `interval` - (Optional, Integer) The length of the secret rotation time interval. * Constraints: The minimum value is `1`. - * `rotate_keys` - (Optional, Boolean) Determines whether Secrets Manager rotates the private key for your public certificate automatically.Default is `false`. If it is set to `true`, the service generates and stores a new private key for your rotated certificate. * `unit` - (Optional, String) The units for the secret rotation time interval. * Constraints: Allowable values are: `day`, `month`. * `secret_group_id` - (Optional, Forces new resource, String) A v4 UUID identifier, or `default` secret group. From 38dd47ede177ae206b89822ef9c6aeb6853ef223 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:13:14 +0000 Subject: [PATCH 4/7] dependabot: bump crazy-max/ghaction-import-gpg from 6.0.0 to 6.1.0 Bumps [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) from 6.0.0 to 6.1.0. - [Release notes](https://github.com/crazy-max/ghaction-import-gpg/releases) - [Commits](https://github.com/crazy-max/ghaction-import-gpg/compare/v6.0.0...v6.1.0) --- updated-dependencies: - dependency-name: crazy-max/ghaction-import-gpg dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15f3a980ec..2bf9694fad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,7 @@ jobs: - name: Import GPG key id: import_gpg - uses: crazy-max/ghaction-import-gpg@v6.0.0 + uses: crazy-max/ghaction-import-gpg@v6.1.0 with: # These secrets will need to be configured for the repository: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} From 7bdec7ee8a6c2996e6f05e56d15a6f3d3baef5ff Mon Sep 17 00:00:00 2001 From: Shuaib Bapputty <42908782+shuaibabubakker@users.noreply.github.com> Date: Tue, 2 Jan 2024 12:34:57 +0530 Subject: [PATCH 5/7] fix: add multipart support for mqcloud service (#5010) * fix: multipart fix for mqcloud (cherry picked from commit e7253421db30943d3582ce07d9504a2117f30ce1) * enable enforceReservedDeploymentPlan --------- Co-authored-by: Shuaib Bapputty --- examples/ibm-mqcloud/README.md | 330 ++++++++++++++---- examples/ibm-mqcloud/main.tf | 27 +- examples/ibm-mqcloud/variables.tf | 62 ++-- go.mod | 2 +- go.sum | 4 +- ibm/acctest/acctest.go | 42 ++- ibm/conns/config.go | 22 +- .../data_source_ibm_mqcloud_application.go | 6 +- ...ata_source_ibm_mqcloud_application_test.go | 40 +-- ...source_ibm_mqcloud_keystore_certificate.go | 4 +- ...e_ibm_mqcloud_keystore_certificate_test.go | 59 +--- .../data_source_ibm_mqcloud_queue_manager.go | 4 +- ...a_source_ibm_mqcloud_queue_manager_test.go | 13 +- ...urce_ibm_mqcloud_truststore_certificate.go | 4 +- ...ibm_mqcloud_truststore_certificate_test.go | 58 +-- .../mqcloud/data_source_ibm_mqcloud_user.go | 4 +- .../data_source_ibm_mqcloud_user_test.go | 42 +-- .../resource_ibm_mqcloud_application_test.go | 33 +- ...source_ibm_mqcloud_keystore_certificate.go | 36 +- ...e_ibm_mqcloud_keystore_certificate_test.go | 47 +-- .../resource_ibm_mqcloud_queue_manager.go | 9 +- ...resource_ibm_mqcloud_queue_manager_test.go | 15 +- ...urce_ibm_mqcloud_truststore_certificate.go | 36 +- ...ibm_mqcloud_truststore_certificate_test.go | 47 +-- .../mqcloud/resource_ibm_mqcloud_user_test.go | 36 +- ibm/service/mqcloud/utils.go | 7 +- ...mqcloud_keystore_certificate.html.markdown | 9 +- .../r/mqcloud_queue_manager.html.markdown | 2 +- ...cloud_truststore_certificate.html.markdown | 9 +- 29 files changed, 448 insertions(+), 561 deletions(-) diff --git a/examples/ibm-mqcloud/README.md b/examples/ibm-mqcloud/README.md index ae8ef2a8dd..05d15097c6 100644 --- a/examples/ibm-mqcloud/README.md +++ b/examples/ibm-mqcloud/README.md @@ -1,14 +1,21 @@ -# Example for MqcloudV1 +# Examples for MQ on Cloud -This example illustrates how to use the MqcloudV1 +These examples illustrate how to use the resources and data sources associated with MQ on Cloud. -The following types of resources are supported: +The following resources are supported: +* ibm_mqcloud_queue_manager +* ibm_mqcloud_application +* ibm_mqcloud_user +* ibm_mqcloud_keystore_certificate +* ibm_mqcloud_truststore_certificate -* mqcloud_queue_manager -* mqcloud_application -* mqcloud_user -* mqcloud_keystore_certificate -* mqcloud_truststore_certificate +The following data sources are supported: +* ibm_mqcloud_queue_manager +* ibm_mqcloud_queue_manager_status +* ibm_mqcloud_application +* ibm_mqcloud_user +* ibm_mqcloud_truststore_certificate +* ibm_mqcloud_keystore_certificate ## Usage @@ -22,13 +29,12 @@ $ terraform apply Run `terraform destroy` when you don't need these resources. +## MQ on Cloud resources -## MqcloudV1 resources - -mqcloud_queue_manager resource: +### Resource: ibm_mqcloud_queue_manager ```hcl -resource "mqcloud_queue_manager" "mqcloud_queue_manager_instance" { +resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { service_instance_guid = var.mqcloud_queue_manager_service_instance_guid name = var.mqcloud_queue_manager_name display_name = var.mqcloud_queue_manager_display_name @@ -37,95 +43,301 @@ resource "mqcloud_queue_manager" "mqcloud_queue_manager_instance" { version = var.mqcloud_queue_manager_version } ``` -mqcloud_application resource: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| name | A queue manager name conforming to MQ restrictions. | `string` | true | +| display_name | A displayable name for the queue manager - limited only in length. | `string` | false | +| location | The locations in which the queue manager could be deployed. | `string` | true | +| size | The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available. | `string` | true | +| version | The MQ version of the queue manager. | `string` | false | + +#### Outputs + +| Name | Description | +|------|-------------| +| status_uri | A reference uri to get deployment status of the queue manager. | +| web_console_url | The url through which to access the web console for this queue manager. | +| rest_api_endpoint_url | The url through which to access REST APIs for this queue manager. | +| administrator_api_endpoint_url | The url through which to access the Admin REST APIs for this queue manager. | +| connection_info_uri | The uri through which the CDDT for this queue manager can be obtained. | +| date_created | RFC3339 formatted UTC date for when the queue manager was created. | +| upgrade_available | Describes whether an upgrade is available for this queue manager. | +| available_upgrade_versions_uri | The uri through which the available versions to upgrade to can be found for this queue manager. | +| href | The URL for this queue manager. | +| queue_manager_id | The ID of the queue manager which was allocated on creation, and can be used for delete calls. | + +### Resource: ibm_mqcloud_application ```hcl -resource "mqcloud_application" "mqcloud_application_instance" { +resource "ibm_mqcloud_application" "mqcloud_application_instance" { service_instance_guid = var.mqcloud_application_service_instance_guid name = var.mqcloud_application_name } ``` -mqcloud_user resource: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| name | The name of the application - conforming to MQ rules. | `string` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| create_api_key_uri | The URI to create a new apikey for the application. | +| href | The URL for this application. | +| application_id | The ID of the application which was allocated on creation, and can be used for delete calls. | + +### Resource: ibm_mqcloud_user ```hcl -resource "mqcloud_user" "mqcloud_user_instance" { +resource "ibm_mqcloud_user" "mqcloud_user_instance" { service_instance_guid = var.mqcloud_user_service_instance_guid name = var.mqcloud_user_name email = var.mqcloud_user_email } ``` -mqcloud_keystore_certificate resource: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| name | The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance. | `string` | true | +| email | The email of the user. | `string` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| href | The URL for the user details. | +| user_id | The ID of the user which was allocated on creation, and can be used for delete calls. | + +### Resource: ibm_mqcloud_keystore_certificate ```hcl -resource "mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { +resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { service_instance_guid = var.mqcloud_keystore_certificate_service_instance_guid queue_manager_id = var.mqcloud_keystore_certificate_queue_manager_id label = var.mqcloud_keystore_certificate_label + certificate_file = var.mqcloud_keystore_certificate_certificate_file } ``` -mqcloud_truststore_certificate resource: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| queue_manager_id | The id of the queue manager to retrieve its full details. | `string` | true | +| label | The label to use for the certificate to be uploaded. | `string` | true | +| certificate_file | The filename and path of the certificate to be uploaded. | `base64-encoded string` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| certificate_type | The type of certificate. | +| fingerprint_sha256 | Fingerprint SHA256. | +| subject_dn | Subject's Distinguished Name. | +| subject_cn | Subject's Common Name. | +| issuer_dn | Issuer's Distinguished Name. | +| issuer_cn | Issuer's Common Name. | +| issued | Date certificate was issued. | +| expiry | Expiry date for the certificate. | +| is_default | Indicates whether it is the queue manager's default certificate. | +| dns_names_total_count | The total count of dns names. | +| dns_names | The list of DNS names. | +| href | The URL for this key store certificate. | +| certificate_id | ID of the certificate. | + +### Resource: ibm_mqcloud_truststore_certificate ```hcl -resource "mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { +resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { service_instance_guid = var.mqcloud_truststore_certificate_service_instance_guid queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id label = var.mqcloud_truststore_certificate_label + certificate_file = var.mqcloud_truststore_certificate_certificate_file } ``` -## MqcloudV1 data sources +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| queue_manager_id | The id of the queue manager to retrieve its full details. | `string` | true | +| label | The label to use for the certificate to be uploaded. | `string` | true | +| certificate_file | The filename and path of the certificate to be uploaded. | `base64-encoded string` | true | + +#### Outputs -mqcloud_queue_manager data source: +| Name | Description | +|------|-------------| +| certificate_type | The type of certificate. | +| fingerprint_sha256 | Fingerprint SHA256. | +| subject_dn | Subject's Distinguished Name. | +| subject_cn | Subject's Common Name. | +| issuer_dn | Issuer's Distinguished Name. | +| issuer_cn | Issuer's Common Name. | +| issued | The Date the certificate was issued. | +| expiry | Expiry date for the certificate. | +| trusted | Indicates whether a certificate is trusted. | +| href | The URL for this trust store certificate. | +| certificate_id | Id of the certificate. | + +## MQ on Cloud data sources + +### Data source: ibm_mqcloud_queue_manager ```hcl -data "mqcloud_queue_manager" "mqcloud_queue_manager_instance" { - service_instance_guid = var.mqcloud_queue_manager_service_instance_guid - name = var.mqcloud_queue_manager_name +data "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = var.data_mqcloud_queue_manager_service_instance_guid + name = var.data_mqcloud_queue_manager_name } ``` -mqcloud_queue_manager_status data source: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| name | A queue manager name conforming to MQ restrictions. | `string` | false | + +#### Outputs + +| Name | Description | +|------|-------------| +| queue_managers | List of queue managers. | + +### Data source: ibm_mqcloud_queue_manager_status ```hcl -data "mqcloud_queue_manager_status" "mqcloud_queue_manager_status_instance" { +data "ibm_mqcloud_queue_manager_status" "mqcloud_queue_manager_status_instance" { service_instance_guid = var.mqcloud_queue_manager_status_service_instance_guid queue_manager_id = var.mqcloud_queue_manager_status_queue_manager_id } ``` -mqcloud_application data source: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| queue_manager_id | The id of the queue manager to retrieve its full details. | `string` | true | + +#### Outputs + +| Name | Description | +|------|-------------| +| status | The deploying and failed states are not queue manager states, they are states which can occur when the request to deploy has been fired, or with that request has failed without producing a queue manager to have any state. The other states map to the queue manager states. State "ending" is either quiesing or ending immediately. State "ended" is either ended normally or endedimmediately. The others map one to one with queue manager states. | + +### Data source: ibm_mqcloud_application ```hcl -data "mqcloud_application" "mqcloud_application_instance" { - service_instance_guid = var.mqcloud_application_service_instance_guid - name = var.mqcloud_application_name +data "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = var.data_mqcloud_application_service_instance_guid + name = var.data_mqcloud_application_name } ``` -mqcloud_user data source: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| name | The name of the application - conforming to MQ rules. | `string` | false | + +#### Outputs + +| Name | Description | +|------|-------------| +| applications | List of applications. | + +### Data source: ibm_mqcloud_user ```hcl -data "mqcloud_user" "mqcloud_user_instance" { - service_instance_guid = var.mqcloud_user_service_instance_guid - name = var.mqcloud_user_name +data "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = var.data_mqcloud_user_service_instance_guid + name = var.data_mqcloud_user_name } ``` -mqcloud_truststore_certificate data source: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| name | The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance. | `string` | false | + +#### Outputs + +| Name | Description | +|------|-------------| +| users | List of users. | + +### Data source: ibm_mqcloud_truststore_certificate ```hcl -data "mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { - service_instance_guid = var.mqcloud_truststore_certificate_service_instance_guid - queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id - label = var.mqcloud_truststore_certificate_label +data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = var.data_mqcloud_truststore_certificate_service_instance_guid + queue_manager_id = var.data_mqcloud_truststore_certificate_queue_manager_id + label = var.data_mqcloud_truststore_certificate_label } ``` -mqcloud_keystore_certificate data source: + +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| queue_manager_id | The id of the queue manager to retrieve its full details. | `string` | true | +| label | Certificate label in queue manager store. | `string` | false | + +#### Outputs + +| Name | Description | +|------|-------------| +| total_count | The total count of trust store certificates. | +| trust_store | The list of trust store certificates. | + +### Data source: ibm_mqcloud_keystore_certificate ```hcl -data "mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { - service_instance_guid = var.mqcloud_keystore_certificate_service_instance_guid - queue_manager_id = var.mqcloud_keystore_certificate_queue_manager_id - label = var.mqcloud_keystore_certificate_label +data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = var.data_mqcloud_keystore_certificate_service_instance_guid + queue_manager_id = var.data_mqcloud_keystore_certificate_queue_manager_id + label = var.data_mqcloud_keystore_certificate_label } ``` +#### Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| queue_manager_id | The id of the queue manager to retrieve its full details. | `string` | true | +| label | Certificate label in queue manager store. | `string` | false | + +#### Outputs + +| Name | Description | +|------|-------------| +| total_count | The total count of key store certificates. | +| key_store | The list of key store certificates. | + ## Assumptions 1. TODO @@ -145,31 +357,3 @@ data "mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { | Name | Version | |------|---------| | ibm | 1.13.1 | - -## Inputs - -| Name | Description | Type | Required | -|------|-------------|------|---------| -| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | -| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | -| name | A queue manager name conforming to MQ restrictions. | `string` | true | -| display_name | A displayable name for the queue manager - limited only in length. | `string` | false | -| location | The locations in which the queue manager could be deployed. | `string` | true | -| size | The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available. | `string` | true | -| version | The MQ version of the queue manager. | `string` | false | -| name | The name of the application - conforming to MQ rules. | `string` | true | -| name | The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance. | `string` | true | -| email | The email of the user. | `string` | true | -| queue_manager_id | The id of the queue manager to retrieve its full details. | `string` | true | -| label | Certificate label in queue manager store. | `string` | true | - -## Outputs - -| Name | Description | -|------|-------------| -| mqcloud_queue_manager | mqcloud_queue_manager object | -| mqcloud_queue_manager_status | mqcloud_queue_manager_status object | -| mqcloud_application | mqcloud_application object | -| mqcloud_user | mqcloud_user object | -| mqcloud_truststore_certificate | mqcloud_truststore_certificate object | -| mqcloud_keystore_certificate | mqcloud_keystore_certificate object | diff --git a/examples/ibm-mqcloud/main.tf b/examples/ibm-mqcloud/main.tf index b89e08c72a..16dc2df7dc 100644 --- a/examples/ibm-mqcloud/main.tf +++ b/examples/ibm-mqcloud/main.tf @@ -30,6 +30,7 @@ resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instan service_instance_guid = var.mqcloud_keystore_certificate_service_instance_guid queue_manager_id = var.mqcloud_keystore_certificate_queue_manager_id label = var.mqcloud_keystore_certificate_label + certificate_file = var.mqcloud_keystore_certificate_certificate_file } // Provision mqcloud_truststore_certificate resource instance @@ -37,6 +38,7 @@ resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_in service_instance_guid = var.mqcloud_truststore_certificate_service_instance_guid queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id label = var.mqcloud_truststore_certificate_label + certificate_file = var.mqcloud_truststore_certificate_certificate_file } // Data source is not linked to a resource instance @@ -44,9 +46,8 @@ resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_in /* // Create mqcloud_queue_manager data source data "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { - service_instance_guid = var.mqcloud_queue_manager_service_instance_guid - - name = var.mqcloud_queue_manager_name + service_instance_guid = var.data_mqcloud_queue_manager_service_instance_guid + name = var.data_mqcloud_queue_manager_name } */ @@ -65,8 +66,8 @@ data "ibm_mqcloud_queue_manager_status" "mqcloud_queue_manager_status_instance" /* // Create mqcloud_application data source data "ibm_mqcloud_application" "mqcloud_application_instance" { - service_instance_guid = var.mqcloud_application_service_instance_guid - name = var.mqcloud_application_name + service_instance_guid = var.data_mqcloud_application_service_instance_guid + name = var.data_mqcloud_application_name } */ @@ -75,8 +76,8 @@ data "ibm_mqcloud_application" "mqcloud_application_instance" { /* // Create mqcloud_user data source data "ibm_mqcloud_user" "mqcloud_user_instance" { - service_instance_guid = var.mqcloud_user_service_instance_guid - name = var.mqcloud_user_name + service_instance_guid = var.data_mqcloud_user_service_instance_guid + name = var.data_mqcloud_user_name } */ @@ -85,9 +86,9 @@ data "ibm_mqcloud_user" "mqcloud_user_instance" { /* // Create mqcloud_truststore_certificate data source data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { - service_instance_guid = var.mqcloud_truststore_certificate_service_instance_guid - queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id - label = var.mqcloud_truststore_certificate_label + service_instance_guid = var.data_mqcloud_truststore_certificate_service_instance_guid + queue_manager_id = var.data_mqcloud_truststore_certificate_queue_manager_id + label = var.data_mqcloud_truststore_certificate_label } */ @@ -96,8 +97,8 @@ data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instan /* // Create mqcloud_keystore_certificate data source data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { - service_instance_guid = var.mqcloud_keystore_certificate_service_instance_guid - queue_manager_id = var.mqcloud_keystore_certificate_queue_manager_id - label = var.mqcloud_keystore_certificate_label + service_instance_guid = var.data_mqcloud_keystore_certificate_service_instance_guid + queue_manager_id = var.data_mqcloud_keystore_certificate_queue_manager_id + label = var.data_mqcloud_keystore_certificate_label } */ diff --git a/examples/ibm-mqcloud/variables.tf b/examples/ibm-mqcloud/variables.tf index dba4d0fff0..66a9dda4ae 100644 --- a/examples/ibm-mqcloud/variables.tf +++ b/examples/ibm-mqcloud/variables.tf @@ -22,7 +22,7 @@ variable "mqcloud_queue_manager_display_name" { variable "mqcloud_queue_manager_location" { description = "The locations in which the queue manager could be deployed." type = string - default = "reserved-eu-fr-cluster-f884" + default = "reserved-eu-de-cluster-f884" } variable "mqcloud_queue_manager_size" { description = "The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available." @@ -53,24 +53,6 @@ variable "mqcloud_user_service_instance_guid" { type = string default = "Service Instance ID" } - -// Data source arguments for mqcloud_application -variable "mqcloud_application_service_instance_guid" { - description = "The GUID that uniquely identifies the MQ on Cloud service instance." - type = string - default = "Service Instance ID" -} -variable "mqcloud_user_name" { - description = "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance." - type = string - default = "name" -} - -variable "mqcloud_application_name" { - description = "The name of the application - conforming to MQ rules." - type = string - default = "name" -} variable "mqcloud_user_name" { description = "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance." type = string @@ -94,10 +76,15 @@ variable "mqcloud_keystore_certificate_queue_manager_id" { default = "Queue Manager ID" } variable "mqcloud_keystore_certificate_label" { - description = "Certificate label in queue manager store." + description = "The label to use for the certificate to be uploaded." type = string default = "label" } +variable "mqcloud_keystore_certificate_certificate_file" { + description = "The filename and path of the certificate to be uploaded." + type = string + default = "SGVsbG8gd29ybGQ=" +} // Resource arguments for mqcloud_truststore_certificate variable "mqcloud_truststore_certificate_service_instance_guid" { @@ -110,21 +97,24 @@ variable "mqcloud_truststore_certificate_queue_manager_id" { type = string default = "Queue Manager ID" } - variable "mqcloud_truststore_certificate_label" { - description = "Certificate label in queue manager store." + description = "The label to use for the certificate to be uploaded." type = string default = "label" } +variable "mqcloud_truststore_certificate_certificate_file" { + description = "The filename and path of the certificate to be uploaded." + type = string + default = "SGVsbG8gd29ybGQ=" +} // Data source arguments for mqcloud_queue_manager -variable "mqcloud_queue_manager_service_instance_guid" { +variable "data_mqcloud_queue_manager_service_instance_guid" { description = "The GUID that uniquely identifies the MQ on Cloud service instance." type = string default = "Service Instance ID" } - -variable "mqcloud_queue_manager_name" { +variable "data_mqcloud_queue_manager_name" { description = "A queue manager name conforming to MQ restrictions." type = string default = "name" @@ -143,60 +133,58 @@ variable "mqcloud_queue_manager_status_queue_manager_id" { } // Data source arguments for mqcloud_application -variable "mqcloud_application_service_instance_guid" { +variable "data_mqcloud_application_service_instance_guid" { description = "The GUID that uniquely identifies the MQ on Cloud service instance." type = string default = "Service Instance ID" } - -variable "mqcloud_application_name" { +variable "data_mqcloud_application_name" { description = "The name of the application - conforming to MQ rules." type = string default = "name" } // Data source arguments for mqcloud_user -variable "mqcloud_user_service_instance_guid" { +variable "data_mqcloud_user_service_instance_guid" { description = "The GUID that uniquely identifies the MQ on Cloud service instance." type = string default = "Service Instance ID" } - -variable "mqcloud_user_name" { +variable "data_mqcloud_user_name" { description = "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance." type = string default = "name" } // Data source arguments for mqcloud_truststore_certificate -variable "mqcloud_truststore_certificate_service_instance_guid" { +variable "data_mqcloud_truststore_certificate_service_instance_guid" { description = "The GUID that uniquely identifies the MQ on Cloud service instance." type = string default = "Service Instance ID" } -variable "mqcloud_truststore_certificate_queue_manager_id" { +variable "data_mqcloud_truststore_certificate_queue_manager_id" { description = "The id of the queue manager to retrieve its full details." type = string default = "Queue Manager ID" } -variable "mqcloud_truststore_certificate_label" { +variable "data_mqcloud_truststore_certificate_label" { description = "Certificate label in queue manager store." type = string default = "label" } // Data source arguments for mqcloud_keystore_certificate -variable "mqcloud_keystore_certificate_service_instance_guid" { +variable "data_mqcloud_keystore_certificate_service_instance_guid" { description = "The GUID that uniquely identifies the MQ on Cloud service instance." type = string default = "Service Instance ID" } -variable "mqcloud_keystore_certificate_queue_manager_id" { +variable "data_mqcloud_keystore_certificate_queue_manager_id" { description = "The id of the queue manager to retrieve its full details." type = string default = "Queue Manager ID" } -variable "mqcloud_keystore_certificate_label" { +variable "data_mqcloud_keystore_certificate_label" { description = "Certificate label in queue manager store." type = string default = "label" diff --git a/go.mod b/go.mod index f90c4389cf..2669b596d2 100644 --- a/go.mod +++ b/go.mod @@ -62,7 +62,7 @@ require ( ) require ( - github.com/IBM/mqcloud-go-sdk v0.0.0-20231207105140-14d858932788 + github.com/IBM/mqcloud-go-sdk v0.0.4 github.com/IBM/sarama v1.41.2 k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 sigs.k8s.io/controller-runtime v0.14.1 diff --git a/go.sum b/go.sum index b3be0e1e92..3d4a146889 100644 --- a/go.sum +++ b/go.sum @@ -154,8 +154,8 @@ github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta/go.mod h1:MLVNHMYoKsvovJZ4v1gQCpIYt github.com/IBM/keyprotect-go-client v0.5.1/go.mod h1:5TwDM/4FRJq1ZOlwQL1xFahLWQ3TveR88VmL1u3njyI= github.com/IBM/keyprotect-go-client v0.12.2 h1:Cjxcqin9Pl0xz3MnxdiVd4v/eIa79xL3hQpSbwOr/DQ= github.com/IBM/keyprotect-go-client v0.12.2/go.mod h1:yr8h2noNgU8vcbs+vhqoXp3Lmv73PI0zAc6VMgFvWwM= -github.com/IBM/mqcloud-go-sdk v0.0.0-20231207105140-14d858932788 h1:cIT0YSzqMGqxM3OJQx1gp4gtYYy9U35O0tVdcFHOgwc= -github.com/IBM/mqcloud-go-sdk v0.0.0-20231207105140-14d858932788/go.mod h1:R4NBbDMygpHiFywUnOdV0UfBZap4HcHa3QXLlACr9TU= +github.com/IBM/mqcloud-go-sdk v0.0.4 h1:gqMpoU5a0qJ0GETG4PQrkgeEEoaQLvbxRJnEe6ytvC4= +github.com/IBM/mqcloud-go-sdk v0.0.4/go.mod h1:gQptHC6D+rxfg0muRFFGvTDmvl4YfiDE0uXkaRRewRk= github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCBmvdyqkA= github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.55.0 h1:W598xZanL61bwd8O2DQexr4qjIr+/tP0Y845zoms5yA= diff --git a/ibm/acctest/acctest.go b/ibm/acctest/acctest.go index 8a90bdea06..16bfc30ab4 100644 --- a/ibm/acctest/acctest.go +++ b/ibm/acctest/acctest.go @@ -126,10 +126,14 @@ var ( // MQ on Cloud var ( - MqcloudInstanceID string - MqcloudQueueManagerID string - MqcloudKSCertFilePath string - MqcloudTSCertFilePath string + MqcloudConfigEndpoint string + MqcloudInstanceID string + MqcloudQueueManagerID string + MqcloudKSCertFilePath string + MqcloudTSCertFilePath string + MqCloudQueueManagerLocation string + MqCloudQueueManagerVersion string + MqCloudQueueManagerVersionUpdate string ) // Secrets Manager @@ -1591,11 +1595,15 @@ func init() { fmt.Println("[WARN] Set the environment variable IBM_SATELLITE_SSH_PUB_KEY with a ssh public key or ibm_satellite_* tests may fail") } + MqcloudConfigEndpoint = os.Getenv("IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT") + if MqcloudConfigEndpoint == "" { + fmt.Println("[INFO] Set the environment variable IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT for ibm_mqcloud service else tests will fail if this is not set correctly") + } + MqcloudInstanceID = os.Getenv("IBM_MQCLOUD_INSTANCE_ID") if MqcloudInstanceID == "" { fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_INSTANCE_ID for ibm_mqcloud_queue_manager resource or datasource else tests will fail if this is not set correctly") } - MqcloudQueueManagerID = os.Getenv("IBM_MQCLOUD_QUEUEMANAGER_ID") if MqcloudQueueManagerID == "" { fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_QUEUEMANAGER_ID for ibm_mqcloud_queue_manager resource or datasource else tests will fail if this is not set correctly") @@ -1608,6 +1616,18 @@ func init() { if MqcloudTSCertFilePath == "" { fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_TS_CERT_PATH for ibm_mqcloud_truststore_certificate resource or datasource else tests will fail if this is not set correctly") } + MqCloudQueueManagerLocation = os.Getenv(("IBM_MQCLOUD_QUEUEMANAGER_LOCATION")) + if MqCloudQueueManagerLocation == "" { + fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_QUEUEMANAGER_LOCATION for ibm_mqcloud_queue_manager resource or datasource else tests will fail if this is not set correctly") + } + MqCloudQueueManagerVersion = os.Getenv(("IBM_MQCLOUD_QUEUEMANAGER_VERSION")) + if MqCloudQueueManagerVersion == "" { + fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_QUEUEMANAGER_VERSION for ibm_mqcloud_queue_manager resource or datasource else tests will fail if this is not set correctly") + } + MqCloudQueueManagerVersionUpdate = os.Getenv(("IBM_MQCLOUD_QUEUEMANAGER_VERSIONUPDATE")) + if MqCloudQueueManagerVersionUpdate == "" { + fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_QUEUEMANAGER_VERSIONUPDATE for ibm_mqcloud_queue_manager resource or datasource else tests will fail if this is not set correctly") + } } var ( @@ -1821,6 +1841,9 @@ func TestAccPreCheckSatelliteSSH(t *testing.T) { func TestAccPreCheckMqcloud(t *testing.T) { TestAccPreCheck(t) + if MqcloudConfigEndpoint == "" { + t.Fatal("IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT must be set for acceptance tests") + } if MqcloudInstanceID == "" { t.Fatal("IBM_MQCLOUD_INSTANCE_ID must be set for acceptance tests") } @@ -1833,6 +1856,15 @@ func TestAccPreCheckMqcloud(t *testing.T) { if MqcloudKSCertFilePath == "" { t.Fatal("IBM_MQCLOUD_KS_CERT_PATH must be set for acceptance tests") } + if MqCloudQueueManagerLocation == "" { + t.Fatal("IBM_MQCLOUD_QUEUEMANAGER_LOCATION must be set for acceptance tests") + } + if MqCloudQueueManagerVersion == "" { + t.Fatal("IBM_MQCLOUD_QUEUEMANAGER_VERSION must be set for acceptance tests") + } + if MqCloudQueueManagerVersionUpdate == "" { + t.Fatal("IBM_MQCLOUD_QUEUEMANAGER_VERSIONUPDATE must be set for acceptance tests") + } } func TestAccProviderFactories() map[string]func() (*schema.Provider, error) { diff --git a/ibm/conns/config.go b/ibm/conns/config.go index fd99350034..c2fc691288 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -1210,9 +1210,12 @@ func (session clientSession) ProjectV1() (*project.ProjectV1, error) { // MQ on Cloud func (session clientSession) MqcloudV1() (*mqcloudv1.MqcloudV1, error) { - sessionMqcloudClient := session.mqcloudClient - sessionMqcloudClient.EnableRetries(0, 0) - return session.mqcloudClient, session.mqcloudClientErr + if session.mqcloudClientErr != nil { + sessionMqcloudClient := session.mqcloudClient + sessionMqcloudClient.EnableRetries(0, 0) + return session.mqcloudClient, session.mqcloudClientErr + } + return session.mqcloudClient.Clone(), nil } // ClientSession configures and returns a fully initialized ClientSession @@ -3266,23 +3269,24 @@ func (c *Config) ClientSession() (interface{}, error) { if fileMap != nil && c.Visibility != "public-and-private" { mqCloudURL = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT", c.Region, mqCloudURL) } - + accept_language := os.Getenv("IBMCLOUD_MQCLOUD_ACCEPT_LANGUAGE") mqcloudClientOptions := &mqcloudv1.MqcloudV1Options{ - Authenticator: authenticator, - URL: EnvFallBack([]string{"IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT"}, mqCloudURL), + Authenticator: authenticator, + AcceptLanguage: core.StringPtr(accept_language), + URL: EnvFallBack([]string{"IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT"}, mqCloudURL), } // Construct the service client for MQ Cloud. session.mqcloudClient, err = mqcloudv1.NewMqcloudV1(mqcloudClientOptions) - if err != nil { - session.mqcloudClientErr = fmt.Errorf("Error occurred while configuring MQ Cloud service: %q", err) - } else { + if err == nil { // Enable retries for API calls session.mqcloudClient.Service.EnableRetries(c.RetryCount, c.RetryDelay) // Add custom header for analytics session.mqcloudClient.SetDefaultHeaders(gohttp.Header{ "X-Original-User-Agent": {fmt.Sprintf("terraform-provider-ibm/%s", version.Version)}, }) + } else { + session.mqcloudClientErr = fmt.Errorf("Error occurred while configuring MQ on Cloud service: %q", err) } // Construct the service options. diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_application.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_application.go index 9cef9c4831..8f2ea42810 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_application.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_application.go @@ -9,11 +9,11 @@ import ( "time" - "github.com/IBM/mqcloud-go-sdk/mqcloudv1" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" ) func DataSourceIbmMqcloudApplication() *schema.Resource { @@ -128,7 +128,7 @@ func dataSourceIbmMqcloudApplicationRead(context context.Context, d *schema.Reso if suppliedFilter { if len(allItems) == 0 { - return diag.FromErr(fmt.Errorf("No Applications found with name %s", name)) + return diag.FromErr(fmt.Errorf("No Application found with name: \"%s\"", name)) } d.SetId(name) } else { @@ -146,7 +146,7 @@ func dataSourceIbmMqcloudApplicationRead(context context.Context, d *schema.Reso } if err = d.Set("applications", mapSlice); err != nil { - return diag.FromErr(fmt.Errorf("Error setting applications %s", err)) + return diag.FromErr(fmt.Errorf("Error setting applications: %s", err)) } return nil diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_application_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_application_test.go index 1c9f1d7347..49eed96b15 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_application_test.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_application_test.go @@ -13,6 +13,7 @@ import ( ) func TestAccIbmMqcloudApplicationDataSourceBasic(t *testing.T) { + t.Parallel() applicationDetailsServiceInstanceGuid := acc.MqcloudInstanceID applicationDetailsName := "appdsbasic" @@ -33,31 +34,6 @@ func TestAccIbmMqcloudApplicationDataSourceBasic(t *testing.T) { }) } -func TestAccIbmMqcloudApplicationDataSourceAllArgs(t *testing.T) { - applicationDetailsServiceInstanceGuid := acc.MqcloudInstanceID - applicationDetailsName := "appdsargs" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIbmMqcloudApplicationDataSourceConfig(applicationDetailsServiceInstanceGuid, applicationDetailsName), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "service_instance_guid"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.#"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.id"), - resource.TestCheckResourceAttr("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.name", applicationDetailsName), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.create_api_key_uri"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.href"), - ), - }, - }, - }) -} - func testAccCheckIbmMqcloudApplicationDataSourceConfigBasic(applicationDetailsServiceInstanceGuid string, applicationDetailsName string) string { return fmt.Sprintf(` resource "ibm_mqcloud_application" "mqcloud_application_instance" { @@ -71,17 +47,3 @@ func testAccCheckIbmMqcloudApplicationDataSourceConfigBasic(applicationDetailsSe } `, applicationDetailsServiceInstanceGuid, applicationDetailsName) } - -func testAccCheckIbmMqcloudApplicationDataSourceConfig(applicationDetailsServiceInstanceGuid string, applicationDetailsName string) string { - return fmt.Sprintf(` - resource "ibm_mqcloud_application" "mqcloud_application_instance" { - service_instance_guid = "%s" - name = "%s" - } - - data "ibm_mqcloud_application" "mqcloud_application_instance" { - service_instance_guid = ibm_mqcloud_application.mqcloud_application_instance.service_instance_guid - name = ibm_mqcloud_application.mqcloud_application_instance.name - } - `, applicationDetailsServiceInstanceGuid, applicationDetailsName) -} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate.go index 0f27f37fa3..0881b79156 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate.go @@ -169,7 +169,7 @@ func dataSourceIbmMqcloudKeystoreCertificateRead(context context.Context, d *sch if suppliedFilter { if len(keyStoreCertificateDetailsCollection.KeyStore) == 0 { - return diag.FromErr(fmt.Errorf("no KeyStore found with label %s", label)) + return diag.FromErr(fmt.Errorf("No Key Store Certificate found with label: \"%s\"", label)) } d.SetId(label) } else { @@ -192,7 +192,7 @@ func dataSourceIbmMqcloudKeystoreCertificateRead(context context.Context, d *sch } } if err = d.Set("key_store", keyStore); err != nil { - return diag.FromErr(fmt.Errorf("Error setting key_store %s", err)) + return diag.FromErr(fmt.Errorf("Error setting key_store: %s", err)) } return nil diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate_test.go index 9f0b3218e6..984831aac7 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate_test.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate_test.go @@ -14,6 +14,7 @@ import ( ) func TestAccIbmMqcloudKeystoreCertificateDataSourceBasic(t *testing.T) { + t.Parallel() keyStoreCertificateDetailsServiceInstanceGuid := acc.MqcloudInstanceID keyStoreCertificateDetailsQueueManagerID := acc.MqcloudQueueManagerID keyStoreCertificateDetailsLabel := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) @@ -26,46 +27,9 @@ func TestAccIbmMqcloudKeystoreCertificateDataSourceBasic(t *testing.T) { { Config: testAccCheckIbmMqcloudKeystoreCertificateDataSourceConfigBasic(keyStoreCertificateDetailsServiceInstanceGuid, keyStoreCertificateDetailsQueueManagerID, keyStoreCertificateDetailsLabel, keyStoreCertificateDetailsCertificateFile), Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "id"), resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "service_instance_guid"), resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "queue_manager_id"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.#"), - resource.TestCheckResourceAttr("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.label", keyStoreCertificateDetailsLabel), - ), - }, - }, - }) -} - -func TestAccIbmMqcloudKeystoreCertificateDataSourceAllArgs(t *testing.T) { - keyStoreCertificateDetailsServiceInstanceGuid := acc.MqcloudInstanceID - keyStoreCertificateDetailsQueueManagerID := acc.MqcloudQueueManagerID - keyStoreCertificateDetailsLabel := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) - keyStoreCertificateDetailsCertificateFile := acc.MqcloudKSCertFilePath - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIbmMqcloudKeystoreCertificateDataSourceConfig(keyStoreCertificateDetailsServiceInstanceGuid, keyStoreCertificateDetailsQueueManagerID, keyStoreCertificateDetailsLabel, keyStoreCertificateDetailsCertificateFile), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "service_instance_guid"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "queue_manager_id"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "label"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "total_count"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.#"), - resource.TestCheckResourceAttr("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.label", keyStoreCertificateDetailsLabel), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.certificate_type"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.fingerprint_sha256"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.subject_dn"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.subject_cn"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.issuer_dn"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.issuer_cn"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.issued"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.expiry"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.is_default"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.dns_names_total_count"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.href"), ), }, }, @@ -78,24 +42,7 @@ func testAccCheckIbmMqcloudKeystoreCertificateDataSourceConfigBasic(keyStoreCert service_instance_guid = "%s" queue_manager_id = "%s" label = "%s" - certificate_file = "%s" - } - - data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { - service_instance_guid = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.service_instance_guid - queue_manager_id = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.queue_manager_id - label = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.label - } - `, keyStoreCertificateDetailsServiceInstanceGuid, keyStoreCertificateDetailsQueueManagerID, keyStoreCertificateDetailsLabel, keyStoreCertificateDetailsCertificateFile) -} - -func testAccCheckIbmMqcloudKeystoreCertificateDataSourceConfig(keyStoreCertificateDetailsServiceInstanceGuid string, keyStoreCertificateDetailsQueueManagerID string, keyStoreCertificateDetailsLabel string, keyStoreCertificateDetailsCertificateFile string) string { - return fmt.Sprintf(` - resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { - service_instance_guid = "%s" - queue_manager_id = "%s" - label = "%s" - certificate_file = "%s" + certificate_file = filebase64("%s") } data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager.go index 42774e4bce..245cbf93b7 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager.go @@ -182,7 +182,7 @@ func dataSourceIbmMqcloudQueueManagerRead(context context.Context, d *schema.Res if suppliedFilter { if len(allItems) == 0 { - return diag.FromErr(fmt.Errorf("No Queue Managers found with name %s", name)) + return diag.FromErr(fmt.Errorf("No Queue Manager found with name: \"%s\"", name)) } d.SetId(name) } else { @@ -200,7 +200,7 @@ func dataSourceIbmMqcloudQueueManagerRead(context context.Context, d *schema.Res } if err = d.Set("queue_managers", mapSlice); err != nil { - return diag.FromErr(fmt.Errorf("Error setting queue_managers %s", err)) + return diag.FromErr(fmt.Errorf("Error setting queue_managers: %s", err)) } return nil diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_test.go index 69f9690370..1bf9dccef8 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_test.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_test.go @@ -7,6 +7,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" @@ -15,8 +16,8 @@ import ( func TestAccIbmMqcloudQueueManagerDataSourceBasic(t *testing.T) { t.Parallel() queueManagerDetailsServiceInstanceGuid := acc.MqcloudInstanceID - queueManagerDetailsName := "queue_manager_ds_basic" - queueManagerDetailsLocation := "ibmcloud_eu_de" + queueManagerDetailsName := fmt.Sprintf("tf_queue_manager_ds_basic%d", acctest.RandIntRange(10, 100)) + queueManagerDetailsLocation := acc.MqCloudQueueManagerLocation queueManagerDetailsSize := "small" resource.Test(t, resource.TestCase{ @@ -41,11 +42,11 @@ func TestAccIbmMqcloudQueueManagerDataSourceBasic(t *testing.T) { func TestAccIbmMqcloudQueueManagerDataSourceAllArgs(t *testing.T) { t.Parallel() queueManagerDetailsServiceInstanceGuid := acc.MqcloudInstanceID - queueManagerDetailsName := "queue_manager_ds_allargs" - queueManagerDetailsDisplayName := "queue_manager_ds_allargs" - queueManagerDetailsLocation := "ibmcloud_eu_de" + queueManagerDetailsName := fmt.Sprintf("tf_queue_manager_ds_allargs%d", acctest.RandIntRange(10, 100)) + queueManagerDetailsDisplayName := queueManagerDetailsName + queueManagerDetailsLocation := acc.MqCloudQueueManagerLocation queueManagerDetailsSize := "small" - queueManagerDetailsVersion := "9.3.3_3" + queueManagerDetailsVersion := acc.MqCloudQueueManagerVersion resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate.go index 265c2cb8b1..c8d0604ab0 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate.go @@ -156,7 +156,7 @@ func dataSourceIbmMqcloudTruststoreCertificateRead(context context.Context, d *s if suppliedFilter { if len(trustStoreCertificateDetailsCollection.TrustStore) == 0 { - return diag.FromErr(fmt.Errorf("no TrustStore found with label %s", label)) + return diag.FromErr(fmt.Errorf("No Trust Store Certificate found with label: \"%s\"", label)) } d.SetId(label) } else { @@ -179,7 +179,7 @@ func dataSourceIbmMqcloudTruststoreCertificateRead(context context.Context, d *s } } if err = d.Set("trust_store", trustStore); err != nil { - return diag.FromErr(fmt.Errorf("Error setting trust_store %s", err)) + return diag.FromErr(fmt.Errorf("Error setting trust_store: %s", err)) } return nil diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate_test.go index a4c50e196f..75552460a4 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate_test.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate_test.go @@ -14,6 +14,7 @@ import ( ) func TestAccIbmMqcloudTruststoreCertificateDataSourceBasic(t *testing.T) { + t.Parallel() trustStoreCertificateDetailsServiceInstanceGuid := acc.MqcloudInstanceID trustStoreCertificateDetailsQueueManagerID := acc.MqcloudQueueManagerID trustStoreCertificateDetailsLabel := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) @@ -26,45 +27,9 @@ func TestAccIbmMqcloudTruststoreCertificateDataSourceBasic(t *testing.T) { { Config: testAccCheckIbmMqcloudTruststoreCertificateDataSourceConfigBasic(trustStoreCertificateDetailsServiceInstanceGuid, trustStoreCertificateDetailsQueueManagerID, trustStoreCertificateDetailsLabel, trustStoreCertificateDetailsCertificateFile), Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "id"), resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "service_instance_guid"), resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "queue_manager_id"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.#"), - resource.TestCheckResourceAttr("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.label", trustStoreCertificateDetailsLabel), - ), - }, - }, - }) -} - -func TestAccIbmMqcloudTruststoreCertificateDataSourceAllArgs(t *testing.T) { - trustStoreCertificateDetailsServiceInstanceGuid := acc.MqcloudInstanceID - trustStoreCertificateDetailsQueueManagerID := acc.MqcloudQueueManagerID - trustStoreCertificateDetailsLabel := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) - trustStoreCertificateDetailsCertificateFile := acc.MqcloudTSCertFilePath - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIbmMqcloudTruststoreCertificateDataSourceConfig(trustStoreCertificateDetailsServiceInstanceGuid, trustStoreCertificateDetailsQueueManagerID, trustStoreCertificateDetailsLabel, trustStoreCertificateDetailsCertificateFile), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "service_instance_guid"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "queue_manager_id"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "label"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "total_count"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.#"), - resource.TestCheckResourceAttr("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.label", trustStoreCertificateDetailsLabel), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.certificate_type"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.fingerprint_sha256"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.subject_dn"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.subject_cn"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.issuer_dn"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.issuer_cn"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.issued"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.expiry"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.trusted"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.href"), ), }, }, @@ -77,24 +42,7 @@ func testAccCheckIbmMqcloudTruststoreCertificateDataSourceConfigBasic(trustStore service_instance_guid = "%s" queue_manager_id = "%s" label = "%s" - certificate_file = "%s" - } - - data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { - service_instance_guid = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.service_instance_guid - queue_manager_id = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.queue_manager_id - label = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.label - } - `, trustStoreCertificateDetailsServiceInstanceGuid, trustStoreCertificateDetailsQueueManagerID, trustStoreCertificateDetailsLabel, trustStoreCertificateDetailsCertificateFile) -} - -func testAccCheckIbmMqcloudTruststoreCertificateDataSourceConfig(trustStoreCertificateDetailsServiceInstanceGuid string, trustStoreCertificateDetailsQueueManagerID string, trustStoreCertificateDetailsLabel string, trustStoreCertificateDetailsCertificateFile string) string { - return fmt.Sprintf(` - resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { - service_instance_guid = "%s" - queue_manager_id = "%s" - label = "%s" - certificate_file = "%s" + certificate_file = filebase64("%s") } data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_user.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_user.go index 259aefa17d..c89a9e0f9e 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_user.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_user.go @@ -127,7 +127,7 @@ func dataSourceIbmMqcloudUserRead(context context.Context, d *schema.ResourceDat if suppliedFilter { if len(allItems) == 0 { - return diag.FromErr(fmt.Errorf("No Users found with name %s", name)) + return diag.FromErr(fmt.Errorf("No User found with name: \"%s\"", name)) } d.SetId(name) } else { @@ -145,7 +145,7 @@ func dataSourceIbmMqcloudUserRead(context context.Context, d *schema.ResourceDat } if err = d.Set("users", mapSlice); err != nil { - return diag.FromErr(fmt.Errorf("Error setting users %s", err)) + return diag.FromErr(fmt.Errorf("Error setting users: %s", err)) } return nil diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_user_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_user_test.go index eb3491817e..8823e06d76 100644 --- a/ibm/service/mqcloud/data_source_ibm_mqcloud_user_test.go +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_user_test.go @@ -14,6 +14,7 @@ import ( ) func TestAccIbmMqcloudUserDataSourceBasic(t *testing.T) { + t.Parallel() userDetailsServiceInstanceGuid := acc.MqcloudInstanceID userDetailsName := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) userDetailsEmail := fmt.Sprintf("tfemail%d@ibm.com", acctest.RandIntRange(10, 100)) @@ -36,32 +37,6 @@ func TestAccIbmMqcloudUserDataSourceBasic(t *testing.T) { }) } -func TestAccIbmMqcloudUserDataSourceAllArgs(t *testing.T) { - userDetailsServiceInstanceGuid := acc.MqcloudInstanceID - userDetailsName := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) - userDetailsEmail := fmt.Sprintf("tfemail%d@ibm.com", acctest.RandIntRange(10, 100)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIbmMqcloudUserDataSourceConfig(userDetailsServiceInstanceGuid, userDetailsName, userDetailsEmail), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "id"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "service_instance_guid"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "name"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "users.#"), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.id"), - resource.TestCheckResourceAttr("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.name", userDetailsName), - resource.TestCheckResourceAttr("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.email", userDetailsEmail), - resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.href"), - ), - }, - }, - }) -} - func testAccCheckIbmMqcloudUserDataSourceConfigBasic(userDetailsServiceInstanceGuid string, userDetailsName string, userDetailsEmail string) string { return fmt.Sprintf(` resource "ibm_mqcloud_user" "mqcloud_user_instance" { @@ -76,18 +51,3 @@ func testAccCheckIbmMqcloudUserDataSourceConfigBasic(userDetailsServiceInstanceG } `, userDetailsServiceInstanceGuid, userDetailsName, userDetailsEmail) } - -func testAccCheckIbmMqcloudUserDataSourceConfig(userDetailsServiceInstanceGuid string, userDetailsName string, userDetailsEmail string) string { - return fmt.Sprintf(` - resource "ibm_mqcloud_user" "mqcloud_user_instance" { - service_instance_guid = "%s" - name = "%s" - email = "%s" - } - - data "ibm_mqcloud_user" "mqcloud_user_instance" { - service_instance_guid = ibm_mqcloud_user.mqcloud_user_instance.service_instance_guid - name = ibm_mqcloud_user.mqcloud_user_instance.name - } - `, userDetailsServiceInstanceGuid, userDetailsName, userDetailsEmail) -} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_application_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_application_test.go index b780d789d1..fec357e6ed 100644 --- a/ibm/service/mqcloud/resource_ibm_mqcloud_application_test.go +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_application_test.go @@ -17,6 +17,7 @@ import ( ) func TestAccIbmMqcloudApplicationBasic(t *testing.T) { + t.Parallel() var conf mqcloudv1.ApplicationDetails serviceInstanceGuid := acc.MqcloudInstanceID name := "appbasic" @@ -34,28 +35,6 @@ func TestAccIbmMqcloudApplicationBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_mqcloud_application.mqcloud_application_instance", "name", name), ), }, - }, - }) -} - -func TestAccIbmMqcloudApplicationAllArgs(t *testing.T) { - var conf mqcloudv1.ApplicationDetails - serviceInstanceGuid := acc.MqcloudInstanceID - name := "appallargs" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIbmMqcloudApplicationDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIbmMqcloudApplicationConfig(serviceInstanceGuid, name), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmMqcloudApplicationExists("ibm_mqcloud_application.mqcloud_application_instance", conf), - resource.TestCheckResourceAttr("ibm_mqcloud_application.mqcloud_application_instance", "service_instance_guid", serviceInstanceGuid), - resource.TestCheckResourceAttr("ibm_mqcloud_application.mqcloud_application_instance", "name", name), - ), - }, { ResourceName: "ibm_mqcloud_application.mqcloud_application_instance", ImportState: true, @@ -74,16 +53,6 @@ func testAccCheckIbmMqcloudApplicationConfigBasic(serviceInstanceGuid string, na `, serviceInstanceGuid, name) } -func testAccCheckIbmMqcloudApplicationConfig(serviceInstanceGuid string, name string) string { - return fmt.Sprintf(` - - resource "ibm_mqcloud_application" "mqcloud_application_instance" { - service_instance_guid = "%s" - name = "%s" - } - `, serviceInstanceGuid, name) -} - func testAccCheckIbmMqcloudApplicationExists(n string, obj mqcloudv1.ApplicationDetails) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate.go b/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate.go index 859d0aa5cc..9cc0f6be06 100644 --- a/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate.go +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate.go @@ -4,12 +4,12 @@ package mqcloud import ( + "bytes" "context" + "encoding/base64" "fmt" "io" "log" - "os" - "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -47,7 +47,13 @@ func ResourceIbmMqcloudKeystoreCertificate() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_mqcloud_keystore_certificate", "label"), - Description: "Certificate label in queue manager store.", + Description: "The label to use for the certificate to be uploaded.", + }, + "certificate_file": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The filename and path of the certificate to be uploaded.", }, "certificate_type": { Type: schema.TypeString, @@ -115,12 +121,6 @@ func ResourceIbmMqcloudKeystoreCertificate() *schema.Resource { Computed: true, Description: "ID of the certificate.", }, - "certificate_file": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The filename and path of the certificate to be uploaded.", - }, }, } } @@ -175,18 +175,11 @@ func resourceIbmMqcloudKeystoreCertificateCreate(context context.Context, d *sch createKeyStorePemCertificateOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) createKeyStorePemCertificateOptions.SetQueueManagerID(d.Get("queue_manager_id").(string)) createKeyStorePemCertificateOptions.SetLabel(d.Get("label").(string)) - //Custom code to read certs and pass to SDK - certBytes, err := os.ReadFile(d.Get("certificate_file").(string)) // just pass the file name + certificateFileBytes, err := base64.StdEncoding.DecodeString(d.Get("certificate_file").(string)) if err != nil { - fmt.Print(err) + return diag.FromErr(err) } - certString := string(certBytes) // convert content to a 'string' - rc := io.NopCloser(strings.NewReader(certString)) - // certificateFileModel, err := resourceIbmMqcloudKeystoreCertificateMapToio.ReadCloser(d.Get("certificate_file.0").(map[string]interface{})) - // if err != nil { - // return diag.FromErr(err) - // } - createKeyStorePemCertificateOptions.SetCertificateFile(rc) + createKeyStorePemCertificateOptions.SetCertificateFile(io.NopCloser(bytes.NewReader(certificateFileBytes))) keyStoreCertificateDetails, response, err := mqcloudClient.CreateKeyStorePemCertificateWithContext(context, createKeyStorePemCertificateOptions) if err != nil { @@ -225,16 +218,13 @@ func resourceIbmMqcloudKeystoreCertificateRead(context context.Context, d *schem log.Printf("[DEBUG] GetKeyStoreCertificateWithContext failed %s\n%s", err, response) return diag.FromErr(fmt.Errorf("GetKeyStoreCertificateWithContext failed %s\n%s", err, response)) } + if err = d.Set("service_instance_guid", parts[0]); err != nil { return diag.FromErr(fmt.Errorf("Error setting service_instance_guid: %s", err)) } if err = d.Set("queue_manager_id", parts[1]); err != nil { return diag.FromErr(fmt.Errorf("Error setting queue_manager_id: %s", err)) } - downloadCertificatePath := "./certificates/keystore/" + *keyStoreCertificateDetails.Label + ".pem" - if err = d.Set("certificate_file", downloadCertificatePath); err != nil { - return diag.FromErr(fmt.Errorf("Error setting certificate_file: %s", err)) - } if err = d.Set("label", keyStoreCertificateDetails.Label); err != nil { return diag.FromErr(fmt.Errorf("Error setting label: %s", err)) } diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate_test.go index 5041c8ed77..83461fc0a2 100644 --- a/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate_test.go +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate_test.go @@ -18,6 +18,7 @@ import ( ) func TestAccIbmMqcloudKeystoreCertificateBasic(t *testing.T) { + t.Parallel() var conf mqcloudv1.KeyStoreCertificateDetails serviceInstanceGuid := acc.MqcloudInstanceID queueManagerID := acc.MqcloudQueueManagerID @@ -38,35 +39,11 @@ func TestAccIbmMqcloudKeystoreCertificateBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "label", label), ), }, - }, - }) -} - -func TestAccIbmMqcloudKeystoreCertificateAllArgs(t *testing.T) { - var conf mqcloudv1.KeyStoreCertificateDetails - serviceInstanceGuid := acc.MqcloudInstanceID - queueManagerID := acc.MqcloudQueueManagerID - label := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) - certificateFile := acc.MqcloudKSCertFilePath - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIbmMqcloudKeystoreCertificateDestroy, - Steps: []resource.TestStep{ { - Config: testAccCheckIbmMqcloudKeystoreCertificateConfig(serviceInstanceGuid, queueManagerID, label, certificateFile), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmMqcloudKeystoreCertificateExists("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", conf), - resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "service_instance_guid", serviceInstanceGuid), - resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "queue_manager_id", queueManagerID), - resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "label", label), - ), - }, - { - ResourceName: "ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", - ImportState: true, - ImportStateVerify: true, + ResourceName: "ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"certificate_file"}, }, }, }) @@ -78,19 +55,7 @@ func testAccCheckIbmMqcloudKeystoreCertificateConfigBasic(serviceInstanceGuid st service_instance_guid = "%s" queue_manager_id = "%s" label = "%s" - certificate_file = "%s" - } - `, serviceInstanceGuid, queueManagerID, label, certificateFile) -} - -func testAccCheckIbmMqcloudKeystoreCertificateConfig(serviceInstanceGuid string, queueManagerID string, label string, certificateFile string) string { - return fmt.Sprintf(` - - resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { - service_instance_guid = "%s" - queue_manager_id = "%s" - label = "%s" - certificate_file = "%s" + certificate_file = filebase64("%s") } `, serviceInstanceGuid, queueManagerID, label, certificateFile) } diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager.go b/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager.go index a94f6fa5c9..252837593f 100644 --- a/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager.go +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager.go @@ -252,14 +252,15 @@ func resourceIbmMqcloudQueueManagerRead(context context.Context, d *schema.Resou var queueManagerDetails *mqcloudv1.QueueManagerDetails var response *core.DetailedResponse - err = resource.RetryContext(context, 10*time.Second, func() *resource.RetryError { + err = resource.RetryContext(context, 150*time.Second, func() *resource.RetryError { queueManagerDetails, response, err = mqcloudClient.GetQueueManagerWithContext(context, getQueueManagerOptions) - if err != nil || response == nil { - if response.StatusCode == 404 { - return resource.RetryableError(err) + if err != nil || queueManagerDetails == nil { + if response != nil && response.StatusCode == 404 { + return resource.RetryableError(fmt.Errorf("Queue Manager not found, retrying")) } return resource.NonRetryableError(err) } + return nil }) diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager_test.go index a6ccbd7feb..d010549e4f 100644 --- a/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager_test.go +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager_test.go @@ -14,14 +14,15 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" "github.com/IBM/mqcloud-go-sdk/mqcloudv1" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" ) func TestAccIbmMqcloudQueueManagerBasic(t *testing.T) { t.Parallel() var conf mqcloudv1.QueueManagerDetails serviceInstanceGuid := acc.MqcloudInstanceID - name := "queue_manager_basic" - location := "ibmcloud_eu_de" + name := fmt.Sprintf("tf_queue_manager_basic%d", acctest.RandIntRange(10, 100)) + location := acc.MqCloudQueueManagerLocation size := "small" resource.Test(t, resource.TestCase{ @@ -47,12 +48,12 @@ func TestAccIbmMqcloudQueueManagerAllArgs(t *testing.T) { t.Parallel() var conf mqcloudv1.QueueManagerDetails serviceInstanceGuid := acc.MqcloudInstanceID - name := "queue_manager_allargs" - displayName := "queue_manager_allargs" - location := "ibmcloud_eu_de" + name := fmt.Sprintf("tf_queue_manager_allargs%d", acctest.RandIntRange(10, 100)) + displayName := name + location := acc.MqCloudQueueManagerLocation size := "small" - version := "9.3.3_3" - versionUpdate := "9.3.4_1" + version := acc.MqCloudQueueManagerVersion + versionUpdate := acc.MqCloudQueueManagerVersionUpdate resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate.go b/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate.go index 63a35c247e..ed12be2ddf 100644 --- a/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate.go +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate.go @@ -4,12 +4,12 @@ package mqcloud import ( + "bytes" "context" + "encoding/base64" "fmt" "io" "log" - "os" - "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -47,7 +47,13 @@ func ResourceIbmMqcloudTruststoreCertificate() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: validate.InvokeValidator("ibm_mqcloud_truststore_certificate", "label"), - Description: "Certificate label in queue manager store.", + Description: "The label to use for the certificate to be uploaded.", + }, + "certificate_file": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The filename and path of the certificate to be uploaded.", }, "certificate_type": { Type: schema.TypeString, @@ -104,12 +110,6 @@ func ResourceIbmMqcloudTruststoreCertificate() *schema.Resource { Computed: true, Description: "Id of the certificate.", }, - "certificate_file": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The filename and path of the certificate to be uploaded.", - }, }, } } @@ -165,18 +165,11 @@ func resourceIbmMqcloudTruststoreCertificateCreate(context context.Context, d *s createTrustStorePemCertificateOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) createTrustStorePemCertificateOptions.SetQueueManagerID(d.Get("queue_manager_id").(string)) createTrustStorePemCertificateOptions.SetLabel(d.Get("label").(string)) - //Custom code to read certs and pass to SDK - certBytes, err := os.ReadFile(d.Get("certificate_file").(string)) // just pass the file name + certificateFileBytes, err := base64.StdEncoding.DecodeString(d.Get("certificate_file").(string)) if err != nil { - fmt.Print(err) + return diag.FromErr(err) } - certString := string(certBytes) // convert content to a 'string' - rc := io.NopCloser(strings.NewReader(certString)) - // certificateFileModel, err := resourceIbmMqcloudTruststoreCertificateMapToio.ReadCloser(d.Get("certificate_file.0").(map[string]interface{})) - // if err != nil { - // return diag.FromErr(err) - // } - createTrustStorePemCertificateOptions.SetCertificateFile(rc) + createTrustStorePemCertificateOptions.SetCertificateFile(io.NopCloser(bytes.NewReader(certificateFileBytes))) trustStoreCertificateDetails, response, err := mqcloudClient.CreateTrustStorePemCertificateWithContext(context, createTrustStorePemCertificateOptions) if err != nil { @@ -215,16 +208,13 @@ func resourceIbmMqcloudTruststoreCertificateRead(context context.Context, d *sch log.Printf("[DEBUG] GetTrustStoreCertificateWithContext failed %s\n%s", err, response) return diag.FromErr(fmt.Errorf("GetTrustStoreCertificateWithContext failed %s\n%s", err, response)) } + if err = d.Set("service_instance_guid", parts[0]); err != nil { return diag.FromErr(fmt.Errorf("Error setting service_instance_guid: %s", err)) } if err = d.Set("queue_manager_id", parts[1]); err != nil { return diag.FromErr(fmt.Errorf("Error setting queue_manager_id: %s", err)) } - downloadCertificatePath := "./certificates/truststore/" + *trustStoreCertificateDetails.Label + ".pem" - if err = d.Set("certificate_file", downloadCertificatePath); err != nil { - return diag.FromErr(fmt.Errorf("Error setting certificate_file: %s", err)) - } if err = d.Set("label", trustStoreCertificateDetails.Label); err != nil { return diag.FromErr(fmt.Errorf("Error setting label: %s", err)) } diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate_test.go index 80acc0e4a1..bfea0ce68e 100644 --- a/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate_test.go +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate_test.go @@ -18,6 +18,7 @@ import ( ) func TestAccIbmMqcloudTruststoreCertificateBasic(t *testing.T) { + t.Parallel() var conf mqcloudv1.TrustStoreCertificateDetails serviceInstanceGuid := acc.MqcloudInstanceID queueManagerID := acc.MqcloudQueueManagerID @@ -38,35 +39,11 @@ func TestAccIbmMqcloudTruststoreCertificateBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "label", label), ), }, - }, - }) -} - -func TestAccIbmMqcloudTruststoreCertificateAllArgs(t *testing.T) { - var conf mqcloudv1.TrustStoreCertificateDetails - serviceInstanceGuid := acc.MqcloudInstanceID - queueManagerID := acc.MqcloudQueueManagerID - label := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) - certificateFile := acc.MqcloudTSCertFilePath - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIbmMqcloudTruststoreCertificateDestroy, - Steps: []resource.TestStep{ { - Config: testAccCheckIbmMqcloudTruststoreCertificateConfig(serviceInstanceGuid, queueManagerID, label, certificateFile), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmMqcloudTruststoreCertificateExists("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", conf), - resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "service_instance_guid", serviceInstanceGuid), - resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "queue_manager_id", queueManagerID), - resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "label", label), - ), - }, - { - ResourceName: "ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", - ImportState: true, - ImportStateVerify: true, + ResourceName: "ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"certificate_file"}, }, }, }) @@ -78,19 +55,7 @@ func testAccCheckIbmMqcloudTruststoreCertificateConfigBasic(serviceInstanceGuid service_instance_guid = "%s" queue_manager_id = "%s" label = "%s" - certificate_file = "%s" - } - `, serviceInstanceGuid, queueManagerID, label, certificateFile) -} - -func testAccCheckIbmMqcloudTruststoreCertificateConfig(serviceInstanceGuid string, queueManagerID string, label string, certificateFile string) string { - return fmt.Sprintf(` - - resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { - service_instance_guid = "%s" - queue_manager_id = "%s" - label = "%s" - certificate_file = "%s" + certificate_file = filebase64("%s") } `, serviceInstanceGuid, queueManagerID, label, certificateFile) } diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_user_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_user_test.go index 551827f583..fd7ad738af 100644 --- a/ibm/service/mqcloud/resource_ibm_mqcloud_user_test.go +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_user_test.go @@ -18,6 +18,7 @@ import ( ) func TestAccIbmMqcloudUserBasic(t *testing.T) { + t.Parallel() var conf mqcloudv1.UserDetails serviceInstanceGuid := acc.MqcloudInstanceID name := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) @@ -37,30 +38,6 @@ func TestAccIbmMqcloudUserBasic(t *testing.T) { resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "email", email), ), }, - }, - }) -} - -func TestAccIbmMqcloudUserAllArgs(t *testing.T) { - var conf mqcloudv1.UserDetails - serviceInstanceGuid := acc.MqcloudInstanceID - name := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) - email := fmt.Sprintf("tfemail%d@ibm.com", acctest.RandIntRange(10, 100)) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIbmMqcloudUserDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIbmMqcloudUserConfig(serviceInstanceGuid, name, email), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIbmMqcloudUserExists("ibm_mqcloud_user.mqcloud_user_instance", conf), - resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "service_instance_guid", serviceInstanceGuid), - resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "name", name), - resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "email", email), - ), - }, { ResourceName: "ibm_mqcloud_user.mqcloud_user_instance", ImportState: true, @@ -80,17 +57,6 @@ func testAccCheckIbmMqcloudUserConfigBasic(serviceInstanceGuid string, name stri `, serviceInstanceGuid, name, email) } -func testAccCheckIbmMqcloudUserConfig(serviceInstanceGuid string, name string, email string) string { - return fmt.Sprintf(` - - resource "ibm_mqcloud_user" "mqcloud_user_instance" { - service_instance_guid = "%s" - name = "%s" - email = "%s" - } - `, serviceInstanceGuid, name, email) -} - func testAccCheckIbmMqcloudUserExists(n string, obj mqcloudv1.UserDetails) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] diff --git a/ibm/service/mqcloud/utils.go b/ibm/service/mqcloud/utils.go index 877b5ed79b..58cd7c50eb 100644 --- a/ibm/service/mqcloud/utils.go +++ b/ibm/service/mqcloud/utils.go @@ -33,7 +33,7 @@ const isQueueManagerDeleteDone = "true" const reservedDeploymentPlan = "reserved-deployment" const enforceReservedDeploymentPlan = true -// waitForQmStatusUpdate Waits for QM to be in running state +// waitForQmStatusUpdate waits for Queue Manager to be in running state func waitForQmStatusUpdate(context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() if err != nil { @@ -58,7 +58,6 @@ func waitForQmStatusUpdate(context context.Context, d *schema.ResourceData, meta if queueManagerStatus == nil || queueManagerStatus.Status == nil { return nil, "", fmt.Errorf("queueManagerStatus or queueManagerStatus.Status is nil") } - fmt.Println("The queue manager is currently in the " + *queueManagerStatus.Status + " state ....") if *queueManagerStatus.Status == "running" { return queueManagerStatus, qmStatus, nil @@ -135,7 +134,7 @@ func checkSIPlan(d *schema.ResourceData, meta interface{}) error { } instance, response, err := rsConClient.GetResourceInstance(&rsInst) if err != nil { - return fmt.Errorf("[ERROR] Failed to retrieve resource instance: %s, Response: %s", err, response) + return fmt.Errorf("[ERROR] Failed to retrieve Resource Instance: %s, Response: %s", err, response) } // Creating a Resource Catalog Client @@ -148,7 +147,7 @@ func checkSIPlan(d *schema.ResourceData, meta interface{}) error { // Checking the service plan plan, err := rsCatRepo.GetServicePlanName(*instance.ResourcePlanID) if err != nil { - return fmt.Errorf("[ERROR] Failed to retrieve service plan: %s", err) + return fmt.Errorf("[ERROR] Failed to retrieve Service Plan: %s", err) } // Update cache diff --git a/website/docs/r/mqcloud_keystore_certificate.html.markdown b/website/docs/r/mqcloud_keystore_certificate.html.markdown index e3b1a0108c..b4740f2661 100644 --- a/website/docs/r/mqcloud_keystore_certificate.html.markdown +++ b/website/docs/r/mqcloud_keystore_certificate.html.markdown @@ -14,6 +14,7 @@ Create, update, and delete mqcloud_keystore_certificates with this resource. ```hcl resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + certificate_file = filebase64("certificate_file.data") label = "label" queue_manager_id = var.queue_manager_id service_instance_guid = var.service_instance_guid @@ -24,7 +25,9 @@ resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instan You can specify the following arguments for this resource. -* `label` - (Required, Forces new resource, String) Certificate label in queue manager store. +* `certificate_file` - (Required, Forces new resource, String) The filename and path of the certificate to be uploaded. + * Constraints: The maximum length is `65537` characters. The minimum length is `1500` characters. +* `label` - (Required, Forces new resource, String) The label to use for the certificate to be uploaded. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9_.]*$/`. * `queue_manager_id` - (Required, Forces new resource, String) The id of the queue manager to retrieve its full details. * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-fA-F]{32}$/`. @@ -67,6 +70,10 @@ The `id` property can be formed from `service_instance_guid`, `queue_manager_id` * `queue_manager_id`: A string in the format `b8e1aeda078009cf3db74e90d5d42328`. The id of the queue manager to retrieve its full details. * `certificate_id`: A string. ID of the certificate. +> ### Important Note +> When configuring the `ibm_mqcloud_keystore_certificate` resource in the root module: +> Ensure to set the `certificate_file` value to an empty string (`certificate_file=""`). This step is crucial as we are not downloading the certificate to the local system. + # Syntax
 $ terraform import ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate <service_instance_guid>/<queue_manager_id>/<certificate_id>
diff --git a/website/docs/r/mqcloud_queue_manager.html.markdown b/website/docs/r/mqcloud_queue_manager.html.markdown
index b26b62631e..abb8eec5f6 100644
--- a/website/docs/r/mqcloud_queue_manager.html.markdown
+++ b/website/docs/r/mqcloud_queue_manager.html.markdown
@@ -15,7 +15,7 @@ Create, update, and delete mqcloud_queue_managers with this resource.
 ```hcl
 resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" {
   display_name = "A test queue manager"
-  location = "reserved-eu-fr-cluster-f884"
+  location = "reserved-eu-de-cluster-f884"
   name = "testqm"
   service_instance_guid = var.service_instance_guid
   size = "lite"
diff --git a/website/docs/r/mqcloud_truststore_certificate.html.markdown b/website/docs/r/mqcloud_truststore_certificate.html.markdown
index ebc00ef103..66d9ab191b 100644
--- a/website/docs/r/mqcloud_truststore_certificate.html.markdown
+++ b/website/docs/r/mqcloud_truststore_certificate.html.markdown
@@ -14,6 +14,7 @@ Create, update, and delete mqcloud_truststore_certificates with this resource.
 
 ```hcl
 resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" {
+  certificate_file = filebase64("certificate_file.data")
   label = "label"
   queue_manager_id = var.queue_manager_id
   service_instance_guid = var.service_instance_guid
@@ -24,7 +25,9 @@ resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_in
 
 You can specify the following arguments for this resource.
 
-* `label` - (Required, Forces new resource, String) Certificate label in queue manager store.
+* `certificate_file` - (Required, Forces new resource, String) The filename and path of the certificate to be uploaded.
+  * Constraints: The maximum length is `65537` characters. The minimum length is `1500` characters.
+* `label` - (Required, Forces new resource, String) The label to use for the certificate to be uploaded.
   * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9_.]*$/`.
 * `queue_manager_id` - (Required, Forces new resource, String) The id of the queue manager to retrieve its full details.
   * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-fA-F]{32}$/`.
@@ -64,6 +67,10 @@ The `id` property can be formed from `service_instance_guid`, `queue_manager_id`
 * `queue_manager_id`: A string in the format `b8e1aeda078009cf3db74e90d5d42328`. The id of the queue manager to retrieve its full details.
 * `certificate_id`: A string. Id of the certificate.
 
+> ### Important Note
+> When configuring the `ibm_mqcloud_keystore_certificate` resource in the root module:
+> Ensure to set the `certificate_file` value to an empty string (`certificate_file=""`). This step is crucial as we are not downloading the certificate to the local system.
+
 # Syntax
 
 $ terraform import ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate <service_instance_guid>/<queue_manager_id>/<certificate_id>

From b5794002f39d894330773d9057cb62d5874e7916 Mon Sep 17 00:00:00 2001
From: Ujjwal Kumar 
Date: Thu, 28 Dec 2023 23:07:22 +0530
Subject: [PATCH 6/7] added a nil check for boottarget of bms

---
 ibm/service/vpc/resource_ibm_is_bare_metal_server.go | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ibm/service/vpc/resource_ibm_is_bare_metal_server.go b/ibm/service/vpc/resource_ibm_is_bare_metal_server.go
index 8e419168b9..0d16c8493b 100644
--- a/ibm/service/vpc/resource_ibm_is_bare_metal_server.go
+++ b/ibm/service/vpc/resource_ibm_is_bare_metal_server.go
@@ -1361,9 +1361,11 @@ func bareMetalServerGet(context context.Context, d *schema.ResourceData, meta in
 	}
 	d.SetId(*bms.ID)
 	d.Set(isBareMetalServerBandwidth, bms.Bandwidth)
-	bmsBootTargetIntf := bms.BootTarget.(*vpcv1.BareMetalServerBootTarget)
-	bmsBootTarget := bmsBootTargetIntf.ID
-	d.Set(isBareMetalServerBootTarget, bmsBootTarget)
+	if bms.BootTarget != nil {
+		bmsBootTargetIntf := bms.BootTarget.(*vpcv1.BareMetalServerBootTarget)
+		bmsBootTarget := bmsBootTargetIntf.ID
+		d.Set(isBareMetalServerBootTarget, bmsBootTarget)
+	}
 	cpuList := make([]map[string]interface{}, 0)
 	if bms.Cpu != nil {
 		currentCPU := map[string]interface{}{}

From 160caa0fcaf0c6aecb07b937afc0d3cf6b33f3c3 Mon Sep 17 00:00:00 2001
From: SunithaGudisagar 
Date: Fri, 29 Dec 2023 23:26:39 +0530
Subject: [PATCH 7/7] Delete wait logic changes

---
 ibm/service/vpc/resource_ibm_is_vpn_server.go       | 4 ++--
 ibm/service/vpc/resource_ibm_is_vpn_server_route.go | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ibm/service/vpc/resource_ibm_is_vpn_server.go b/ibm/service/vpc/resource_ibm_is_vpn_server.go
index 23a6e5ecdb..fa0042b9af 100644
--- a/ibm/service/vpc/resource_ibm_is_vpn_server.go
+++ b/ibm/service/vpc/resource_ibm_is_vpn_server.go
@@ -1027,9 +1027,9 @@ func isWaitForVPNServerDeleted(context context.Context, sess *vpcv1.VpcV1, d *sc
 				if response != nil && response.StatusCode == 404 {
 					return vpnServer, isVPNServerStatusDeleted, nil
 				}
-				return vpnServer, isVPNServerStatusDeleting, fmt.Errorf("The VPC route %s failed to delete: %s\n%s", d.Id(), err, response)
+				return vpnServer, *vpnServer.LifecycleState, fmt.Errorf("The VPC vpn server %s failed to delete: %s\n%s", d.Id(), err, response)
 			}
-			return vpnServer, isVPNServerStatusDeleting, nil
+			return vpnServer, *vpnServer.LifecycleState, nil
 
 		},
 		Timeout:    d.Timeout(schema.TimeoutDelete),
diff --git a/ibm/service/vpc/resource_ibm_is_vpn_server_route.go b/ibm/service/vpc/resource_ibm_is_vpn_server_route.go
index ed38a19bd8..95ce9764cd 100644
--- a/ibm/service/vpc/resource_ibm_is_vpn_server_route.go
+++ b/ibm/service/vpc/resource_ibm_is_vpn_server_route.go
@@ -422,9 +422,9 @@ func isWaitForVPNServerRouteDeleted(context context.Context, sess *vpcv1.VpcV1,
 				if response != nil && response.StatusCode == 404 {
 					return vpnServerRoute, isVPNServerRouteStatusDeleted, nil
 				}
-				return vpnServerRoute, isVPNServerRouteStatusDeleting, fmt.Errorf("The VPC route %s failed to delete: %s\n%s", d.Id(), err, response)
+				return vpnServerRoute, *vpnServerRoute.LifecycleState, fmt.Errorf("The VPC route %s failed to delete: %s\n%s", d.Id(), err, response)
 			}
-			return vpnServerRoute, isVPNServerRouteStatusDeleting, nil
+			return vpnServerRoute, *vpnServerRoute.LifecycleState, nil
 
 		},
 		Timeout:    d.Timeout(schema.TimeoutDelete),