Skip to content
Open
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
3 changes: 3 additions & 0 deletions docs/resources/objectstorage_bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ page_title: "stackit_objectstorage_bucket Resource - stackit"
subcategory: ""
description: |-
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.
~> This resource cannot be destroyed if the bucket contains objects. Please ensure the bucket is empty before attempting to destroy it.
---

# stackit_objectstorage_bucket (Resource)

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.

~> This resource cannot be destroyed if the bucket contains objects. Please ensure the bucket is empty before attempting to destroy it.

## Example Usage

```terraform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ type bucketResource struct {
// ModifyPlan implements resource.ResourceWithModifyPlan.
// Use the modifier to set the effective region in the current plan.
func (r *bucketResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { // nolint:gocritic // function signature required by Terraform
// Note: This resource cannot be destroyed if the bucket contains objects. We added a check here to inform the user about this before accepting the deletion.
if req.Plan.Raw.IsNull() && !req.State.Raw.IsNull() {
core.LogAndAddWarning(ctx, &resp.Diagnostics, "stackit_object_storage", "Note: This resource cannot be destroyed if the bucket contains objects. Please ensure the bucket is empty before attempting to destroy it.")
return
}

var configModel Model
// skip initial empty configuration to avoid follow-up errors
if req.Config.Raw.IsNull() {
Expand Down Expand Up @@ -113,7 +119,8 @@ func (r *bucketResource) Configure(ctx context.Context, req resource.ConfigureRe
// Schema defines the schema for the resource.
func (r *bucketResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
descriptions := map[string]string{
"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.",
"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.\n\n" +
"~> This resource cannot be destroyed if the bucket contains objects. Please ensure the bucket is empty before attempting to destroy it.",
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`region`,`name`\".",
"name": "The bucket name. It must be DNS conform.",
"project_id": "STACKIT Project ID to which the bucket is associated.",
Expand Down
Loading