getting the given error :╷
│ Error: Unsupported argument
│
│ on main.tf line 4, in module “VPC”:
│ 4: cidr_block = var.cidr_block
│
│ An argument named “cidr_block” is not expected here.
I am creating the vpc from vpc module the module has a resource block which triggers the service catalog provisioned product which create the vpc by calling service catalog template which is a cloudformation templates.
when I am calling the module in the child module also getting the above error:
I have define the input variable in the module variable.tf and in the child module variable.tf from where i am calling the the module along with the argument as well cidr_block = var.cidr_block don’t know what is missing.
Module -VPC Content:
main.tf
data “aws_region” “current” {}
locals {
vpc_name = “${var.vpc}”
}
resource “aws_servicecatalog_provisioned_product” “vpc” {
name = local.vpc_name
product_name = “VPC”
provisioning_artifact_name = “1.5.0”
aws servicecatalog describe-provisioning-parameters --product-name VPC --provisioning-artifact-name 1.1.0 --path-name Networking
provisioning_parameters {
key = “vpcname”
value = local.vpc_name ### where to pass the value for t
}
provisioning_parameters {
key = “cidrblocksize”
value = var.mask
}
tags = {
region = data.aws_region.current.id
short_name = var.vpc
}
}
Getting VPC data
data “aws_vpc” “this” {
depends_on = [aws_servicecatalog_provisioned_product.vpc]
filter {
name = “tag:Name”
values = [local.vpc_name]
}
}
variable.tf
variable “vpc” {
description = “Vpc and subnet definition”
type = string
}
variable “cidr_block” {
description = “vpc mask for cidr”
type = string
}
=============================
Child module :
main.tf
module “VPC” {
source = “git::Sign in to your account”
cidr_block = var.cidr_block
}
module “private_subnet” {
source = “…/modules/private_subnet”
depends_on = [module.VPC]
subnet_mask = var.subnet_mask
vpc_id = module.VPC.vpc_id
}
variable.tf:
variable “region” {
description = “Region for deploying resources (auto-filled by the terraform Gradle plugin)”
type = string
default = “eu-west-1”
}
variable “vpc” {
description = “Vpc and subnet definition”
type = string
}
variable “cidr_block” {
description = “vpc mask for cidr”
type = string
}
variable “subnet_mask” {
description = “subnet mask for the subnets”
type = number
}