带有Terraform的AWS Storage网关

时间:2018-08-31 08:01:42

标签: amazon-web-services terraform

有人设置过一个吗?我正在尝试创建NFS共享。

aws_storagegateway_local_disk无法找到该磁盘,并且如果没有它的terraform超时,aws控制台将显示消息“您需要分配本地存储”。

terraform文档对于此设置而言效果不佳,因为它似乎需要几个部分才能一起设置。

resource "aws_instance" "storage-gateway-server" {
    ami = "${local.thininstallami}"
    instance_type = "m4.xlarge"
    associate_public_ip_address = false
    key_name = "${local.keyname}"
    subnet_id = "${local.subnet}"
    vpc_security_group_ids = ["${aws_security_group.storage-gateway-sg.id}"]
    root_block_device {
        volume_size = 80
        volume_type = "gp2"
    }
}

resource "aws_ebs_volume" "storage-gateway-server-cache-disk" {
    availability_zone = "us-east-1a"
    size = 150
    encrypted = true
    type = "gp2"
}

resource "aws_volume_attachment" "storage-gateway-server-cache-disk-attach" {
    device_name = "/dev/sdb"
    volume_id   = "${aws_ebs_volume.storage-gateway-server-cache-disk.id}"
    instance_id = "${aws_instance.storage-gateway-server.id}"
}

resource "aws_storagegateway_gateway" "storage-gateway" {
    gateway_ip_address = "${aws_instance.storage-gateway-server.private_ip}"
    gateway_name       = "storage-gateway"
    gateway_timezone   = "GMT"
    gateway_type       = "FILE_S3"
}

data "aws_storagegateway_local_disk" "storage-gateway-data" {
    disk_path = "${aws_volume_attachment.storage-gateway-server-cache-disk-attach.device_name}"
    gateway_arn = "${aws_storagegateway_gateway.storage-gateway.arn}"
}

resource "aws_storagegateway_cache" "storage-gateway-cache" {
    disk_id     = "${data.aws_storagegateway_local_disk.storage-gateway-data.id}"
    gateway_arn = "${aws_storagegateway_gateway.storage-gateway.arn}"
}

resource "aws_storagegateway_nfs_file_share" "nfs_share" {
    client_list  = ["0.0.0.0/0"]
    gateway_arn  = "${aws_storagegateway_gateway.storage-gateway.arn}"
    location_arn = "${aws_s3_bucket.transfer-bucket.arn}"
    role_arn     = "${aws_iam_role.transfer-role.arn}"
}

0 个答案:

没有答案