I believe I've followed the documentation properly, however I can't get past this error when trying to create a VPC:
Plan: 3 to add, 0 to change, 0 to destroy.
module.vpc.aws_vpc.default[0]: Creating...
Error: creating EC2 VPC: MissingParameter: Either 'cidrBlock' or 'ipv4IpamPoolId' should be provided.
status code: 400, request id: d0e8e1a1-a19c-4d2a-9b33-cf89c5d207be
with module.vpc.aws_vpc.default[0],
on .terraform/modules/vpc/main.tf line 30, in resource "aws_vpc" "default":
30: resource "aws_vpc" "default" {
Releasing state lock. This may take a few moments...
Expected Behavior
When declaring variables according to the documentation, I would expect the module to create a VPC using my IPAM pool & CIDR I specified in my .tfvars file:
variable "region" {
description = "The region in AWS we're working on"
default = null
}
variable "namespace" {
description = "ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique"
default = "<REDACTED>"
}
variable "stage" {
description = "ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'"
default = null
}
variable "name" {
description = <<EOF
ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
EOF
default = null
}
variable "ipv4_additional_cidr_block_associations" {
description = <<EOF
IPv4 CIDR blocks to assign to the VPC.
Ipv4_cidr_block can be set explicitly, or set to null with the CIDR block derived from ipv4_ipam_pool_id using ipv4_netmask_length.
Map keys must be known at plan time, and are only used to track changes.
EOF
type = map(object({
ipv4_cidr_block = string
ipv4_ipam_pool_id = string
ipv4_netmask_length = number
}))
default = null
}
Screenshots
I think the code snippets above should be just fine
Environment:
[] adam ~ $ tfenv list
* 1.4.6 (set by /opt/homebrew/Cellar/tfenv/3.0.0/version)
1.3.6
1.2.9
1.1.9
[] adam ~ $
terraform {
required_version = "~> 1.4.6"
(I also tried terraform versions 1.2.9 & 1.1.9, same error)
source = "hashicorp/aws"
version = "4.58.0"
Additional Context
I can't seem to figure this out. I've enabled export TF_LOG=DEBUG too, however that didn't give anymore information besides the error above.
I very well could be using map(object) incorrectly, however I've troubleshot this quite a bit and I'm out of ideas. I looked locally in the .terraform/modules directory too, to see what the modules doing but again.. just stuck on this. Any help would be greatly appreciated.
Describe the Bug
I believe I've followed the documentation properly, however I can't get past this error when trying to create a VPC:
Expected Behavior
When declaring variables according to the documentation, I would expect the module to create a VPC using my IPAM pool & CIDR I specified in my .tfvars file:
Steps to Reproduce
Steps to reproduce the behavior: Using the VPC module as so, you should be able to replicate this:
main.tf
<some-prefix>.tfvar
:provider.tf
:backend.tf
:variables.tf
:Screenshots
I think the code snippets above should be just fine
Environment:
(I also tried terraform versions 1.2.9 & 1.1.9, same error)
Additional Context
I can't seem to figure this out. I've enabled
export TF_LOG=DEBUG
too, however that didn't give anymore information besides the error above.I very well could be using map(object) incorrectly, however I've troubleshot this quite a bit and I'm out of ideas. I looked locally in the
.terraform/modules
directory too, to see what the modules doing but again.. just stuck on this. Any help would be greatly appreciated.Thank you!