i have a single folder in which i have 2 files
- config.yml
- main.tf
in my config.yml the data is -
ami: ami-12345678
instance_type: t2.micro
name: my-instance
in my main.tf i have -
provider “aws” {
region = “us-east-2”
access_key= “AKIASDBYCJ62########”
secret_key= “B48Vgh4nRaTMuQDpki8ih2/TYR1M####@@@@#@#@”
}
locals {
my_yaml_data = yamldecode(file(“./config.yml”))
}
resource “aws_instance” “my_instance” {
source = “./config.yml”
ami = config.yml.ami
instance_type = config.yml.instance_type
name = config.yml.name
}
NOW when i do terraform plan i get a error =
- Reference to undeclared resource , A managed resource “config” “yml” has not been declared in the root module.
i did everything but i cant solve this error. i;m new to terraform and yml data parcing