hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.74k stars 9.1k forks source link

[Bug]: error waiting for Network Manager Core Network Policy #38672

Open JasonCubic opened 1 month ago

JasonCubic commented 1 month ago

Terraform Core Version

1.9.3

AWS Provider Version

5.61.0

Affected Resource(s)

aws_networkmanager_core_network_policy_attachment

Expected Behavior

timeout value of 30m set on aws_networkmanager_core_network be respected. When I try to attach a network policy the terraform crashes.

Workaround is to wait and run the terraform again.

Actual Behavior

Instead the timeout value falls back to 5m and my policy fails to attach. 5m might no longer be reasonable since AWS has added network configuration groups to the core network.

Possibly because of this line? https://github.com/hashicorp/terraform-provider-aws/blob/v5.61.0/internal/service/networkmanager/core_network.go#L40

Relevant Error/Panic Output Snippet

╷
│ Error: waiting for Network Manager Core Network Policy from Core Network (core-network-abc123) create: timeout while waiting for state to become 'READY_TO_EXECUTE' (last state: 'PENDING_GENERATION', timeout: 5m0s)
│
│   with module.cwan_core_network_policy.aws_networkmanager_core_network_policy_attachment.policy_attachment,
│   on modules\cwan_core_network_policy\main.tf line 11, in resource "aws_networkmanager_core_network_policy_attachment" "policy_attachment":
│   11: resource "aws_networkmanager_core_network_policy_attachment" "policy_attachment" {
│
╵

Terraform Configuration Files

I'm sorry, but I am unable to share this network policy document. As this issue can be resolved by making the timeout value configurable, I hope it is not needed.

https://github.com/hashicorp/terraform-provider-aws/blob/v5.61.0/internal/service/networkmanager/core_network.go#L40

Steps to Reproduce

Create a reasonably complicated core network policy and try to attach it in the same terraform apply. I have ~100 lines of policy with various segments, segment_actions, and attachment policies.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

JasonCubic commented 1 month ago

this is the resource where I set the timeouts:

resource "aws_networkmanager_core_network" "core_network" {
  description          = "Cloud WAN ${var.base_policy_region_name} core network"
  global_network_id    = aws_networkmanager_global_network.global_network.id
  base_policy_document = data.aws_networkmanager_core_network_policy_document.base_policy.json
  create_base_policy   = true
  tags = {
    Name = var.cwan_core_network_name
  }
  timeouts {
    create = "30m"
    update = "30m"
    delete = "30m"
  }
}

this is the resource that reports as failing in the error message:

resource "aws_networkmanager_core_network_policy_attachment" "policy_attachment" {
  core_network_id = var.core_network_id
  policy_document = data.aws_networkmanager_core_network_policy_document.cwan_policy.json
  timeouts {
    update = "30m"
  }
}