Skip to content

Commit

Permalink
Fixed the computed block issue
Browse files Browse the repository at this point in the history
  • Loading branch information
markoskandylis committed Dec 4, 2023
1 parent ae47528 commit 276b23f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
23 changes: 12 additions & 11 deletions internal/service/securitylake/data_lake.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ 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/listplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down Expand Up @@ -85,19 +85,20 @@ func (r *resourceDataLake) Schema(ctx context.Context, req resource.SchemaReques
"region": schema.StringAttribute{
Required: true,
},
},
Blocks: map[string]schema.Block{
"encryption_configuration": schema.ListNestedBlock{
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"kms_key_id": schema.StringAttribute{
Optional: true,
Computed: true,
Default: stringdefault.StaticString("S3_MANAGED_KEY"),
},
"encryption_configuration": schema.ListAttribute{
Computed: true,
Optional: true,
ElementType: types.ObjectType{
AttrTypes: map[string]attr.Type{
"kms_key_id": types.StringType,
},
},
PlanModifiers: []planmodifier.List{
listplanmodifier.UseStateForUnknown(),
},
},
},
Blocks: map[string]schema.Block{
"lifecycle_configuration": schema.ListNestedBlock{
Validators: []validator.List{
listvalidator.SizeAtMost(1),
Expand Down
28 changes: 24 additions & 4 deletions internal/service/securitylake/data_lake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ func testAccDataLakeConfigBaseConfig(rName string) string {
return fmt.Sprintf(`
data "aws_caller_identity" "current" {}
resource "aws_iam_role" "meta_store_manager" {
Expand Down Expand Up @@ -467,6 +469,28 @@ resource "aws_iam_role_policy" "datalake_s3_replication" {
}
EOF
}
resource "aws_kms_key" "test" {
description = %[1]q
policy = jsonencode({
Version = "2012-10-17"
Id = %[1]q
Statement = [{
Sid = "Enable IAM User Permissions"
Effect = "Allow"
Action = "kms:*"
Resource = "*"
Principal = {
AWS = "*"
}
}]
})
}
`, rName)
}

Expand All @@ -479,10 +503,6 @@ resource "aws_securitylake_data_lake" "test" {
configurations {
region = "eu-west-1"
encryption_configuration {
kms_key_id = "S3_MANAGED_KEY"
}
}
tags = {
Name = %[1]q
Expand Down

0 comments on commit 276b23f

Please sign in to comment.