@@ -53,17 +53,21 @@ loads all of them.
5353
5454```
5555provider "aws" {
56- access_key = "ACCESS_KEY_HERE"
57- secret_key = "SECRET_KEY_HERE"
58- region = "us-east-1"
56+ access_key = "ACCESS_KEY_HERE"
57+ secret_key = "SECRET_KEY_HERE"
58+ region = "us-east-1"
5959}
6060
6161resource "aws_instance" "example" {
62- ami = "ami-408c7f28 "
63- instance_type = "t1 .micro"
62+ ami = "ami-0d729a60 "
63+ instance_type = "t2 .micro"
6464}
6565```
6666
67+ ~ > ** Note** : The above configuation is designed to work on most EC2 accounts,
68+ with access to a default VPC. For EC2 Classic users, please use ` t1.micro ` for
69+ ` instance_type ` , and ` ami-408c7f28 ` for the ` ami ` .
70+
6771Replace the ` ACCESS_KEY_HERE ` and ` SECRET_KEY_HERE ` with your
6872AWS access key and secret key, available from
6973[ this page] ( https://console.aws.amazon.com/iam/home?#security_credential ) .
@@ -95,7 +99,7 @@ Within the resource block itself is configuration for that
9599resource. This is dependent on each resource provider and
96100is fully documented within our
97101[ providers reference] ( /docs/providers/index.html ) . For our EC2 instance, we specify
98- an AMI for Ubuntu, and request a "t1 .micro" instance so we
102+ an AMI for Ubuntu, and request a "t2 .micro" instance so we
99103qualify under the free tier.
100104
101105## Execution Plan
@@ -111,16 +115,24 @@ $ terraform plan
111115...
112116
113117+ aws_instance.example
114- ami: "" => "ami-408c7f28"
115- availability_zone: "" => "<computed>"
116- instance_type: "" => "t1.micro"
117- key_name: "" => "<computed>"
118- private_dns: "" => "<computed>"
119- private_ip: "" => "<computed>"
120- public_dns: "" => "<computed>"
121- public_ip: "" => "<computed>"
122- security_groups: "" => "<computed>"
123- subnet_id: "" => "<computed>"
118+ ami: "ami-0d729a60"
119+ availability_zone: "<computed>"
120+ ebs_block_device.#: "<computed>"
121+ ephemeral_block_device.#: "<computed>"
122+ instance_state: "<computed>"
123+ instance_type: "t2.micro"
124+ key_name: "<computed>"
125+ placement_group: "<computed>"
126+ private_dns: "<computed>"
127+ private_ip: "<computed>"
128+ public_dns: "<computed>"
129+ public_ip: "<computed>"
130+ root_block_device.#: "<computed>"
131+ security_groups.#: "<computed>"
132+ source_dest_check: "true"
133+ subnet_id: "<computed>"
134+ tenancy: "<computed>"
135+ vpc_security_group_ids.#: "<computed>"
124136```
125137
126138` terraform plan ` shows what changes Terraform will apply to
@@ -148,8 +160,12 @@ since Terraform waits for the EC2 instance to become available.
148160```
149161$ terraform apply
150162aws_instance.example: Creating...
151- ami: "" => "ami-408c7f28"
152- instance_type: "" => "t1.micro"
163+ ami: "" => "ami-0d729a60"
164+ instance_type: "" => "t2.micro"
165+ [...]
166+
167+ aws_instance.example: Still creating... (10s elapsed)
168+ aws_instance.example: Creation complete
153169
154170Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
155171
@@ -171,18 +187,17 @@ You can inspect the state using `terraform show`:
171187```
172188$ terraform show
173189aws_instance.example:
174- id = i-e60900cd
175- ami = ami-408c7f28
176- availability_zone = us-east-1c
177- instance_type = t1.micro
178- key_name =
179- private_dns = domU-12-31-39-12-38-AB.compute-1.internal
180- private_ip = 10.200.59.89
181- public_dns = ec2-54-81-21-192.compute-1.amazonaws.com
182- public_ip = 54.81.21.192
183- security_groups.# = 1
184- security_groups.0 = default
185- subnet_id =
190+ id = i-32cf65a8
191+ ami = ami-0d729a60
192+ availability_zone = us-east-1a
193+ instance_state = running
194+ instance_type = t2.micro
195+ private_ip = 172.31.30.244
196+ public_dns = ec2-52-90-212-55.compute-1.amazonaws.com
197+ public_ip = 52.90.212.55
198+ subnet_id = subnet-1497024d
199+ vpc_security_group_ids.# = 1
200+ vpc_security_group_ids.3348721628 = sg-67652003
186201```
187202
188203You can see that by creating our resource, we've also gathered
0 commit comments