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

[Bug]: Message: "$.network-function-groups: null found, array expected" even when there is a network function group defined #38255

Closed
sameesin opened this issue Jul 4, 2024 · 5 comments · Fixed by #38642
Labels
bug Addresses a defect in current functionality. service/networkmanager Issues and PRs that pertain to the networkmanager service.
Milestone

Comments

@sameesin
Copy link

sameesin commented Jul 4, 2024

Terraform Core Version

1.9.1

AWS Provider Version

5.57.0

Affected Resource(s)

data source - "aws_networkmanager_core_network_policy_document"

data "aws_networkmanager_core_network_policy_document" "policy1" {
  core_network_configuration {
    asn_ranges = ["65022-65534"]

    edge_locations {
      location = "ap-south-1"
    }
  }

  segments {
    name = "segment1"
    require_attachment_acceptance = false
  }

  network_function_groups {
    name = "ftdgroup"
    require_attachment_acceptance = false
  }
}

Expected Behavior

The core network should get created but the code fails with an error stating incorrect policy

Actual Behavior

{
│ RespMetadata: {
│ StatusCode: 400,
│ RequestID: "<>"
│ },
│ Errors: [{
│ ErrorCode: "TYPE_MISMATCH",
│ Message: "$.network-function-groups: null found, array expected",
│ Path: "$.network-function-groups"
│ }],
│ Message_: "Incorrect policy."
│ }

Relevant Error/Panic Output Snippet

{
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "<>"
│   },
│   Errors: [{
│       ErrorCode: "TYPE_MISMATCH",
│       Message: "$.network-function-groups: null found, array expected",
│       Path: "$.network-function-groups"
│     }],
│   Message_: "Incorrect policy."
│ }

Terraform Configuration Files

resource "aws_networkmanager_global_network" "cloudwan-automation-test" {
  description = "cloudwan-automation-test"
}

data "aws_networkmanager_core_network_policy_document" "policy1" {
  core_network_configuration {
    asn_ranges = ["65022-65534"]

    edge_locations {
      location = "ap-south-1"
    }
  }

  segments {
    name = "segment1"
    require_attachment_acceptance = false
  }

  network_function_groups {
    name = "ftdgroup"
    require_attachment_acceptance = false
  }
}

resource "aws_networkmanager_core_network" "core_network" {
  global_network_id = aws_networkmanager_global_network.cloudwan-automation-test.id
  create_base_policy = true
}

resource "aws_networkmanager_core_network_policy_attachment" "policy_attachment" {
  core_network_id = aws_networkmanager_core_network.core_network.id
  policy_document = data.aws_networkmanager_core_network_policy_document.policy1.json
}

Steps to Reproduce

terraform init
terraform plan --out t
terraform apply t

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

@sameesin sameesin added the bug Addresses a defect in current functionality. label Jul 4, 2024
Copy link

github-actions bot commented Jul 4, 2024

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/networkmanager Issues and PRs that pertain to the networkmanager service. label Jul 4, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 4, 2024
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Jul 5, 2024
@ddericco
Copy link
Contributor

ddericco commented Jul 31, 2024

I'm able to reproduce this using the configuration files provided by @sameesin. It looks like using the create_base_policy argument with no other arguments causes the provider to generate an invalid base policy.

Note this is also causing multiple acceptance test failures:

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.5 test ./internal/service/networkmanager/... -v -count 1 -parallel 1 -run='TestAccNetworkManagerCoreNetwork_createBasePolicyDocument*'  -timeout 360m
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
=== RUN   TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithPolicyDocument
=== PAUSE TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithPolicyDocument
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion
    core_network_test.go:161: Step 1/2 error: Error running apply: exit status 1
        
        Error: creating Core Network: CoreNetworkPolicyException: Incorrect policy.
        {
          RespMetadata: {
            StatusCode: 400,
            RequestID: "dad105b7-d07d-43c8-90ef-9e039a62e05b"
          },
          Errors: [{
              ErrorCode: "TYPE_MISMATCH",
              Message: "$.network-function-groups: null found, array expected",
              Path: "$.network-function-groups"
            }],
          Message_: "Incorrect policy."
        }
        
          with aws_networkmanager_core_network.test,
          on terraform_plugin_test.tf line 14, in resource "aws_networkmanager_core_network" "test":
          14: resource "aws_networkmanager_core_network" "test" {
        
--- FAIL: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithoutRegion (11.52s)
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion
    core_network_test.go:239: Step 1/2 error: Error running apply: exit status 1
        
        Error: creating Core Network: CoreNetworkPolicyException: Incorrect policy.
        {
          RespMetadata: {
            StatusCode: 400,
            RequestID: "43f62dae-fa67-4d83-81bb-fe9320adf038"
          },
          Errors: [{
              ErrorCode: "TYPE_MISMATCH",
              Message: "$.network-function-groups: null found, array expected",
              Path: "$.network-function-groups"
            }],
          Message_: "Incorrect policy."
        }
        
          with aws_networkmanager_core_network.test,
          on terraform_plugin_test.tf line 14, in resource "aws_networkmanager_core_network" "test":
          14: resource "aws_networkmanager_core_network" "test" {
        
--- FAIL: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithMultiRegion (9.49s)
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithPolicyDocument
=== CONT  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
--- PASS: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithPolicyDocument (1488.82s)
=== NAME  TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion
    core_network_test.go:200: Step 1/2 error: Error running apply: exit status 1
        
        Error: creating Core Network: CoreNetworkPolicyException: Incorrect policy.
        {
          RespMetadata: {
            StatusCode: 400,
            RequestID: "95c44732-d429-463d-bd36-3c72459eb55e"
          },
          Errors: [{
              ErrorCode: "TYPE_MISMATCH",
              Message: "$.network-function-groups: null found, array expected",
              Path: "$.network-function-groups"
            }],
          Message_: "Incorrect policy."
        }
        
          with aws_networkmanager_core_network.test,
          on terraform_plugin_test.tf line 14, in resource "aws_networkmanager_core_network" "test":
          14: resource "aws_networkmanager_core_network" "test" {
        
--- FAIL: TestAccNetworkManagerCoreNetwork_createBasePolicyDocumentWithRegion (9.14s)
FAIL
FAIL    github.com/hashicorp/terraform-provider-aws/internal/service/networkmanager     1524.612s
FAIL
make: *** [testacc] Error 1

Possible workarounds

  1. Use the base_policy_document argument in the aws_networkmanager_core_network resource to force the use of a working policy:
resource "aws_networkmanager_core_network" "core_network" {
  global_network_id = aws_networkmanager_global_network.cloudwan-automation-test.id
  create_base_policy = true
  base_policy_document = data.aws_networkmanager_core_network_policy_document.policy1.json
}
  1. Use the AWSCC provider and the corresponding resource type to create and manage the core network:
resource "awscc_networkmanager_core_network" "example" {
  global_network_id = aws_networkmanager_global_network.cloudwan-automation-test.id
  description       = "example"
}

Copy link

github-actions bot commented Aug 5, 2024

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.62.0 milestone Aug 5, 2024
Copy link

github-actions bot commented Aug 9, 2024

This functionality has been released in v5.62.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

github-actions bot commented Sep 9, 2024

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/networkmanager Issues and PRs that pertain to the networkmanager service.
Projects
None yet
3 participants