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]: network-function-groups wildcard fails in data source aws_networkmanager_core_network_policy_document #38145

Closed
sgreathouse-rgare opened this issue Jun 26, 2024 · 7 comments · Fixed by #38595
Labels
bug Addresses a defect in current functionality. service/networkmanager Issues and PRs that pertain to the networkmanager service.
Milestone

Comments

@sgreathouse-rgare
Copy link

sgreathouse-rgare commented Jun 26, 2024

Terraform Core Version

1.8.5

AWS Provider Version

5.55.0

Affected Resource(s)

Wildcard for segments fails in network_function_groups.

json version works:

"segment-actions": [
  {
    "action": "send-via",
    "segment": "production",
    "mode": "single-hop",
    "when-sent-to": {
      "segments": "*"
    },
    "via": {
      "network-function-groups": [
        "inspection"
      ]
    }
  }
]

tf version fails in data.aws_networkmanager_core_network_policy_document

segment_actions {
    action = "send-via"
    segment = "prouction"
    mode = "single-hop"
    when_sent_to {
      segments = "*"
    }
    via {
      network_function_groups = ["inspection"]
   }
  }

with Terraform error:

Error: Incorrect attribute value type
  on policy_document.tf line 94, in data "aws_networkmanager_core_network_policy_document" "this":
  94:       segments = "*"
Inappropriate value for attribute "segments": set of string required.

placing the wildcard in brackets ["*"] fails with AWS API error:

Error: putting Network Manager Core Network (core-network-01e65ecf64c59aca1) policy: CoreNetworkPolicyException: Incorrect policy.
{
  RespMetadata: {
    StatusCode: 400,
    RequestID: "6cbbef9d-64bf-4872-8012-95d1513e206f"
  },
  Errors: [
    {
      ErrorCode: "TYPE_MISMATCH",
      Message: "$.segment-actions[0].when-sent-to.segments: array found, object expected",
      Path: "$.segment-actions[0].when-sent-to.segments"
    },
    {
      ErrorCode: "TYPE_MISMATCH",
      Message: "$.segment-actions[0].when-sent-to.segments: array found, string expected",
      Path: "$.segment-actions[0].when-sent-to.segments"
    },
    {
      ErrorCode: "CONSTANT_VIOLATION",
      Message: "$.segment-actions[0].when-sent-to.segments: send-via segments only accept wildcard \"*\" as a string",
      Path: "$.segment-actions[0].when-sent-to.segments"
    },
    {
      ErrorCode: "INVALID_STRING",
      Message: "$.segment-actions[0].when-sent-to.segments[0]: segment names must start with a letter, be less than 64 characters long in length, and may include \"a..z\", \"A..Z\", or, \"0..9\"",
      Path: "$.segment-actions[0].when-sent-to.segments[0]"
    }
  ],
  Message_: "Incorrect policy."
}
with aws_networkmanager_core_network_policy_attachment.policy_attachment,
on core_network.tf line 12, in resource "aws_networkmanager_core_network_policy_attachment" "policy_attachment":
12: resource "aws_networkmanager_core_network_policy_attachment" "policy_attachment" 

as do other variants:

segments = *
segments = [*]

Expected Behavior

It should work like the json version

Actual Behavior

errors, as shown above

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

see below

Steps to Reproduce

Convert any module using service insertion via json:

resource "aws_networkmanager_core_network_policy_attachment" "policy_attachment" {
  core_network_id = aws_networkmanager_core_network.core_network.id
  policy_document = jsonencode(jsondecode(file("${path.module}/policy_document.json")))
}

That contains a wildcard in send-via

"segment-actions": [
  {
    "action": "send-via",
    "segment": "production",
    "mode": "single-hop",
    "when-sent-to": {
      "segments": "*"
    },
    "via": {
      "network-function-groups": [
        "inspection"
      ]
    }
  }
]

To use data.aws_networkmanager_core_network_policy_document

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.this.json
}

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

Relates #38013.
Relates #38134.

Would you like to implement a fix?

None

@sgreathouse-rgare sgreathouse-rgare added the bug Addresses a defect in current functionality. label Jun 26, 2024
@github-actions github-actions bot added the service/networkmanager Issues and PRs that pertain to the networkmanager service. label Jun 26, 2024
Copy link

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.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Jun 26, 2024
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Jun 27, 2024
@ewbankkit
Copy link
Contributor

We'll probably have to apply the same custom marshaling logic as for share-with:

	if v := c.ShareWith; v != nil {
		v := v.([]string)
		if v[0] == "*" {
			share = v[0]
		} else {
			share = v
		}
	}

@sgreathouse-rgare
Copy link
Author

@ewbankkit Any updates or ETA on this issue?

  • Thanks

Copy link

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.

1 similar comment
Copy link

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.61.0 milestone Jul 30, 2024
Copy link

github-actions bot commented Aug 2, 2024

This functionality has been released in v5.61.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 1, 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 1, 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
2 participants