Skip to content

Commit 506d1af

Browse files
Fix error handling on object storage service enablement (#165)
* Fix error handling on objecto storage service enablement * Add message about depends_on * Update docs
1 parent 35275fd commit 506d1af

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

docs/resources/objectstorage_bucket.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "stackit_objectstorage_bucket Resource - stackit"
44
subcategory: ""
55
description: |-
6-
ObjectStorage bucket resource schema. Must have a region specified in the provider configuration.
6+
ObjectStorage bucket resource schema. Must have a region specified in the provider configuration. If you are creating credentialsgroup and bucket resources simultaneously, please include the depends_on field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.
77
---
88

99
# stackit_objectstorage_bucket (Resource)
1010

11-
ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration.
11+
ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.
1212

1313
## Example Usage
1414

docs/resources/objectstorage_credentials_group.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "stackit_objectstorage_credentials_group Resource - stackit"
44
subcategory: ""
55
description: |-
6-
ObjectStorage credentials group resource schema. Must have a region specified in the provider configuration.
6+
ObjectStorage credentials group resource schema. Must have a region specified in the provider configuration. If you are creating credentialsgroup and bucket resources simultaneously, please include the depends_on field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.
77
---
88

99
# stackit_objectstorage_credentials_group (Resource)
1010

11-
ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration.
11+
ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.
1212

1313
## Example Usage
1414

stackit/internal/services/objectstorage/bucket/resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (r *bucketResource) Configure(ctx context.Context, req resource.ConfigureRe
9090
// Schema defines the schema for the resource.
9191
func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
9292
descriptions := map[string]string{
93-
"main": "ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration.",
93+
"main": "ObjectStorage bucket resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.",
9494
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`name`\".",
9595
"name": "The bucket name. It must be DNS conform.",
9696
"project_id": "STACKIT Project ID to which the bucket is associated.",
@@ -156,7 +156,7 @@ func (r *bucketResource) Create(ctx context.Context, req resource.CreateRequest,
156156

157157
// Handle project init
158158
err := enableProject(ctx, &model, r.client)
159-
if resp.Diagnostics.HasError() {
159+
if err != nil {
160160
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating bucket", fmt.Sprintf("Enabling object storage project before creation: %v", err))
161161
return
162162
}

stackit/internal/services/objectstorage/credential/resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
186186

187187
// Handle project init
188188
err := enableProject(ctx, &model, r.client)
189-
if resp.Diagnostics.HasError() {
189+
if err != nil {
190190
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Enabling object storage project before creation: %v", err))
191191
return
192192
}

stackit/internal/services/objectstorage/credentialsgroup/resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (r *credentialsGroupResource) Configure(ctx context.Context, req resource.C
9090
// Schema defines the schema for the resource.
9191
func (r *credentialsGroupResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
9292
descriptions := map[string]string{
93-
"main": "ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration.",
93+
"main": "ObjectStorage credentials group resource schema. Must have a `region` specified in the provider configuration. If you are creating `credentialsgroup` and `bucket` resources simultaneously, please include the `depends_on` field so that they are created sequentially. This prevents errors from concurrent calls to the service enablement that is done in the background.",
9494
"id": "Terraform's internal data source identifier. It is structured as \"`project_id`,`credentials_group_id`\".",
9595
"credentials_group_id": "The credentials group ID",
9696
"name": "The credentials group's display name.",
@@ -159,7 +159,7 @@ func (r *credentialsGroupResource) Create(ctx context.Context, req resource.Crea
159159

160160
// Handle project init
161161
err := enableProject(ctx, &model, r.client)
162-
if resp.Diagnostics.HasError() {
162+
if err != nil {
163163
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credentials group", fmt.Sprintf("Enabling object storage project before creation: %v", err))
164164
return
165165
}

0 commit comments

Comments
 (0)