- Implementing Cloud Design Patterns for AWS(Second Edition)
- Sean Keery Clive Harber Marcus Young
- 135字
- 2021-06-24 15:11:50
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.
推薦閱讀
- Mastering vRealize Operations Manager(Second Edition)
- 白話(huà)區(qū)塊鏈
- Instant Handlebars.js
- Windows Server 2012 Hyper-V Cookbook
- Installing and Configuring Windows 10:70-698 Exam Guide
- Mastering Reactive JavaScript
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)(Windows 7+Office 2016)
- AWS SysOps Cookbook
- Linux內(nèi)核API完全參考手冊(cè)(第2版)
- Linux從入門(mén)到精通(視頻教學(xué)版)
- Learn Quantum Computing with Python and IBM Quantum Experience
- VMware vSphere 5.1 Cookbook
- Getting Started with UDK
- 每天5分鐘玩轉(zhuǎn)Docker容器技術(shù)
- Linux指令從初學(xué)到精通