Skip to content

Create secondary cidr block on first pass? #142

@JasonCubic

Description

@JasonCubic

How can you make a secondary ipv4 cidr block for the vpc without needing to do a second pass and add it to an already created vpc? I want to create a vpc with two cidr blocks. A cidr block with a private IP block and an on-prem cidr block. I've tried it but it fails with this error:

│ Error: Invalid count argument

│ on .terraform\modules\secondary_vpc\data.tf line 132, in data "aws_vpc" "main":
│ 132: count = local.create_vpc ? 0 : 1

│ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created.
│ To work around this, use the -target argument to first apply only the resources that the count depends on.

It's possible that I am overthinking this. Should I just use the normal terraform aws_vpc_ipv4_cidr_block_association?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions