从快照还原实例,而无需使用terraform

时间:2018-03-31 04:27:24

标签: terraform

用例:意图是恢复已经运行实例当前正在运行的卷的AWS快照的实例。

为此,我想为什么不使用“terraform import”来引入实例的现有状态,然后修改HCL配置文件以替换ONLY卷。通过行为,它期望从快照创建AMI,然后从AMI生成实例。它可以工作,但它会破坏实例,然后重新创建实例。

我不期望实例娱乐,而是为什么不在下面使用terraform:

  • 停止实例
  • 分离当前音量
  • 从提供的快照创建卷以恢复为
  • 将创建的卷附加到实例
  • 启动实例。

如何实现上述目标?

导入实例后我正在尝试的当前配置文件:

provider "aws" {
…..
…..
…..
}

resource "aws_ami" "example5554" {
    name = "example5554"
    virtualization_type = "hvm"
    root_device_name = "/dev/sda1"

    ebs_block_device {
        snapshot_id = "snap-xxxxxxxxxxxxx”
        device_name = "/dev/sda1"
        volume_type = "gp2"
    }
}

resource "aws_instance" "arstest1new" {
    ami = "${aws_ami.example5554.id}"
    instance_type = "m4.large"
}

0 个答案:

没有答案
相关问题