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]: data.aws_networkmanager_core_network_policy_document attribute with_edge_override.use_edge instead of with_edge_override.use_edge_location #38134

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

Comments

@pablo19sc
Copy link

pablo19sc commented Jun 26, 2024

Terraform Core Version

1.3.0

AWS Provider Version

5.55.0

Affected Resource(s)

  • data.aws_networkmanager_core_network_policy_document

Expected Behavior

Attribute should be with_edge_override.use_edge_location

Actual Behavior

As attribute to configure is with_edge_override.use_edge, it translates bad to JSON, giving an error in the service.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

locals {
  aws_regions = {
    ireland   = "eu-west-1"
    london    = "eu-west-2"
    nvirginia = "us-east-1"
    sydney    = "ap-southeast-2"
  }

  segments = {
    production = {
      require_attachment_acceptance = false
      isolate_attachments           = true
    }
    development = {
      require_attachment_acceptance = false
      isolate_attachments           = false
    }
  }
}

data "aws_networkmanager_core_network_policy_document" "policy" {
  core_network_configuration {
    vpn_ecmp_support = false
    asn_ranges       = ["64520-65525"]

    dynamic "edge_locations" {
      for_each = local.aws_regions
      iterator = region

      content {
        location = region.value
      }
    }
  }

  dynamic "segments" {
    for_each = local.segments
    iterator = segment

    content {
      name                          = segment.key
      require_attachment_acceptance = segment.value.require_attachment_acceptance
      isolate_attachments           = segment.value.isolate_attachments
    }
  }

  network_function_groups {
    name                          = "inspectionVpcs"
    require_attachment_acceptance = false
  }

  dynamic "segment_actions" {
    for_each = local.segments
    iterator = segment

    content {
      action  = "send-to"
      segment = segment.key
      via {
        network_function_groups = ["inspectionVpcs"]
        with_edge_override {
          edge_sets = [ 
            [var.aws_regions.london] 
          ]
          use_edge  = var.aws_regions.ireland
        }
      }
    }
  }

  attachment_policies {
    rule_number     = 100
    condition_logic = "or"

    conditions {
      type     = "tag-value"
      operator = "equals"
      key      = "inspection"
      value    = "true"
    }
    action {
      add_to_network_function_group = "inspectionVpcs"
    }
  }

  attachment_policies {
    rule_number     = 200
    condition_logic = "or"

    conditions {
      type = "tag-exists"
      key  = "domain"
    }
    action {
      association_method = "tag"
      tag_value_of_key   = "domain"
    }
  }
}

data "aws_networkmanager_core_network_policy_document" "base_policy" {
  core_network_configuration {
    vpn_ecmp_support = false
    asn_ranges       = ["64520-65525"]

    dynamic "edge_locations" {
      for_each = var.aws_regions
      iterator = region

      content {
        location = region.value
      }
    }
  }

  dynamic "segments" {
    for_each = local.segments
    iterator = segment

    content {
      name                          = segment.key
      require_attachment_acceptance = segment.value.require_attachment_acceptance
      isolate_attachments           = segment.value.isolate_attachments
    }
  }

  network_function_groups {
    name                          = "inspectionVpcs"
    require_attachment_acceptance = false
  }

  attachment_policies {
    rule_number     = 100
    condition_logic = "or"

    conditions {
      type     = "tag-value"
      operator = "equals"
      key      = "inspection"
      value    = "true"
    }
    action {
      add_to_network_function_group = "inspectionVpcs"
    }
  }

  attachment_policies {
    rule_number     = 200
    condition_logic = "or"

    conditions {
      type = "tag-exists"
      key  = "domain"
    }
    action {
      association_method = "tag"
      tag_value_of_key   = "domain"
    }
  }
}

# Global Network
resource "aws_networkmanager_global_network" "global_network" {
  provider = aws.awsnvirginia

  description = "Global Network - ${var.identifier}"

  tags = {
    Name = "Global Network - ${var.identifier}"
  }
}

# Core Network
resource "aws_networkmanager_core_network" "core_network" {
  provider = aws.awsnvirginia

  description       = "Core Network - ${var.identifier}"
  global_network_id = aws_networkmanager_global_network.global_network.id

  create_base_policy = true
  #base_policy_document = local.base_policy
  base_policy_document = data.aws_networkmanager_core_network_policy_document.base_policy.json

  tags = {
    Name = "Core Network - ${var.identifier}"
  }
}

# Core Network Policy Attachment
resource "aws_networkmanager_core_network_policy_attachment" "core_network_policy_attachment" {
  provider = aws.awsnvirginia

  core_network_id = aws_networkmanager_core_network.core_network.id
  policy_document = data.aws_networkmanager_core_network_policy_document.policy.json
}

Steps to Reproduce

Terraform apply of above should be enough

Debug Output

Error: putting Network Manager Core Network (core-network-06fd2373b3367cdb0) policy: CoreNetworkPolicyException: Incorrect policy.
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "662b7f20-6c33-410d-bb28-63569cd0bd04"
│   },
│   Errors: [
│     {
│       ErrorCode: "TYPE_MISMATCH",
│       Message: "$.segment-actions[0].via.with-edge-overrides[0].edge-sets[0]: string found, array expected",
│       Path: "$.segment-actions[0].via.with-edge-overrides[0].edge-sets[0]"
│     },
│     {
│       ErrorCode: "REQUIRED_PROPERTY",
│       Message: "$.segment-actions[0].via.with-edge-overrides[0].use-edge-location: is missing but it is required",
│       Path: "$.segment-actions[0].via.with-edge-overrides[0]"
│     },
│     {
│       ErrorCode: "ADDITIONAL_PROPERTIES",
│       Message: "$.segment-actions[0].via.with-edge-overrides[0].use-edge: is not defined in the schema and the schema does not allow additional properties",
│       Path: "$.segment-actions[0].via.with-edge-overrides[0]"
│     },
│     {
│       ErrorCode: "TYPE_MISMATCH",
│       Message: "$.segment-actions[1].via.with-edge-overrides[0].edge-sets[0]: string found, array expected",
│       Path: "$.segment-actions[1].via.with-edge-overrides[0].edge-sets[0]"
│     },
│     {
│       ErrorCode: "REQUIRED_PROPERTY",
│       Message: "$.segment-actions[1].via.with-edge-overrides[0].use-edge-location: is missing but it is required",
│       Path: "$.segment-actions[1].via.with-edge-overrides[0]"
│     },
│     {
│       ErrorCode: "ADDITIONAL_PROPERTIES",
│       Message: "$.segment-actions[1].via.with-edge-overrides[0].use-edge: is not defined in the schema and the schema does not allow additional properties",
│       Path: "$.segment-actions[1].via.with-edge-overrides[0]"
│     }
│   ],
│   Message_: "Incorrect policy."
│ }
│ 
│   with aws_networkmanager_core_network_policy_attachment.core_network_policy_attachment,
│   on main.tf line 40, in resource "aws_networkmanager_core_network_policy_attachment" "core_network_policy_attachment":
│   40: resource "aws_networkmanager_core_network_policy_attachment" "core_network_policy_attachment" {

Panic Output

No response

Important Factoids

No response

References

Relates #38013.

Would you like to implement a fix?

None

@pablo19sc pablo19sc 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.

Copy link

github-actions bot commented Sep 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.66.0 milestone Sep 5, 2024
Copy link

github-actions bot commented Sep 5, 2024

This functionality has been released in v5.66.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 Oct 6, 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 Oct 6, 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
Development

Successfully merging a pull request may close this issue.

2 participants