Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable timeouts for environment instance and service instance #401

Merged
merged 9 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/resources/subaccount_environment_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
instance_name = "my-cf-org-name"
})
}


# creates a cloud foundry environment in a given account
# in additon add a custom timeout for the create and delete operation
resource "btp_subaccount_environment_instance" "cloudfoundry" {
subaccount_id = "6aa64c2f-38c1-49a9-b2e8-cf9fea769b7f"
name = "my-cf-environment"
environment_type = "cloudfoundry"
service_name = "cloudfoundry"
plan_name = "standard"
# some regions offer multiple environments of a kind and you must explicitly select the target environment in which
# the instance shall be created.
# available environments can be looked up using the btp_subaccount_environments datasource
parameters = jsonencode({
instance_name = "my-cf-org-name"
})
timeouts = {
create = "1h"
update = "35m"
delete = "30m"
}
}
```

<!-- schema generated by tfplugindocs -->
Expand All @@ -60,6 +82,7 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
### Optional

- `landscape_label` (String) The name of the landscape within the logged in region on which the environment instance is created.
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

Expand Down Expand Up @@ -95,6 +118,15 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
| `Update` | The environment instance is changed. |
| `Deprovision` | The environment instance is deleted. |

<a id="nestedatt--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String) Timeout for creating the environment instance.
- `delete` (String) Timeout for deleting the environment instance.
- `update` (String) Timeout for updating the environment instance.

## Import

Import is supported using the following syntax:
Expand Down
24 changes: 24 additions & 0 deletions docs/resources/subaccount_service_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ resource "btp_subaccount_service_instance" "xsuaa_application" {
tenant-mode = "dedicated"
})
}

# create an instance of the alert-notification service (no configuration necessary)
# in additon add a custom timeout for the create and update operation
resource "btp_subaccount_service_instance" "alert_notification_free" {
subaccount_id = "6aa64c2f-38c1-49a9-b2e8-cf9fea769b7f"
# The service plan ID can be looked up via the data source btp_subaccount_service_plan
serviceplan_id = "b50d1b0b-2059-4f21-a014-2ea87752eb48" # alert-notification - free
name = "my-alert-notification-instance-new"
timeouts = {
create = "25m"
update = "15m"
delete = "15m"
}
}
```

<!-- schema generated by tfplugindocs -->
Expand All @@ -46,6 +60,7 @@ resource "btp_subaccount_service_instance" "xsuaa_application" {

- `labels` (Map of Set of String) The set of words or phrases assigned to the service instance.
- `parameters` (String, Sensitive) The configuration parameters for the service instance.
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

Expand All @@ -60,6 +75,15 @@ resource "btp_subaccount_service_instance" "xsuaa_application" {
- `state` (String) The current state of the service instance.
- `usable` (Boolean) Shows whether the resource can be used.

<a id="nestedatt--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String) Timeout for creating the service instance.
- `delete` (String) Timeout for deleting the service instance.
- `update` (String) Timeout for updating the service instance.

## Import

Import is supported using the following syntax:
Expand Down
22 changes: 22 additions & 0 deletions examples/resources/btp_subaccount_environment_instance/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,25 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
instance_name = "my-cf-org-name"
})
}


# creates a cloud foundry environment in a given account
# in additon add a custom timeout for the create and delete operation
resource "btp_subaccount_environment_instance" "cloudfoundry" {
subaccount_id = "6aa64c2f-38c1-49a9-b2e8-cf9fea769b7f"
name = "my-cf-environment"
environment_type = "cloudfoundry"
service_name = "cloudfoundry"
plan_name = "standard"
# some regions offer multiple environments of a kind and you must explicitly select the target environment in which
# the instance shall be created.
# available environments can be looked up using the btp_subaccount_environments datasource
parameters = jsonencode({
instance_name = "my-cf-org-name"
})
timeouts = {
create = "1h"
update = "35m"
delete = "30m"
}
}
14 changes: 14 additions & 0 deletions examples/resources/btp_subaccount_service_instance/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,17 @@ resource "btp_subaccount_service_instance" "xsuaa_application" {
tenant-mode = "dedicated"
})
}

# create an instance of the alert-notification service (no configuration necessary)
# in additon add a custom timeout for the create and update operation
resource "btp_subaccount_service_instance" "alert_notification_free" {
subaccount_id = "6aa64c2f-38c1-49a9-b2e8-cf9fea769b7f"
# The service plan ID can be looked up via the data source btp_subaccount_service_plan
serviceplan_id = "b50d1b0b-2059-4f21-a014-2ea87752eb48" # alert-notification - free
name = "my-alert-notification-instance-new"
timeouts = {
create = "25m"
update = "15m"
delete = "15m"
}
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
require (
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/terraform-plugin-framework v1.3.5
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1
github.com/hashicorp/terraform-plugin-framework-validators v0.11.0
github.com/hashicorp/terraform-plugin-go v0.18.0
github.com/hashicorp/terraform-plugin-testing v1.4.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQH
github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o=
github.com/hashicorp/terraform-plugin-framework v1.3.5 h1:FJ6s3CVWVAxlhiF/jhy6hzs4AnPHiflsp9KgzTGl1wo=
github.com/hashicorp/terraform-plugin-framework v1.3.5/go.mod h1:2gGDpWiTI0irr9NSTLFAKlTi6KwGti3AoU19rFqU30o=
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 h1:gm5b1kHgFFhaKFhm4h2TgvMUlNzFAtUqlcOWnWPm+9E=
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1/go.mod h1:MsjL1sQ9L7wGwzJ5RjcI6FzEMdyoBnw+XK8ZnOvQOLY=
github.com/hashicorp/terraform-plugin-framework-validators v0.11.0 h1:DKb1bX7/EPZUTW6F5zdwJzS/EZ/ycVD6JAW5RYOj4f8=
github.com/hashicorp/terraform-plugin-framework-validators v0.11.0/go.mod h1:dzxOiHh7O9CAwc6p8N4mR1H++LtRkl+u+21YNiBVNno=
github.com/hashicorp/terraform-plugin-go v0.18.0 h1:IwTkOS9cOW1ehLd/rG0y+u/TGLK9y6fGoBjXVUquzpE=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ You must be assigned to the subaccount admin or viewer role.`,
}

func (ds *subaccountEnvironmentInstanceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var data subaccountEnvironmentInstanceType
var data subaccountEnvironmentInstanceDataSourceType

diags := req.Config.Get(ctx, &data)

Expand All @@ -170,7 +170,7 @@ func (ds *subaccountEnvironmentInstanceDataSource) Read(ctx context.Context, req
return
}

data, diags = subaccountEnvironmentInstanceValueFrom(ctx, cliRes)
data, diags = subaccountEnvironmentInstanceDataSourceValueFrom(ctx, cliRes)
resp.Diagnostics.Append(diags...)

diags = resp.State.Set(ctx, &data)
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/datasource_subaccount_service_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (ds *subaccountServiceInstanceDataSource) Schema(_ context.Context, _ datas
}

func (ds *subaccountServiceInstanceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var data subaccountServiceInstanceType
var data subaccountServiceInstanceDataSourceType

diags := req.Config.Get(ctx, &data)

Expand All @@ -146,7 +146,7 @@ func (ds *subaccountServiceInstanceDataSource) Read(ctx context.Context, req dat
return
}

data, diags = subaccountServiceInstanceValueFrom(ctx, cliRes)
data, diags = subaccountServiceInstanceDataSourceValueFrom(ctx, cliRes)
resp.Diagnostics.Append(diags...)

data.Parameters = types.StringNull() // TODO can be set once --show-parameters is works
Expand Down
Loading
Loading