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

d/aws_networkmanager_core_network_policy_document: Add support for service insertion #38013

Merged
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
23 changes: 23 additions & 0 deletions .changelog/38013.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
```release-note:enhancement
data-source/aws_networkmanager_core_network_policy_document: Add `attachment_policies.action.add_to_network_function_group` argument
```

```release-note:enhancement
data-source/aws_networkmanager_core_network_policy_document: Add `send-via` and `send-to` as valid values for `segment_actions.action`
```

```release-note:enhancement
data-source/aws_networkmanager_core_network_policy_document: Add `single-hop` and `dual-hop` as valid values for `segment_actions.mode`
```

```release-note:enhancement
data-source/aws_networkmanager_core_network_policy_document: Add `when_sent_to` and `via` configuration blocks to `segment_actions`
```

```release-note:bug
data-source/aws_networkmanager_core_network_policy_document: Add correct `except` values to the returned JSON document when `segment_actions.share_with_except` is configured
```

```release-note:enhancement
data-source/aws_networkmanager_core_network_policy_document: Add `network_function_groups` configuration block
```
26 changes: 8 additions & 18 deletions internal/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,23 +652,13 @@ func CheckResourceAttrRFC3339(resourceName, attributeName string) resource.TestC
return resource.TestMatchResourceAttr(resourceName, attributeName, regexache.MustCompile(RFC3339RegexPattern))
}

// CheckResourceAttrEquivalentJSON is a TestCheckFunc that compares a JSON value with an expected value. Both JSON
// values are normalized before being compared.
func CheckResourceAttrEquivalentJSON(resourceName, attributeName, expectedJSON string) resource.TestCheckFunc {
return func(s *terraform.State) error {
is, err := PrimaryInstanceState(s, resourceName)
if err != nil {
return err
}

v, ok := is.Attributes[attributeName]
if !ok {
return fmt.Errorf("%s: No attribute %q found", resourceName, attributeName)
}

vNormal, err := structure.NormalizeJsonString(v)
// CheckResourceAttrEquivalentJSON is a TestCheckFunc that compares a JSON value with an expected value.
// Both JSON values are normalized before being compared.
func CheckResourceAttrEquivalentJSON(n, key, expectedJSON string) resource.TestCheckFunc {
return resource.TestCheckResourceAttrWith(n, key, func(value string) error {
vNormal, err := structure.NormalizeJsonString(value)
if err != nil {
return fmt.Errorf("%s: Error normalizing JSON in %q: %w", resourceName, attributeName, err)
return fmt.Errorf("%s: Error normalizing JSON in %q: %w", n, key, err)
}

expectedNormal, err := structure.NormalizeJsonString(expectedJSON)
Expand All @@ -677,10 +667,10 @@ func CheckResourceAttrEquivalentJSON(resourceName, attributeName, expectedJSON s
}

if vNormal != expectedNormal {
return fmt.Errorf("%s: Attribute %q expected\n%s\ngot\n%s", resourceName, attributeName, expectedJSON, v)
return fmt.Errorf("%s: Attribute %q expected\n%s\ngot\n%s", n, key, expectedJSON, value)
}
return nil
}
})
}

func CheckResourceAttrJMES(name, key, jmesPath, value string) resource.TestCheckFunc {
Expand Down
12 changes: 6 additions & 6 deletions internal/service/networkmanager/core_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,18 +625,18 @@ func waitCoreNetworkPolicyCreated(ctx context.Context, conn *networkmanager.Netw

// buildCoreNetworkBasePolicyDocument returns a base policy document
func buildCoreNetworkBasePolicyDocument(regions []interface{}) (string, error) {
edgeLocations := make([]*CoreNetworkEdgeLocation, len(regions))
edgeLocations := make([]*coreNetworkPolicyCoreNetworkEdgeLocation, len(regions))
for i, location := range regions {
edgeLocations[i] = &CoreNetworkEdgeLocation{Location: location.(string)}
edgeLocations[i] = &coreNetworkPolicyCoreNetworkEdgeLocation{Location: location.(string)}
}

basePolicy := &CoreNetworkPolicyDoc{
basePolicy := &coreNetworkPolicyDocument{
Version: "2021.12",
CoreNetworkConfiguration: &CoreNetworkPolicyCoreNetworkConfiguration{
AsnRanges: CoreNetworkPolicyDecodeConfigStringList([]interface{}{"64512-65534"}),
CoreNetworkConfiguration: &coreNetworkPolicyCoreNetworkConfiguration{
AsnRanges: coreNetworkPolicyExpandStringList([]interface{}{"64512-65534"}),
EdgeLocations: edgeLocations,
},
Segments: []*CoreNetworkPolicySegment{
Segments: []*coreNetworkPolicySegment{
{
Name: "segment",
Description: "base-policy",
Expand Down
Loading
Loading