I'm automating the creation of a storage gateway in terraform following [1], to follow the best practices of gitops of having every important infrastucture as code. And i have to manually allocate the disk to cache. Has someone been able of automating the creating of cache disks for storage gateway in terraform? If I include the code in [1] it appears the error of data.aws_storagegateway_local_disk.fg_disk: no results found for query, try adjusting your search criteria
. I tried following [2], using disk path instead, but it appeared the same error. Thanks in advance :)
I forgot, this is the code regarding storage gateway cache disks that I used:
resource "aws_volume_attachment" "ebs_att_tf" {
device_name = "/dev/sdb"
volume_id = aws_ebs_volume.v_sg_agent_tf.id
instance_id = aws_instance.sg-agent_tf.id
depends_on = [aws_ebs_volume.v_sg_agent_tf, aws_instance.sg-agent_tf]
}
data "aws_storagegateway_local_disk" "ld_sg_tf" {
depends_on = [aws_volume_attachment.ebs_att_tf ]
disk_path = "/dev/sdb"
gateway_arn = aws_storagegateway_gateway.sg_tf.arn
}
resource "aws_storagegateway_cache" "sg_c_tf" {
disk_id = data.aws_storagegateway_local_disk.ld_sg_tf.disk_id
gateway_arn = aws_storagegateway_gateway.sg_tf.arn
depends_on = [ aws_storagegateway_gateway.sg_tf]
}
try using disk_node instead of disk_path, that worked for me :
data "aws_storagegateway_local_disk" "ld_sg_tf {
disk_node = "${aws_volume_attachment.ebs_att_tf.device_name}"
gateway_arn = "${aws_storagegateway_gateway.sg_tf.arn}"
}