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

local.lookup_transit_gateway : The "count" value depends on resource attributes that cannot be determined until apply #51

Open
allexivan opened this issue Aug 17, 2024 · 3 comments · May be fixed by #53
Labels
bug 🐛 An issue with the system

Comments

@allexivan
Copy link

Describe the Bug

I cannot dynamically reference module.transit_gateway.
I get a count error:

.terraform/modules/transit_gateway_vpc_attachments_and_subnet_routes_dev_oregon/main.tf line 34, in data "aws_ec2_transit_gateway" "this":
│ 34: count = local.lookup_transit_gateway ? 1 : 0
│
module "transit_gateway_vpc_attachments_and_subnet_routes_prod" {
  source = "../../"

  # `prod` account can access the Transit Gateway in the `network` account since we shared the Transit Gateway with the Organization using Resource Access Manager
  existing_transit_gateway_id             = module.transit_gateway.transit_gateway_id
  existing_transit_gateway_route_table_id = module.transit_gateway.transit_gateway_route_table_id

  create_transit_gateway                                         = false
  create_transit_gateway_route_table                             = false
  create_transit_gateway_vpc_attachment                          = true
  create_transit_gateway_route_table_association_and_propagation = false

  config = {
    prod = {
      vpc_id                 = module.vpc_prod.vpc_id
      vpc_cidr               = module.vpc_prod.vpc_cidr_block
      subnet_ids             = module.subnets_prod.private_subnet_ids
      subnet_route_table_ids = module.subnets_prod.private_route_table_ids
      route_to               = null
      route_to_cidr_blocks = [
        module.vpc_staging.vpc_cidr_block,
        module.vpc_dev.vpc_cidr_block
      ]
      static_routes                     = null
      transit_gateway_vpc_attachment_id = null
    }
  }

  context = module.this.context

  providers = {
    aws = aws.prod
  }
}

Expected Behavior

reference to a transit gateway should not fail when there are no resources created.

Steps to Reproduce

The official code does not work:

https://github.com/cloudposse/terraform-aws-transit-gateway/blob/main/examples/multi-account/main.tf

Screenshots

No response

Environment

Terraform v1.9.3
on darwin_arm64

Additional Context

No response

@allexivan allexivan added the bug 🐛 An issue with the system label Aug 17, 2024
@intel352
Copy link

I'm also blocked by this error.

@intel352
Copy link

@osterman Is there a workaround that CloudPosse can recommend here, or a suggested fix? I'm happy to submit a PR but I'm newer to terraform and unsure how to resolve this other than potentially via apply-time -target, which seems hacky.

@intel352 intel352 linked a pull request Oct 28, 2024 that will close this issue
@intel352
Copy link

@allexivan I've submitted PR #53, in case you want to test whether this also resolves your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants