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

Execution fails when using vpc_attachments[].vpc_route_table_ids #100

Closed
1 task done
Jarodiv opened this issue Feb 11, 2023 · 9 comments
Closed
1 task done

Execution fails when using vpc_attachments[].vpc_route_table_ids #100

Jarodiv opened this issue Feb 11, 2023 · 9 comments
Labels

Comments

@Jarodiv
Copy link
Contributor

Jarodiv commented Feb 11, 2023

Description

Trying to add routes to Route Tables provided via vpc_attachments[].vpc_route_table_ids results in Terraform failing with an error message.

  • ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]: 2.8.2
  • Terraform version:
    Terraform v1.3.7
    on darwin_arm64
    
  • Provider version(s):
    provider registry.terraform.io/hashicorp/aws v4.46.0
    

Reproduction Code [Required]

Everything it needs is to configure IPv6 and provide VPC Route Tables:

module "my_vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "~> 3.0"

  name = "my-vpc"
  cidr = "10.1.0.0/16"

  azs             = ["${local.region}a", "${local.region}b"]
  private_subnets = ["10.1.1.0/24", "10.1.2.0/24"]
  public_subnets  = ["10.1.101.0/24", "10.1.102.0/24"]

  enable_nat_gateway = false
}

module "my_tgw" {
  source  = "terraform-aws-modules/transit-gateway/aws"
  version = "~> 2.0"

  name = "my-tgw"

  vpc_attachments = {
    vpc = {
      vpc_id     = module.my_vpc.vpc_id
      subnet_ids = module.my_vpc.private_subnets

      tgw_destination_cidr = "0.0.0.0/0"
      vpc_route_table_ids  = module.my_vpc.private_route_table_ids
    },
  }
}

Expected behavior

The code runs and routes are being created.

Actual behavior

The code fails with

╷
│ Error: Invalid for_each argument
│ 
│   on .terraform/modules/my_tgw/main.tf line 112, in resource "aws_route" "this":
│  112:   for_each = { for x in local.vpc_route_table_destination_cidr : x.rtb_id => x.cidr }
│     ├────────────────
│     │ local.vpc_route_table_destination_cidr will be known only after apply
│ 
│ The "for_each" map includes keys derived from resource attributes that cannot be determined until apply, and so Terraform cannot determine the full set of keys that will identify the instances of this resource.
│ 
│ When working with unknown values in for_each, it's better to define the map keys statically in your configuration and place apply-time results only in the map values.
│ 
│ Alternatively, you could use the -target planning option to first apply only the resources that the for_each value depends on, and then apply a second time to fully converge.
╵
@latelan
Copy link

latelan commented Feb 13, 2023

+1, It works when I comment it at first apply, and uncomment it run again

@github-actions
Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Mar 16, 2023
@Jarodiv
Copy link
Contributor Author

Jarodiv commented Mar 16, 2023

"Keep alive" post

@github-actions github-actions bot removed the stale label Mar 17, 2023
@github-actions
Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Apr 17, 2023
@Jarodiv
Copy link
Contributor Author

Jarodiv commented Apr 18, 2023

"Keep alive" post

@github-actions github-actions bot removed the stale label Apr 19, 2023
@github-actions
Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label May 20, 2023
@github-actions
Copy link

This issue was automatically closed because of stale in 10 days

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2023
@Jarodiv
Copy link
Contributor Author

Jarodiv commented Jun 1, 2023

Any way to re-ope this issue? The issue still exists and the PR fixing it is still not merged

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

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 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants