Hi all,
I have a problem about 10th question at the lab-terraform-workspaces. Link is Terraform Basics Training Course | KodeKloud
I applied the solution but I met an error like below .
iac-server $ cat main.tf
module “payroll_app” {
source = “/root/terraform-projects/modules/payroll-app”
app_region = lookup(var.region, terraform.workspace)
ami = lookup(var.ami, terraform_workspace)
}iac-server $ terraform init
Initializing modules…
Downloading /root/terraform-projects/modules/payroll-app for payroll_app…
- payroll_app in .terraform/modules/payroll_app
Initializing the backend…
Initializing provider plugins…
- Finding hashicorp/aws versions matching “4.15.0”…
- Installing hashicorp/aws v4.15.0…
- Installed hashicorp/aws v4.15.0 (self-signed, key ID 34365D9472D7468F)
Partner and community providers are signed by their developers.
If you’d like to know more about provider signing, you can read about it here:
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running “terraform plan” to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
iac-server $ pwd
/root/terraform-projects/project-sapphire
iac-server $ terraform plan
Warning: Argument is deprecated
Use s3_use_path_style instead.
Error: Invalid reference
on main.tf line 4, in module “payroll_app”:
4: ami = lookup(var.ami, terraform_workspace)
A reference to a resource type must be followed by at least one attribute
access, specifying the resource name.
Could you please help me about solving?
Thank you
Best Regards
Elif