Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29243

root module does not declare a variable of that name. To use this value, add a "variable" block to the configuration

$
0
0

my directory structure

.├── README.md├── ec2│  ├── ec2.tf│  ├── outputs.tf│  └── vars.tf├── main.tf

main.tf

provider "aws" {  region = "us-east-1"}module "ec2" {  source = "./ec2"}

ec2/ec2.tf

data "aws_ami""example" {  most_recent = true  owners = ["amazon"]  filter {    name = "image-id"    values = ["ami-0323c3dd2da7fb37d"]  }  filter {    name = "root-device-type"    values = ["ebs"]  }  filter {    name = "virtualization-type"    values = ["hvm"]  }}resource "aws_instance""web" {  ami = data.aws_ami.example.id  instance_type = "t2.micro"  subnet_id = var.subnet_id  tags = {    Name = "HelloWorld"  }}

ec2/avrs.tf

variable "subnet_id" {  default = {}}

when i try to pass the subnet_id from outside i'm getting error.

terraform plan -var subnet_id=$subnet_name

Error: Value for undeclared variableA variable named "subnet_id" was assigned on the command line, but the rootmodule does not declare a variable of that name. To use this value, add a"variable" block to the configuration.

if any of you have idea about this issue please help me.


Viewing all articles
Browse latest Browse all 29243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>