Skip to content

Commit

Permalink
feat(MQaaS): Add Virtual Private Endpoint Gateway Resource (#5804)
Browse files Browse the repository at this point in the history
* feat(MQaaS): Add Virtual Private Endpoint Gateway Resource

MQ on Cloud is now renamed to MQ as a Service (MQaaS)

* Add missing env

* Change to CapacityID

* push change to fix tests

* fix error message

* add plan names in error message

* Clean up after running tests

* Use latest SDK to consume VPEG resources
  • Loading branch information
SowmyaGrama authored Nov 26, 2024
1 parent caa07a4 commit a0d45f7
Show file tree
Hide file tree
Showing 58 changed files with 1,494 additions and 207 deletions.
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test: fmtcheck
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4

testacc: fmtcheck
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout $(TEST_TIMEOUT)
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout $(TEST_TIMEOUT)

testrace: fmtcheck
TF_ACC= go test -race $(TEST) $(TESTARGS)
Expand Down
115 changes: 99 additions & 16 deletions examples/ibm-mqcloud/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Examples for MQ on Cloud
# Examples for MQaaS

These examples illustrate how to use the resources and data sources associated with MQ on Cloud.
These examples illustrate how to use the resources and data sources associated with MQaaS.

The following resources are supported:
* ibm_mqcloud_queue_manager
* ibm_mqcloud_application
* ibm_mqcloud_user
* ibm_mqcloud_keystore_certificate
* ibm_mqcloud_truststore_certificate
* ibm_mqcloud_virtual_private_endpoint_gateway

The following data sources are supported:
* ibm_mqcloud_queue_manager_options
Expand All @@ -17,6 +18,8 @@ The following data sources are supported:
* ibm_mqcloud_user
* ibm_mqcloud_truststore_certificate
* ibm_mqcloud_keystore_certificate
* ibm_mqcloud_virtual_private_endpoint_gateways
* ibm_mqcloud_virtual_private_endpoint_gateway

## Usage

Expand All @@ -30,7 +33,7 @@ $ terraform apply

Run `terraform destroy` when you don't need these resources.

## MQ on Cloud resources
## MQaaS resources

### Resource: ibm_mqcloud_queue_manager

Expand All @@ -50,7 +53,7 @@ resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" {
| 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 |
| service_instance_guid | The GUID that uniquely identifies the MQaaS 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 |
Expand Down Expand Up @@ -86,7 +89,7 @@ resource "ibm_mqcloud_application" "mqcloud_application_instance" {
| 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 |
| service_instance_guid | The GUID that uniquely identifies the MQaaS service instance. | `string` | true |
| name | The name of the application - conforming to MQ rules. | `string` | true |

#### Outputs
Expand All @@ -112,7 +115,7 @@ resource "ibm_mqcloud_user" "mqcloud_user_instance" {
| 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 |
| service_instance_guid | The GUID that uniquely identifies the MQaaS 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 |

Expand Down Expand Up @@ -147,7 +150,7 @@ resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instan
| 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 |
| service_instance_guid | The GUID that uniquely identifies the MQaaS 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 |
Expand Down Expand Up @@ -187,7 +190,7 @@ resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_in
| 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 |
| service_instance_guid | The GUID that uniquely identifies the MQaaS 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 |
Expand All @@ -208,7 +211,36 @@ resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_in
| href | The URL for this trust store certificate. |
| certificate_id | Id of the certificate. |

## MQ on Cloud data sources
### Resource: ibm_mqcloud_virtual_private_endpoint_gateway

```hcl
resource "ibm_mqcloud_virtual_private_endpoint_gateway" "mqcloud_virtual_private_endpoint_gateway_instance" {
service_instance_guid = var.mqcloud_virtual_private_endpoint_gateway_service_instance_guid
trusted_profile = var.mqcloud_virtual_private_endpoint_gateway_trusted_profile
name = var.mqcloud_virtual_private_endpoint_gateway_name
target_crn = var.mqcloud_virtual_private_endpoint_gateway_target_crn
}
```

#### Inputs

| Name | Description | Type | Required |
|------|-------------|------|---------|
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
| service_instance_guid | The GUID that uniquely identifies the MQaaS service instance. | `string` | true |
| trusted_profile | The CRN of the trusted profile to assume for this request. | `string` | false |
| name | The name of the virtual private endpoint gateway, created by the user. | `string` | true |
| target_crn | The CRN of the reserved capacity service instance the user is trying to connect to. | `string` | true |

#### Outputs

| Name | Description |
|------|-------------|
| href | URL for the details of the virtual private endpoint gateway. |
| status | The lifecycle state of this virtual privage endpoint. |
| virtual_private_endpoint_gateway_guid | The ID of the virtual private endpoint gateway which was allocated on creation. |

## MQaaS data sources

### Data source: ibm_mqcloud_queue_manager_options

Expand All @@ -222,7 +254,7 @@ data "ibm_mqcloud_queue_manager_options" "mqcloud_queue_manager_options_instance

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true |
| service_instance_guid | The GUID that uniquely identifies the MQaaS service instance. | `string` | true |

#### Outputs

Expand All @@ -246,7 +278,7 @@ data "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" {

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true |
| service_instance_guid | The GUID that uniquely identifies the MQaaS service instance. | `string` | true |
| name | A queue manager name conforming to MQ restrictions. | `string` | false |

#### Outputs
Expand All @@ -268,7 +300,7 @@ data "ibm_mqcloud_queue_manager_status" "mqcloud_queue_manager_status_instance"

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true |
| service_instance_guid | The GUID that uniquely identifies the MQaaS service instance. | `string` | true |
| queue_manager_id | The id of the queue manager to retrieve its full details. | `string` | true |

#### Outputs
Expand All @@ -290,7 +322,7 @@ data "ibm_mqcloud_application" "mqcloud_application_instance" {

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true |
| service_instance_guid | The GUID that uniquely identifies the MQaaS service instance. | `string` | true |
| name | The name of the application - conforming to MQ rules. | `string` | false |

#### Outputs
Expand All @@ -312,7 +344,7 @@ data "ibm_mqcloud_user" "mqcloud_user_instance" {

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true |
| service_instance_guid | The GUID that uniquely identifies the MQaaS 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
Expand All @@ -335,7 +367,7 @@ data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instan

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true |
| service_instance_guid | The GUID that uniquely identifies the MQaaS 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 |

Expand All @@ -360,7 +392,7 @@ data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance"

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true |
| service_instance_guid | The GUID that uniquely identifies the MQaaS 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 |

Expand All @@ -371,6 +403,57 @@ data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance"
| total_count | The total count of key store certificates. |
| key_store | The list of key store certificates. |

### Data source: ibm_mqcloud_virtual_private_endpoint_gateways

```hcl
data "ibm_mqcloud_virtual_private_endpoint_gateways" "mqcloud_virtual_private_endpoint_gateways_instance" {
service_instance_guid = var.mqcloud_virtual_private_endpoint_gateways_service_instance_guid
trusted_profile = var.mqcloud_virtual_private_endpoint_gateways_trusted_profile
name = var.mqcloud_virtual_private_endpoint_gateways_name
}
```

#### Inputs

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQaaS service instance. | `string` | true |
| trusted_profile | The CRN of the trusted profile to assume for this request. | `string` | false |
| name | The name of the virtual private endpoint gateway, created by the user. | `string` | false |

#### Outputs

| Name | Description |
|------|-------------|
| virtual_private_endpoint_gateways | List of virtual private endpoint gateways. |

### Data source: ibm_mqcloud_virtual_private_endpoint_gateway

```hcl
data "ibm_mqcloud_virtual_private_endpoint_gateway" "mqcloud_virtual_private_endpoint_gateway_instance" {
service_instance_guid = var.data_mqcloud_virtual_private_endpoint_gateway_service_instance_guid
virtual_private_endpoint_gateway_guid = var.data_mqcloud_virtual_private_endpoint_gateway_virtual_private_endpoint_gateway_guid
trusted_profile = var.data_mqcloud_virtual_private_endpoint_gateway_trusted_profile
}
```

#### Inputs

| Name | Description | Type | Required |
|------|-------------|------|---------|
| service_instance_guid | The GUID that uniquely identifies the MQaaS service instance. | `string` | true |
| virtual_private_endpoint_gateway_guid | The id of the virtual private endpoint gateway. | `string` | true |
| trusted_profile | The CRN of the trusted profile to assume for this request. | `string` | false |

#### Outputs

| Name | Description |
|------|-------------|
| href | URL for the details of the virtual private endpoint gateway. |
| name | The name of the virtual private endpoint gateway, created by the user. |
| target_crn | The CRN of the reserved capacity service instance the user is trying to connect to. |
| status | The lifecycle state of this virtual privage endpoint. |

## Assumptions

1. TODO
Expand Down
54 changes: 43 additions & 11 deletions examples/ibm-mqcloud/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ provider "ibm" {
// Provision mqcloud_queue_manager resource 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
location = var.mqcloud_queue_manager_location
size = var.mqcloud_queue_manager_size
version = var.mqcloud_queue_manager_version
name = var.mqcloud_queue_manager_name
display_name = var.mqcloud_queue_manager_display_name
location = var.mqcloud_queue_manager_location
size = var.mqcloud_queue_manager_size
version = var.mqcloud_queue_manager_version
}

// Provision mqcloud_application resource instance
resource "ibm_mqcloud_application" "mqcloud_application_instance" {
service_instance_guid = var.mqcloud_application_service_instance_guid
name = var.mqcloud_application_name
name = var.mqcloud_application_name
}

// Provision mqcloud_user resource 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
name = var.mqcloud_user_name
email = var.mqcloud_user_email
}

// Provision mqcloud_keystore_certificate resource instance
Expand All @@ -32,6 +32,8 @@ resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instan
label = var.mqcloud_keystore_certificate_label
certificate_file = var.mqcloud_keystore_certificate_certificate_file

certificate_file = var.mqcloud_keystore_certificate_certificate_file

config {
ams {
channels {
Expand All @@ -44,9 +46,17 @@ resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instan
// Provision mqcloud_truststore_certificate resource 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
queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id
label = var.mqcloud_truststore_certificate_label
certificate_file = var.mqcloud_truststore_certificate_certificate_file
}

// Provision mqcloud_virtual_private_endpoint_gateway resource instance
resource "ibm_mqcloud_virtual_private_endpoint_gateway" "mqcloud_virtual_private_endpoint_gateway_instance" {
service_instance_guid = var.mqcloud_virtual_private_endpoint_gateway_service_instance_guid
trusted_profile = var.mqcloud_virtual_private_endpoint_gateway_trusted_profile
name = var.mqcloud_virtual_private_endpoint_gateway_name
target_crn = var.mqcloud_virtual_private_endpoint_gateway_target_crn
}

// Data source is not linked to a resource instance
Expand Down Expand Up @@ -119,3 +129,25 @@ data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance"
label = var.data_mqcloud_keystore_certificate_label
}
*/

// Data source is not linked to a resource instance
// Uncomment if an existing data source instance exists
/*
// Create mqcloud_virtual_private_endpoint_gateways data source
data "ibm_mqcloud_virtual_private_endpoint_gateways" "mqcloud_virtual_private_endpoint_gateways_instance" {
service_instance_guid = var.mqcloud_virtual_private_endpoint_gateways_service_instance_guid
trusted_profile = var.mqcloud_virtual_private_endpoint_gateways_trusted_profile
name = var.mqcloud_virtual_private_endpoint_gateways_name
}
*/

// Data source is not linked to a resource instance
// Uncomment if an existing data source instance exists
/*
// Create mqcloud_virtual_private_endpoint_gateway data source
data "ibm_mqcloud_virtual_private_endpoint_gateway" "mqcloud_virtual_private_endpoint_gateway_instance" {
service_instance_guid = var.data_mqcloud_virtual_private_endpoint_gateway_service_instance_guid
virtual_private_endpoint_gateway_guid = var.data_mqcloud_virtual_private_endpoint_gateway_virtual_private_endpoint_gateway_guid
trusted_profile = var.data_mqcloud_virtual_private_endpoint_gateway_trusted_profile
}
*/
6 changes: 6 additions & 0 deletions examples/ibm-mqcloud/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,9 @@ output "ibm_mqcloud_truststore_certificate" {
value = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance
description = "mqcloud_truststore_certificate resource instance"
}
// This output allows mqcloud_virtual_private_endpoint_gateway data to be referenced by other resources and the terraform CLI
// Modify this output if only certain data should be exposed
output "ibm_mqcloud_virtual_private_endpoint_gateway" {
value = ibm_mqcloud_virtual_private_endpoint_gateway.mqcloud_virtual_private_endpoint_gateway_instance
description = "mqcloud_virtual_private_endpoint_gateway resource instance"
}
Loading

0 comments on commit a0d45f7

Please sign in to comment.