Skip to content

Commit

Permalink
Merge pull request #38811 from hashicorp/f/datazone-environment
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonaj authored Aug 30, 2024
2 parents d1934f9 + 5a0cf7f commit 1d9b515
Show file tree
Hide file tree
Showing 10 changed files with 1,080 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changelog/38811.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_datazone_domain: Add `skip_deletion_protection` attribute
```

```release-note:new-resource
aws_datazone_environment
```
24 changes: 24 additions & 0 deletions internal/service/datazone/datazone_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package datazone_test

import (
"testing"

"github.com/hashicorp/terraform-provider-aws/internal/acctest"
)

func TestAccDataZone_serial(t *testing.T) {
t.Parallel()

testCases := map[string]map[string]func(t *testing.T){
"Environment": {
acctest.CtBasic: testAccEnvironment_basic,
acctest.CtDisappears: testAccEnvironment_disappears,
"update": testAccEnvironment_update,
},
}

acctest.RunSerialTests2Levels(t, testCases, 0)
}
12 changes: 12 additions & 0 deletions internal/service/datazone/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
Expand Down Expand Up @@ -90,6 +91,12 @@ func (r *resourceDomain) Schema(ctx context.Context, req resource.SchemaRequest,
stringplanmodifier.UseStateForUnknown(),
},
},
"skip_deletion_check": schema.BoolAttribute{
Optional: true,
PlanModifiers: []planmodifier.Bool{
boolplanmodifier.UseStateForUnknown(),
},
},
names.AttrTags: tftags.TagsAttribute(),
names.AttrTagsAll: tftags.TagsAttributeComputedOnly(),
},
Expand Down Expand Up @@ -326,6 +333,10 @@ func (r *resourceDomain) Delete(ctx context.Context, req resource.DeleteRequest,
Identifier: aws.String(state.ID.ValueString()),
}

if !state.SkipDeletionCheck.IsNull() {
in.SkipDeletionCheck = state.SkipDeletionCheck.ValueBoolPointer()
}

_, err := conn.DeleteDomain(ctx, in)
if err != nil {
if isResourceMissing(err) {
Expand Down Expand Up @@ -477,6 +488,7 @@ type domainResourceModel struct {
KmsKeyIdentifier fwtypes.ARN `tfsdk:"kms_key_identifier"`
Name types.String `tfsdk:"name"`
PortalUrl types.String `tfsdk:"portal_url"`
SkipDeletionCheck types.Bool `tfsdk:"skip_deletion_check"`
SingleSignOn types.List `tfsdk:"single_sign_on"`
Tags types.Map `tfsdk:"tags"`
TagsAll types.Map `tfsdk:"tags_all"`
Expand Down
8 changes: 4 additions & 4 deletions internal/service/datazone/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestAccDataZoneDomain_basic(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{names.AttrApplyImmediately, "user"},
ImportStateVerifyIgnore: []string{names.AttrApplyImmediately, "user", "skip_deletion_check"},
},
},
})
Expand Down Expand Up @@ -113,7 +113,7 @@ func TestAccDataZoneDomain_kms_key_identifier(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{names.AttrApplyImmediately, "user"},
ImportStateVerifyIgnore: []string{names.AttrApplyImmediately, "user", "skip_deletion_check"},
},
},
})
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestAccDataZoneDomain_description(t *testing.T) {
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{names.AttrApplyImmediately, "user"},
ImportStateVerifyIgnore: []string{names.AttrApplyImmediately, "user", "skip_deletion_check"},
},
},
})
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestAccDataZoneDomain_single_sign_on(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
// we do not set single_sign_on if it's the default value
ImportStateVerifyIgnore: []string{"single_sign_on"},
ImportStateVerifyIgnore: []string{"single_sign_on", "skip_deletion_check"},
},
},
})
Expand Down
Loading

0 comments on commit 1d9b515

Please sign in to comment.