python-terraform
python-terraform copied to clipboard
Error: Argument or block definition required
tf = Terraform(working_dir='/var/www/html/terraform')
tf.plan(no_color=IsFlagged, refresh=False, capture_output=True)
after running this script we are getting
Error: Argument or block definition required
Python Version - 3.6.8 Terraform v0.12.10
- provider.aws v2.31.0
anyone?
Without visibility into the actual TF plan I cannot help. This error would more than likely still occur if you ran the TF plan manually without wrapping with python-terraform, I would recommend running a tf fmt on the plan and see if that tells you where your error is.
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "${var.aws_region}"
}
resource "aws_instance" "scm_instances" {
ami = "ami-xxxxxxxxxxxxxxxxx"
instance_type = "t2.micro"
subnet_id = "subnet-xxxxxxxxxxxxxxxxxxxxxx"
vpc_security_group_ids = ["sg-0xxxxxxxxxxxxxxxxxxxxx"]
associate_public_ip_address = true
key_name = "ec2-instances"
root_block_device {
volume_type = "gp2"
volume_size = "50"
delete_on_termination = "true"
}
tags = {
Name = "${var.instance_name}"
}
}
output "instance_id" {
value = "${aws_instance.scm_instances.id}"
}
output "ip" {
value = "aws_instance.ip.public_ip"
}
This is the main.tf file
At a glance the output for IP is incorrect, you need to use a valid identifier. If you run this plan with Terraform directly do you get the same error?
No it works perfectly if hit manually!! Even if you remove the output section still get the same error
I will put a test together and take a deeper look, I don't see anything offhand that would be causing this unless they changed something in TF 0.12.10.
I would like to give more details about the error!! i tried on different terraform versions like 0.12.0, 0.12.12 (latest one), still getting the same error. also i get the following error
terraform.tfstate is not exist
before
Error: Argument or block definition required