$ terraform --version
Terraform v0.12.0
+ provider.aws v2.13.0
+ provider.template v2.1.2
Bastion
resource "aws_instance" "bastion" {
ami = "${var.AMI_ID}"
instance_type = "${var.EC2_INSTANCE_SIZE}"
root_block_device = [{
volume_size = "${var.EC2_ROOT_VOLUME_SIZE}"
volume_type = "${var.EC2_ROOT_VOLUME_TYPE}"
delete_on_termination = "${var.EC2_ROOT_VOLUME_DELETE_ON_TERMINATION}"
}]
}
variable "AMI_ID" {
type = "string"
description = "AMI ID for the instance"
}
variable "EC2_INSTANCE_SIZE" {
type = "string"
default = "t2.micro"
description = "The EC2 instance size"
}
variable "EC2_ROOT_VOLUME_SIZE" {
type = "string"
default = "30"
description = "The volume size for the root volume in GiB"
}
variable "EC2_ROOT_VOLUME_TYPE" {
type = "string"
default = "gp2"
description = "The type of data storage: standard, gp2, io1"
}
variable "EC2_ROOT_VOLUME_DELETE_ON_TERMINATION" {
default = true
description = "Delete the root volume on instance termination."
}
https://gist.github.com/jpSimkins/23eb0cd578e53903e5fd6fca113f3c57
I expected this to create a bastion instance with a root device that I specified
Received an error:
An argument named "root_block_device" is not expected here. Did you mean to
define a block of type "root_block_device"?
Pretty much telling me that root_block_device
is not expected. I doubt the docs are wrong so this seems to be a bug.
With a simple aws_instance
resource using root_block_device
run:
terraform plan
NOTE: when omitting root_block_device
works as expected
This also affects terraform-aws-modules/autoscaling/aws. I assume due to using aws_instance
internally.
Error: Unsupported argument
on .terraform/modules/webserver_asg/terraform-aws-modules-terraform-aws-autoscaling-c5355e1/main.tf line 21, in resource "aws_launch_configuration" "this":
21: root_block_device = "${var.root_block_device}"
An argument named "root_block_device" is not expected here. Did you mean to
define a block of type "root_block_device"?
This is actually a critical issue IMHO, I am now having to bypass Terraform to complete a project. This is breaking. If I had time to look into why this was happening I would but unfortunately, I have to pass this to the community
`Error: Unsupported argument
on .terraform/modules/instance/main.tf line 13, in resource "aws_instance" "this":
13: root_block_device = "${var.root_block}"
An argument named "root_block_device" is not expected here. Did you mean to
define a block of type "root_block_device"?
Error: Unsupported argument
on .terraform/modules/instance/main.tf line 14, in resource "aws_instance" "this":
14: ebs_block_device = "${var.ebs_block}"
An argument named "ebs_block_device" is not expected here. Did you mean to
define a block of type "ebs_block_device"?
Releasing state lock. This may take a few moments...
make: * [apply] Error 1
`
**ebs_block_device and root_block_device error :(
@jpSimkins I believe you have the root_block_device
defined as a map attribute as opposed to a nested configuration block. I believe changing your syntax to the following should solve the issue in Terraform v0.12.0
resource "aws_instance" "bastion" {
ami = "${var.AMI_ID}"
instance_type = "${var.EC2_INSTANCE_SIZE}"
root_block_device {
volume_size = "${var.EC2_ROOT_VOLUME_SIZE}"
volume_type = "${var.EC2_ROOT_VOLUME_TYPE}"
delete_on_termination = "${var.EC2_ROOT_VOLUME_DELETE_ON_TERMINATION}"
}
}
@jmgreg31 Thank you! Yes, that was my issue. I am still having a similar issue with https://github.com/terraform-aws-modules/terraform-aws-autoscaling/issues/67 but I will close this ticket out and follow that ticket.
I thought I already tried that but I clearly didn't...
Thank you!
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
@jpSimkins I believe you have the
root_block_device
defined as a map attribute as opposed to a nested configuration block. I believe changing your syntax to the following should solve the issue inTerraform v0.12.0