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

F securitylake data lake #34521

Merged
merged 50 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
74c398f
Initial code
markoskandylis Nov 19, 2023
7167eb4
Successfull Creation part
markoskandylis Nov 22, 2023
d59ad48
Successfull Creation part
markoskandylis Nov 22, 2023
094c0b6
Succesfull first test
markoskandylis Nov 26, 2023
de2a763
Merge remote-tracking branch 'origin' into f-securitylake-data-lake
markoskandylis Nov 26, 2023
8b100b9
Added tags and disapear tests
markoskandylis Nov 26, 2023
70f107c
Removed iam
markoskandylis Nov 28, 2023
aba841e
Merge branch 'hashicorp:main' into f-securitylake-data-lake
markoskandylis Nov 28, 2023
d68af9e
All tests that include the encryption run succesffuly
markoskandylis Nov 30, 2023
2b36a07
Added Document and changelog
markoskandylis Nov 30, 2023
13a160a
Fixed the document errors
markoskandylis Nov 30, 2023
ae47528
Minor fixes
markoskandylis Nov 30, 2023
f154da1
Merge branch 'main' into HEAD
ewbankkit Dec 1, 2023
fadedce
r/aws_securitylake_data_lake: Transparent tagging.
ewbankkit Dec 1, 2023
a54f342
r/aws_securitylake_data_lake: 'configurations' -> 'configuration' and…
ewbankkit Dec 1, 2023
8928b5d
r/aws_securitylake_data_lake: Start to think about AutoFlEx.
ewbankkit Dec 1, 2023
c987f4f
r/aws_securitylake_data_lake: Add 'findDataLakes' and friends.
ewbankkit Dec 1, 2023
20dacb9
r/aws_securitylake_data_lake: Tidy up Delete.
ewbankkit Dec 1, 2023
57ab21b
r/aws_securitylake_data_lake: Use AutoFlEx for Create, Read and Update.
ewbankkit Dec 1, 2023
3540427
r/aws_securitylake_data_lake: Tidy up acceptance tests.
ewbankkit Dec 1, 2023
e2796ed
r/aws_securitylake_data_lake: AutoFlEx fixes.
ewbankkit Dec 1, 2023
276b23f
Fixed the computed block issue
markoskandylis Dec 4, 2023
9984e3d
Fixed the last errors
markoskandylis Dec 5, 2023
9560d75
Fixed the formating error
markoskandylis Dec 5, 2023
ec0eb66
Tweak comments.
ewbankkit Dec 5, 2023
f4e22aa
Add 'flex.SetValueOf' etc.
ewbankkit Dec 5, 2023
0100044
Add 'flex.SetOfStringType'.
ewbankkit Dec 5, 2023
b975bd7
Add 'TestSetOfStringFromTerraform'.
ewbankkit Dec 5, 2023
03a96b9
Handle empty ID in 'ProblemStandardMessage'.
ewbankkit Dec 5, 2023
439fe34
r/aws_securitylake_data_lake: Use 'SetOf' for 'replication_configurat…
ewbankkit Dec 5, 2023
d5881f0
r/aws_securitylake_data_lake: Correct 'waitDataLakeDeleted'.
ewbankkit Dec 6, 2023
bfd0e28
r/aws_securitylake_data_lake: Tidy up acceptance tests.
ewbankkit Dec 6, 2023
3b0136a
Add 'TestAccSecurityLakeDataLake_tags'.
ewbankkit Dec 6, 2023
148a44f
securitylake: Serialize acceptance tests.
ewbankkit Dec 6, 2023
881a173
r/aws_securitylake_data_lake: Fix Read.
ewbankkit Dec 6, 2023
7f0fed3
r/aws_securitylake_data_lake: Ensure standalone (non-Org) account for…
ewbankkit Dec 6, 2023
3d01573
Add 'names.SecurityLakeEndpointID'.
ewbankkit Dec 6, 2023
14c7954
r/aws_securitylake_data_lake: Add 's3_bucket_arn' attribute.
ewbankkit Dec 6, 2023
dd040ce
Fix 'testAccDataLake_replication'.
ewbankkit Dec 6, 2023
a21ecaf
r/aws_securitylake_data_lake: Handle tag retrieval for resource's 're…
ewbankkit Dec 6, 2023
8136b7c
Merge branch 'main' into HEAD
ewbankkit Dec 6, 2023
5db9232
Merge commit 'a21ecaf37d3785f837e261b2e7dc53396568c9d6' into HEAD
ewbankkit Dec 6, 2023
14c5da5
Merge 276b23fccffa323035d4c9b040d86147e0806ea5, 9984e3d93343e1cd902c3…
ewbankkit Dec 6, 2023
b177df3
Run 'go generate ./internal/service/securitylake'.
ewbankkit Dec 6, 2023
93f7700
r/aws_securitylake_data_lake: Pass Region to 'listTags'.
ewbankkit Dec 6, 2023
854a5e0
Fix 'testAccDataLake_basic'.
ewbankkit Dec 6, 2023
7b24991
r/aws_securitylake_data_lake: encryption_configuration is a nested at…
ewbankkit Dec 6, 2023
dc7a242
Fix 'testAccDataLake_replication'.
ewbankkit Dec 6, 2023
d362d4b
Fix typo in acceptance test checks.
ewbankkit Dec 7, 2023
69a092d
Correct CHANGELOG entry file name.
ewbankkit Dec 7, 2023
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 .changelog/29376.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
resource/aws_securitylake_data_lake
```
6 changes: 6 additions & 0 deletions internal/create/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ func ProblemStandardMessage(service, action, resource, id string, gotError error
}

if gotError == nil {
if id == "" {
return fmt.Sprintf("%s %s %s", action, hf, resource)
}
return fmt.Sprintf("%s %s %s (%s)", action, hf, resource, id)
}

if id == "" {
return fmt.Sprintf("%s %s %s: %s", action, hf, resource, gotError)
}
return fmt.Sprintf("%s %s %s (%s): %s", action, hf, resource, id, gotError)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/framework/types/list_nested_objectof.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func nestedObjectTypeNewObjectSlice[T any](_ context.Context, len, cap int) ([]*
return make([]*T, len, cap), diags
}

// ListNestedObjectValueOf represents a Terraform Plugin Framework List value whose elements are of type ObjectTypeOf.
// ListNestedObjectValueOf represents a Terraform Plugin Framework List value whose elements are of type `ObjectTypeOf[T]`.
type ListNestedObjectValueOf[T any] struct {
basetypes.ListValue
}
Expand Down
2 changes: 1 addition & 1 deletion internal/framework/types/set_nested_objectof.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (t setNestedObjectTypeOf[T]) ValueFromObjectSlice(ctx context.Context, slic
return nil, diags
}

// SetNestedObjectValueOf represents a Terraform Plugin Framework Set value whose elements are of type ObjectTypeOf.
// SetNestedObjectValueOf represents a Terraform Plugin Framework Set value whose elements are of type `ObjectTypeOf[T]`.
type SetNestedObjectValueOf[T any] struct {
basetypes.SetValue
}
Expand Down
142 changes: 142 additions & 0 deletions internal/framework/types/setof.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-provider-aws/internal/errs/fwdiag"
)

// setTypeOf is the attribute type of a SetValueOf.
type setTypeOf[T attr.Value] struct {
basetypes.SetType
}

var (
SetOfStringType = setTypeOf[basetypes.StringValue]{basetypes.SetType{ElemType: basetypes.StringType{}}}
)

var (
_ basetypes.SetTypable = (*setTypeOf[basetypes.StringValue])(nil)
_ basetypes.SetValuable = (*SetValueOf[basetypes.StringValue])(nil)
)

func newAttrTypeOf[T attr.Value](ctx context.Context) attr.Type {
var zero T
return zero.Type(ctx)
}

func NewSetTypeOf[T attr.Value](ctx context.Context) setTypeOf[T] {
return setTypeOf[T]{basetypes.SetType{ElemType: newAttrTypeOf[T](ctx)}}
}

func (t setTypeOf[T]) Equal(o attr.Type) bool {
other, ok := o.(setTypeOf[T])

if !ok {
return false
}

return t.SetType.Equal(other.SetType)
}

func (t setTypeOf[T]) String() string {
var zero T
return fmt.Sprintf("SetTypeOf[%T]", zero)
}

func (t setTypeOf[T]) ValueFromSet(ctx context.Context, in basetypes.SetValue) (basetypes.SetValuable, diag.Diagnostics) {
var diags diag.Diagnostics

if in.IsNull() {
return NewSetValueOfNull[T](ctx), diags
}
if in.IsUnknown() {
return NewSetValueOfUnknown[T](ctx), diags
}

setValue, d := basetypes.NewSetValue(newAttrTypeOf[T](ctx), in.Elements())
diags.Append(d...)
if diags.HasError() {
return NewSetValueOfUnknown[T](ctx), diags
}

value := SetValueOf[T]{
SetValue: setValue,
}

return value, diags
}

func (t setTypeOf[T]) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error) {
attrValue, err := t.SetType.ValueFromTerraform(ctx, in)

if err != nil {
return nil, err
}

setValue, ok := attrValue.(basetypes.SetValue)

if !ok {
return nil, fmt.Errorf("unexpected value type of %T", attrValue)
}

setValuable, diags := t.ValueFromSet(ctx, setValue)

if diags.HasError() {
return nil, fmt.Errorf("unexpected error converting SetValue to SetValuable: %v", diags)
}

return setValuable, nil
}

func (t setTypeOf[T]) ValueType(ctx context.Context) attr.Value {
return SetValueOf[T]{}
}

// SetValueOf represents a Terraform Plugin Framework Set value whose elements are of type `T`.
type SetValueOf[T attr.Value] struct {
basetypes.SetValue
}

func (v SetValueOf[T]) Equal(o attr.Value) bool {
other, ok := o.(SetValueOf[T])

if !ok {
return false
}

return v.SetValue.Equal(other.SetValue)
}

func (v SetValueOf[T]) Type(ctx context.Context) attr.Type {
return NewSetTypeOf[T](ctx)
}

func NewSetValueOfNull[T attr.Value](ctx context.Context) SetValueOf[T] {
return SetValueOf[T]{SetValue: basetypes.NewSetNull(newAttrTypeOf[T](ctx))}
}

func NewSetValueOfUnknown[T attr.Value](ctx context.Context) SetValueOf[T] {
return SetValueOf[T]{SetValue: basetypes.NewSetUnknown(newAttrTypeOf[T](ctx))}
}

func NewSetValueOf[T attr.Value](ctx context.Context, elements []attr.Value) (SetValueOf[T], diag.Diagnostics) {
v, diags := basetypes.NewSetValue(newAttrTypeOf[T](ctx), elements)
if diags.HasError() {
return NewSetValueOfUnknown[T](ctx), diags
}

return SetValueOf[T]{SetValue: v}, diags
}

func NewSetValueOfMust[T attr.Value](ctx context.Context, elements []attr.Value) SetValueOf[T] {
return fwdiag.Must(NewSetValueOf[T](ctx, elements))
}
57 changes: 57 additions & 0 deletions internal/framework/types/setof_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package types_test

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-go/tftypes"
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
)

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

ctx := context.Background()
tests := map[string]struct {
val tftypes.Value
expected attr.Value
}{
"values": {
val: tftypes.NewValue(tftypes.Set{
ElementType: tftypes.String,
}, []tftypes.Value{
tftypes.NewValue(tftypes.String, "red"),
tftypes.NewValue(tftypes.String, "blue"),
tftypes.NewValue(tftypes.String, "green"),
}),
expected: fwtypes.NewSetValueOfMust[types.String](ctx, []attr.Value{
types.StringValue("red"),
types.StringValue("blue"),
types.StringValue("green"),
}),
},
}

for name, test := range tests {
name, test := name, test
t.Run(name, func(t *testing.T) {
t.Parallel()

val, err := fwtypes.SetOfStringType.ValueFromTerraform(ctx, test.val)

if err != nil {
t.Fatalf("got unexpected error: %s", err)
}

if diff := cmp.Diff(val, test.expected); diff != "" {
t.Errorf("unexpected diff (+wanted, -got): %s", diff)
}
})
}
}
Loading