如何使用 terraform 自动为存储网关创建缓存磁盘?
How to automate the creation of cache disks for storage gateway with terraform?
我正在按照 [1] 在 terraform 中自动创建存储网关,以遵循 gitops 将每个重要基础设施作为代码的最佳实践。而且我必须手动将磁盘分配给缓存。有人能够在 terraform 中为存储网关自动创建缓存磁盘吗?如果我在 [1] 中包含代码,则会出现 data.aws_storagegateway_local_disk.fg_disk: no results found for query, try adjusting your search criteria
的错误。我尝试按照 [2],改用磁盘路径,但出现了同样的错误。提前致谢:)
忘记了,这是我用的存储网关缓存盘的代码:
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]
}
尝试使用 disk_node 而不是 disk_path,这对我有用:
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}"
}
我正在按照 [1] 在 terraform 中自动创建存储网关,以遵循 gitops 将每个重要基础设施作为代码的最佳实践。而且我必须手动将磁盘分配给缓存。有人能够在 terraform 中为存储网关自动创建缓存磁盘吗?如果我在 [1] 中包含代码,则会出现 data.aws_storagegateway_local_disk.fg_disk: no results found for query, try adjusting your search criteria
的错误。我尝试按照 [2],改用磁盘路径,但出现了同样的错误。提前致谢:)
忘记了,这是我用的存储网关缓存盘的代码:
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]
}
尝试使用 disk_node 而不是 disk_path,这对我有用:
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}"
}