官术网_书友最值得收藏!

Instances

EC2 is the instance level service offering. We already created an instance when we spun up our Cloud9 environment. Using Terraform, we can create another one very easily. Create the following example.tf file:

resource "aws_instance" "example" {
ami = "ami-2757f631"
instance_type = "t2.micro"
}
output "id" {
value = "${aws_instance.example.id}"
}

Run terraform apply. The output will be kept in your state file for future use:

We can easily destroy it with terraform destroy. If you like, you can try it now. Bringing the environments back is as simple as running terraform apply.

One thing to note about terraform destroy is that it can be unreliable in practice, especially if the environment is quite complicated. It pays to check that everything has been torn down successfully after the command has completed.

主站蜘蛛池模板: 台州市| 金平| 鸡西市| 宁海县| 晋中市| 南江县| 南乐县| 尚义县| 开平市| 禄劝| 南昌市| 兰坪| 青州市| 宁蒗| 垫江县| 甘谷县| 离岛区| 龙岩市| 隆林| 霸州市| 安溪县| 秦安县| 乌兰县| 文化| 大连市| 汪清县| 永修县| 义马市| 四会市| 苍梧县| 佛坪县| 调兵山市| 从江县| 昆明市| 沧州市| 绿春县| 红原县| 上杭县| 图木舒克市| 饶阳县| 化州市|