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]: 'aws_networkmanager_core_network_policy_document' Data with 'share_with_except' results in unexpected 'share_with' in plan #31314

Closed
dmaclaury opened this issue May 10, 2023 · 3 comments · Fixed by #38013
Labels
bug Addresses a defect in current functionality. service/networkmanager Issues and PRs that pertain to the networkmanager service.
Milestone

Comments

@dmaclaury
Copy link

Terraform Core Version

1.4.6

AWS Provider Version

4.66.1

Affected Resource(s)

  • data "aws_networkmanager_core_network_policy_document"

Expected Behavior

Defining a share segment_actions block within data "aws_networkmanager_core_network_policy_document" "this" with a segment name in the share_with_except value should result in the policy's JSON output having { except: ["SegmentNotSharedWith"]}.

The block:

data "aws_networkmanager_core_network_policy_document" "this"
  ....
  segment_actions {
    action            = "share"
    mode              = "attachment-route"
    segment           = "SegmentToBeShared"
    share_with_except = ["SegmentNotSharedWith"]
  }
  ...
}

Once applied, should result in:

  "segment-actions": [
    {
      "action": "share",
      "mode": "attachment-route",
      "segment": "SegmentToBeShared",
      "share-with": {
        "except": [
          "SegmentNotSharedWith"
        ]
      }
    }
  ],

Actual Behavior

The segment defined in share_with_except is defined in JSON as "share-with": [ "SegmentNotSharedWith" ] (missing the except).

This results in the shared segment being shared with a segment that it should be excluded from.

The block

  segment_actions {
    action            = "share"
    mode              = "attachment-route"
    segment           = "SegmentToBeShared"
    share_with_except = ["SegmentNotSharedWith"]
  }

results in the plan

        policy_document = jsonencode(
          ~ {
              + segment-actions            = [
                  + {
                      + action     = "share"
                      + mode       = "attachment-route"
                      + segment    = "SegmentToBeShared"
                      + share-with = [
                          + "SegmentNotSharedWith",
                        ]
                    },
                ]
                # (4 unchanged attributes hidden)
            }
        )

Once applied the json contains:

  "segment-actions": [
    {
      "action": "share",
      "mode": "attachment-route",
      "segment": "SegmentToBeShared",
      "share-with": [
        "SegmentNotSharedWith"
      ]
    }
  ],

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

terraform {
  required_version = "1.4.6"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "4.66.1"
    }
  }
}

provider "aws" {
  region = "us-west-2"
}

resource "aws_networkmanager_global_network" "this" {
  description = "CloudWAN Troubleshooting"
}

resource "aws_networkmanager_core_network" "this" {
  global_network_id = aws_networkmanager_global_network.this.id

  description         = "Troubleshooting Cloud WAN Core Network"
  create_base_policy  = false
  base_policy_regions = null
}

resource "aws_networkmanager_core_network_policy_attachment" "this" {
  core_network_id = aws_networkmanager_core_network.this.id
  policy_document = data.aws_networkmanager_core_network_policy_document.this.json
}

data "aws_networkmanager_core_network_policy_document" "this" {
  core_network_configuration {
    asn_ranges       = ["64512-65534"]
    vpn_ecmp_support = false

    edge_locations {
      location = "us-east-1"
    }

    edge_locations {
      location = "us-west-2"
    }
  }

  segments {
    name                          = "SegmentToBeShared"
    description                   = "Segment to be shared in this test"
    require_attachment_acceptance = true
  }

  segments {
    name = "OtherSegment1"
  }

  segments {
    name = "OtherSegment2"
  }

  segments {
    name                          = "SegmentNotSharedWith"
    description                   = "Segment that should not be shared with this test"
    require_attachment_acceptance = true
  }

  segment_actions {
    action            = "share"
    mode              = "attachment-route"
    segment           = "SegmentToBeShared"
    share_with_except = ["SegmentNotSharedWith"]
  }
}

Steps to Reproduce

Apply the supplied configuration that has share_with_except defined in the segment_actions block.

The same result occurs with both a larger deployment, and this simplified test deployment.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

Registry documentation on share_with vs share_with_except: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/networkmanager_core_network_policy_document#segment_actions

Would you like to implement a fix?

None

@dmaclaury dmaclaury added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels May 10, 2023
@github-actions github-actions bot added the service/networkmanager Issues and PRs that pertain to the networkmanager service. label May 10, 2023
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label May 11, 2023
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.55.0 milestone Jun 17, 2024
Copy link

This functionality has been released in v5.55.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

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 Jul 22, 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