Skip to content

Commit

Permalink
[Datasource] Workspace NSG update
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkad committed Sep 18, 2024
1 parent 2aa2176 commit 82aad7a
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 24 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.5
require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113
github.com/IBM-Cloud/power-go-client v1.7.0
github.com/IBM-Cloud/power-go-client v1.8.0-beta17
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be/go.mod h1:/7h
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113 h1:f2Erqfea1dKpaTFagTJM6W/wnD3JGq/Vn9URh8nuRwk=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.7.0 h1:/GuGwPMTKoCZACfnwt7b6wKr4v32q1VO1AMFGNETRN4=
github.com/IBM-Cloud/power-go-client v1.7.0/go.mod h1:9izycYAmNQ+NAdVPXDC3fHYxqWLjlR2YiwqKYveMv5Y=
github.com/IBM-Cloud/power-go-client v1.8.0-beta17 h1:zL/qQUs/bb8L0FEazcBcpr7wTCpv0CJp/dbpg6351Qc=
github.com/IBM-Cloud/power-go-client v1.8.0-beta17/go.mod h1:oAkZiHX25cmr2Yun5V0q6CpnUemegvSrpcEy/oQcjzU=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4=
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs=
Expand All @@ -138,8 +138,6 @@ github.com/IBM/container-registry-go-sdk v1.1.0 h1:sYyknIod8R4RJZQqAheiduP6wbSTp
github.com/IBM/container-registry-go-sdk v1.1.0/go.mod h1:4TwsCnQtVfZ4Vkapy/KPvQBKFc3VOyUZYkwRU4FTPrs=
github.com/IBM/continuous-delivery-go-sdk v1.6.0 h1:eAL/jIWHrDFlWDF+Qd9Y5UN99Pr5Mjd/H/bvTbXUbz4=
github.com/IBM/continuous-delivery-go-sdk v1.6.0/go.mod h1:nZdKUnubXNLo+zo28R4Rd+TGDqiJ/xoE8WO/A3kLw1E=
github.com/IBM/event-notifications-go-admin-sdk v0.8.0 h1:xk2CYTayQtKi6LSgGGFRxFJfWUxyM5SY8Rs64ducAhw=
github.com/IBM/event-notifications-go-admin-sdk v0.8.0/go.mod h1:OByvqfrNVxs7G6ggv8pwQCEVw10/TBJCLh7NM3z707w=
github.com/IBM/event-notifications-go-admin-sdk v0.9.0 h1:eaCd+GkxhNyot+8rA9WkAQdlVYrRD20LYiXjEytFO6M=
github.com/IBM/event-notifications-go-admin-sdk v0.9.0/go.mod h1:OByvqfrNVxs7G6ggv8pwQCEVw10/TBJCLh7NM3z707w=
github.com/IBM/eventstreams-go-sdk v1.4.0 h1:yS/Ns29sBOe8W2tynQmz9HTKqQZ0ckse4Py5Oy/F2rM=
Expand Down Expand Up @@ -187,8 +185,6 @@ github.com/IBM/scc-go-sdk/v5 v5.4.1 h1:RXIuxOo9/hxkWyHCI69ae+KIJgSbXcAkJwTEl+fO3
github.com/IBM/scc-go-sdk/v5 v5.4.1/go.mod h1:2xQTDgNXG5QMEfQxBDKB067z+5ha6OgcaKCTcdGDAo8=
github.com/IBM/schematics-go-sdk v0.2.3 h1:lgTt0Sbudii3cuSk1YSQgrtiZAXDbBABAoVj3eQuBrU=
github.com/IBM/schematics-go-sdk v0.2.3/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.5 h1:VMc/Zd6RzB8j60CqZekkwYT2wQsCfrkGV2n01Gviuaw=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.5/go.mod h1:5kUgJ1dG9cdiAcPDqVz46m362bPnoqZQSth24NiowSg=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.6 h1:bF6bAdI4wDZSje6+Yx1mJxvirboxO+uMuKhzgfRCNxE=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.6/go.mod h1:XWYnbcc5vN1RnKwk/fCzfD8aZd7At/Y1/b6c+oDyliU=
github.com/IBM/vmware-go-sdk v0.1.2 h1:5lKWFyInWz9e2hwGsoFTEoLa1jYkD30SReN0fQ10w9M=
Expand Down
21 changes: 21 additions & 0 deletions ibm/service/power/data_source_ibm_pi_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ func DatasourceIBMPIWorkspace() *schema.Resource {
Description: "The Workspace crn.",
Type: schema.TypeString,
},
Attr_NetworkSecurityGroups: {
Computed: true,
Description: "Network security groups configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Attr_State: {
Computed: true,
Description: "The state of a Network Security Groups configuration.",
Type: schema.TypeString,
},
},
},
Type: schema.TypeList,
},
Attr_PowerEdgeRouter: {
Computed: true,
Elem: &schema.Resource{
Expand Down Expand Up @@ -132,6 +146,13 @@ func dataSourceIBMPIWorkspaceRead(ctx context.Context, d *schema.ResourceData, m
detailsData[Attr_PowerEdgeRouter] = []map[string]interface{}{wsPowerEdge}
wsDetails = append(wsDetails, detailsData)
}
if wsData.Details.NetworkSecurityGroups != nil {
wsNSG := map[string]interface{}{
Attr_State: *wsData.Details.NetworkSecurityGroups.State,
}
detailsData[Attr_NetworkSecurityGroups] = []map[string]interface{}{wsNSG}
wsDetails = append(wsDetails, detailsData)
}

d.Set(Attr_WorkspaceDetails, wsDetails)
wsLocation := map[string]interface{}{
Expand Down
21 changes: 21 additions & 0 deletions ibm/service/power/data_source_ibm_pi_workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ func DatasourceIBMPIWorkspaces() *schema.Resource {
Description: "The Workspace crn.",
Type: schema.TypeString,
},
Attr_NetworkSecurityGroups: {
Computed: true,
Description: "Network security groups configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Attr_State: {
Computed: true,
Description: "The state of a Network Security Groups configuration.",
Type: schema.TypeString,
},
},
},
Type: schema.TypeList,
},
Attr_PowerEdgeRouter: {
Computed: true,
Elem: &schema.Resource{
Expand Down Expand Up @@ -142,6 +156,13 @@ func dataSourceIBMPIWorkspacesRead(ctx context.Context, d *schema.ResourceData,
detailsData[Attr_PowerEdgeRouter] = []map[string]interface{}{wsPowerEdge}
wsDetails = append(wsDetails, detailsData)
}
if ws.Details.NetworkSecurityGroups != nil {
wsNSG := map[string]interface{}{
Attr_State: *ws.Details.NetworkSecurityGroups.State,
}
detailsData[Attr_NetworkSecurityGroups] = []map[string]interface{}{wsNSG}
wsDetails = append(wsDetails, detailsData)
}

workspace := map[string]interface{}{
Attr_WorkspaceCapabilities: ws.Capabilities,
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ const (
Attr_WorkspaceStatus = "pi_workspace_status"
Attr_WorkspaceType = "pi_workspace_type"
Attr_WWN = "wwn"
Attr_NetworkSecurityGroups = "network_security_groups"

// Duplicate Attributes, will be removed as refactoring take course.
PICloudConnectionClassicGreSource = "gre_source_address"
Expand Down
17 changes: 13 additions & 4 deletions website/docs/d/pi_workspace.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ description: |-
---

# ibm_pi_workspace

Retrieve information about your Power Systems account workspace.

## Example usage

```terraform
data "ibm_pi_workspace" "workspace" {
pi_cloud_instance_id = "99fba9c9-66f9-99bc-9999-aca999ee9d9b"
}
```

**Notes**
### Notes

- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints.
- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows:
- `region` - `lon`
- `zone` - `lon04`

Example usage:

```terraform
provider "ibm" {
region = "lon"
Expand All @@ -31,11 +35,13 @@ Example usage:
```

## Argument reference

Review the argument references that you can specify for your data source.

- `pi_cloud_instance_id` - (Required, String) Cloud Instance ID of a PCloud Instance under your account.

## Attribute reference

In addition to all argument reference listed, you can access the following attribute references after your data source is created.

- `id` - (String) Workspace ID.
Expand All @@ -49,12 +55,15 @@ In addition to all argument reference listed, you can access the following attri
Nested schema for `pi_workspace_details`:
- `creation_date` - (String) Date of workspace creation.
- `crn` - (String) Workspace crn.
- `network_security_groups` - (List) Network security groups configuration.
Nested schema for `network_security_groups`:
- `state` - (String) The state of a network security groups configuration.
- `power_edge_router` - (List) Power Edge Router information.

Nested schema for `power_edge_router`:
- `migration_status` - (String) The migration status of a Power Edge Router.
- `status` - (String) The state of a Power Edge Router.
- `type` - (String) The Power Edge Router type.
- `migration_status` - (String) The migration status of a Power Edge Router.
- `status` - (String) The state of a Power Edge Router.
- `type` - (String) The Power Edge Router type.
- `pi_workspace_location` - (Map) Workspace location.

Nested schema for `Workspace location`:
Expand Down
35 changes: 22 additions & 13 deletions website/docs/d/pi_workspaces.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ description: |-
---

# ibm_pi_workspaces

Retrieve information about Power Systems workspaces.

## Example usage

```terraform
data "ibm_pi_workspaces" "workspaces" {
pi_cloud_instance_id = "99fba9c9-66f9-99bc-9999-aca999ee9d9b"
}
```

**Notes**
### Notes

- Please find [supported Regions](https://cloud.ibm.com/apidocs/power-cloud#endpoint) for endpoints.
- If a Power cloud instance is provisioned at `lon04`, The provider level attributes should be as follows:
- `region` - `lon`
- `zone` - `lon04`

Example usage:

```terraform
provider "ibm" {
region = "lon"
Expand All @@ -31,38 +35,43 @@ Example usage:
```

## Argument reference

Review the argument references that you can specify for your data source.

- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account.

## Attribute reference

In addition to all argument reference listed, you can access the following attribute references after your data source is created.

- `workspaces` - (List) List of all Workspaces.
Nested schema for `workspaces`
- `pi_workspace_capabilities` - (Map) Workspace Capabilities. Capabilities are `true` or `false`.

Some of `pi_workspace_capabilities` are:
- `cloud-connections`, `power-edge-router`, `power-vpn-connections`, `transit-gateway-connection`
- `cloud-connections`, `power-edge-router`, `power-vpn-connections`, `transit-gateway-connection`

- `pi_workspace_details` - (List) Workspace information.

Nested schema for `pi_workspace_details`:
- `creation_date` - (String) Date of workspace creation.
- `crn` - (String) Workspace crn.
- `power_edge_router` - (List) Power Edge Router information.

Nested schema for `power_edge_router`:
- `migration_status` - (String) The migration status of a Power Edge Router.
- `status` - (String) The state of a Power Edge Router.
- `type` - (String) The Power Edge Router type.
- `creation_date` - (String) Date of workspace creation.
- `crn` - (String) Workspace crn.
- `network_security_groups` - (List) Network security groups configuration.
Nested schema for `network_security_groups`:
- `state` - (String) The state of a network security groups configuration.
- `power_edge_router` - (List) Power Edge Router information.

Nested schema for `power_edge_router`:
- `migration_status` - (String) The migration status of a Power Edge Router.
- `status` - (String) The state of a Power Edge Router.
- `type` - (String) The Power Edge Router type.
- `pi_workspace_id` - (String) Workspace ID.
- `pi_workspace_location` - (Map) Workspace location.

Nested schema for `Workspace location`:
- `region` - (String) Workspace location region zone.
- `type` - (String) Workspace location region type.
- `url`- (String) Workspace location region url.
- `region` - (String) Workspace location region zone.
- `type` - (String) Workspace location region type.
- `url`- (String) Workspace location region url.
- `pi_workspace_name` - (String) Workspace name.
- `pi_workspace_status` - (String) Workspace status, `active`, `critical`, `failed`, `provisioning`.
- `pi_workspace_type` - (String) Workspace type, `off-premises` or `on-premises`.

0 comments on commit 82aad7a

Please sign in to comment.