Skip to content

Commit

Permalink
Merge pull request hashicorp#35168 from ddericco/f-aws_networkfirewal…
Browse files Browse the repository at this point in the history
…l_tls_inspection_configuration-v2

Add aws_networkfirewall_tls_inspection_configuration
  • Loading branch information
ewbankkit authored Jun 21, 2024
2 parents 651c941 + e4cb764 commit b3e6927
Show file tree
Hide file tree
Showing 42 changed files with 5,422 additions and 2,475 deletions.
7 changes: 7 additions & 0 deletions .changelog/35168.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:new-resource
aws_networkfirewall_tls_inspection_configuration
```

```release-note:enhancement
resource/aws_networkfirewall_logging_configuration: Add plan-time validation of `firewall_arn`
```
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/mq v1.23.1
github.com/aws/aws-sdk-go-v2/service/mwaa v1.28.1
github.com/aws/aws-sdk-go-v2/service/neptunegraph v1.9.1
github.com/aws/aws-sdk-go-v2/service/networkfirewall v1.39.1
github.com/aws/aws-sdk-go-v2/service/oam v1.12.1
github.com/aws/aws-sdk-go-v2/service/opensearchserverless v1.12.1
github.com/aws/aws-sdk-go-v2/service/organizations v1.28.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ github.com/aws/aws-sdk-go-v2/service/mwaa v1.28.1 h1:fzBc0gfOfrlcyP/COVDt8iGVUnQ
github.com/aws/aws-sdk-go-v2/service/mwaa v1.28.1/go.mod h1:a46hMp6jog7U6rhMxmp0wwcGvPTJINQkc6EevZb7SNs=
github.com/aws/aws-sdk-go-v2/service/neptunegraph v1.9.1 h1:UjByGYRBlhjY4l8Lun62K3Z62Wks84q3UasnDDJoz5I=
github.com/aws/aws-sdk-go-v2/service/neptunegraph v1.9.1/go.mod h1:5q3YTQennpO1/KB7rU71vW/9PjLC4PuosEi2xDEw5OY=
github.com/aws/aws-sdk-go-v2/service/networkfirewall v1.39.1 h1:f2TcduRAvOs8ltPaAnjSP64WHRmM/B5bsDSqXRYBYGs=
github.com/aws/aws-sdk-go-v2/service/networkfirewall v1.39.1/go.mod h1:23qyfghRkv9qOMRIL9KdUHiKyhARU/0FddRMtvMSVV0=
github.com/aws/aws-sdk-go-v2/service/oam v1.12.1 h1:LZrULRkfrmZVE8OHqwI8tKFEFxpjZl6ll7Bn2MCCVwg=
github.com/aws/aws-sdk-go-v2/service/oam v1.12.1/go.mod h1:yiUaEYA1zVxtz/EGgf8NE7rT56sLKGqQwQrWg/GhGu8=
github.com/aws/aws-sdk-go-v2/service/opensearchserverless v1.12.1 h1:BRAM7tTwHJojSOhiyUkPh2Z/hOco7OkayTf6MYFOF5w=
Expand Down
6 changes: 3 additions & 3 deletions internal/conns/awsclient_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 77 additions & 58 deletions internal/framework/flex/auto_expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,12 @@ func (expander autoExpander) list(ctx context.Context, vFrom basetypes.ListValua
}

switch v.ElementType(ctx).(type) {
case basetypes.Int64Typable:
diags.Append(expander.listOrSetOfInt64(ctx, v, vTo)...)
return diags

case basetypes.StringTypable:
diags.Append(expander.listOfString(ctx, v, vTo)...)
diags.Append(expander.listOrSetOfString(ctx, v, vTo)...)
return diags

case basetypes.ObjectTypable:
Expand All @@ -398,8 +402,71 @@ func (expander autoExpander) list(ctx context.Context, vFrom basetypes.ListValua
return diags
}

// listOfString copies a Plugin Framework ListOfString(ish) value to a compatible AWS API value.
func (expander autoExpander) listOfString(ctx context.Context, vFrom basetypes.ListValue, vTo reflect.Value) diag.Diagnostics {
// listOrSetOfInt64 copies a Plugin Framework ListOfInt64(ish) or SetOfInt64(ish) value to a compatible AWS API value.
func (expander autoExpander) listOrSetOfInt64(ctx context.Context, vFrom valueWithElementsAs, vTo reflect.Value) diag.Diagnostics {
var diags diag.Diagnostics

switch vTo.Kind() {
case reflect.Slice:
switch tSliceElem := vTo.Type().Elem(); tSliceElem.Kind() {
case reflect.Int32, reflect.Int64:
//
// types.List(OfInt64) -> []int64 or []int32
//
var to []int64
diags.Append(vFrom.ElementsAs(ctx, &to, false)...)
if diags.HasError() {
return diags
}

vals := reflect.MakeSlice(vTo.Type(), len(to), len(to))
for i := 0; i < len(to); i++ {
vals.Index(i).SetInt(to[i])
}
vTo.Set(vals)
return diags

case reflect.Ptr:
switch tSliceElem.Elem().Kind() {
case reflect.Int32:
//
// types.List(OfInt64) -> []*int32.
//
var to []*int32
diags.Append(vFrom.ElementsAs(ctx, &to, false)...)
if diags.HasError() {
return diags
}

vTo.Set(reflect.ValueOf(to))
return diags

case reflect.Int64:
//
// types.List(OfInt64) -> []*int64.
//
var to []*int64
diags.Append(vFrom.ElementsAs(ctx, &to, false)...)
if diags.HasError() {
return diags
}

vTo.Set(reflect.ValueOf(to))
return diags
}
}
}

tflog.Info(ctx, "AutoFlex Expand; incompatible types", map[string]interface{}{
"from": vFrom.Type(ctx),
"to": vTo.Kind(),
})

return diags
}

// listOrSetOfString copies a Plugin Framework ListOfString(ish) or SetOfString(ish) value to a compatible AWS API value.
func (expander autoExpander) listOrSetOfString(ctx context.Context, vFrom valueWithElementsAs, vTo reflect.Value) diag.Diagnostics {
var diags diag.Diagnostics

switch vTo.Kind() {
Expand Down Expand Up @@ -443,8 +510,8 @@ func (expander autoExpander) listOfString(ctx context.Context, vFrom basetypes.L
}

tflog.Info(ctx, "AutoFlex Expand; incompatible types", map[string]interface{}{
"from list[%s]": vFrom.ElementType(ctx),
"to": vTo.Kind(),
"from": vFrom.Type(ctx),
"to": vTo.Kind(),
})

return diags
Expand Down Expand Up @@ -576,8 +643,12 @@ func (expander autoExpander) set(ctx context.Context, vFrom basetypes.SetValuabl
}

switch v.ElementType(ctx).(type) {
case basetypes.Int64Typable:
diags.Append(expander.listOrSetOfInt64(ctx, v, vTo)...)
return diags

case basetypes.StringTypable:
diags.Append(expander.setOfString(ctx, v, vTo)...)
diags.Append(expander.listOrSetOfString(ctx, v, vTo)...)
return diags

case basetypes.ObjectTypable:
Expand All @@ -595,58 +666,6 @@ func (expander autoExpander) set(ctx context.Context, vFrom basetypes.SetValuabl
return diags
}

// setOfString copies a Plugin Framework SetOfString(ish) value to a compatible AWS API value.
func (expander autoExpander) setOfString(ctx context.Context, vFrom basetypes.SetValue, vTo reflect.Value) diag.Diagnostics {
var diags diag.Diagnostics

switch vTo.Kind() {
case reflect.Slice:
switch tSliceElem := vTo.Type().Elem(); tSliceElem.Kind() {
case reflect.String:
//
// types.Set(OfString) -> []string.
//
var to []string
diags.Append(vFrom.ElementsAs(ctx, &to, false)...)
if diags.HasError() {
return diags
}

// Copy elements individually to enable expansion of lists of
// custom string types (AWS enums)
vals := reflect.MakeSlice(vTo.Type(), len(to), len(to))
for i := 0; i < len(to); i++ {
vals.Index(i).SetString(to[i])
}
vTo.Set(vals)
return diags

case reflect.Ptr:
switch tSliceElem.Elem().Kind() {
case reflect.String:
//
// types.Set(OfString) -> []*string.
//
var to []*string
diags.Append(vFrom.ElementsAs(ctx, &to, false)...)
if diags.HasError() {
return diags
}

vTo.Set(reflect.ValueOf(to))
return diags
}
}
}

tflog.Info(ctx, "AutoFlex Expand; incompatible types", map[string]interface{}{
"from set[%s]": vFrom.ElementType(ctx),
"to": vTo.Kind(),
})

return diags
}

// nestedObjectCollection copies a Plugin Framework NestedObjectCollectionValue value to a compatible AWS API value.
func (expander autoExpander) nestedObjectCollection(ctx context.Context, vFrom fwtypes.NestedObjectCollectionValue, vTo reflect.Value) diag.Diagnostics {
var diags diag.Diagnostics
Expand Down
Loading

0 comments on commit b3e6927

Please sign in to comment.