mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/aws: Update documentation to use t2.micro, provide Classic options (#6801)
* provider/aws: Update documentation to use t2.micro, provide Classic options
This commit is contained in:
parent
28ad394264
commit
42c68645af
@ -59,11 +59,15 @@ provider "aws" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_instance" "example" {
|
resource "aws_instance" "example" {
|
||||||
ami = "ami-408c7f28"
|
ami = "ami-0d729a60"
|
||||||
instance_type = "t1.micro"
|
instance_type = "t2.micro"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
~> **Note**: The above configuation is designed to work on most EC2 accounts,
|
||||||
|
with access to a default VPC. For EC2 Classic users, please use `t1.micro` for
|
||||||
|
`instance_type`, and `ami-408c7f28` for the `ami`.
|
||||||
|
|
||||||
Replace the `ACCESS_KEY_HERE` and `SECRET_KEY_HERE` with your
|
Replace the `ACCESS_KEY_HERE` and `SECRET_KEY_HERE` with your
|
||||||
AWS access key and secret key, available from
|
AWS access key and secret key, available from
|
||||||
[this page](https://console.aws.amazon.com/iam/home?#security_credential).
|
[this page](https://console.aws.amazon.com/iam/home?#security_credential).
|
||||||
@ -95,7 +99,7 @@ Within the resource block itself is configuration for that
|
|||||||
resource. This is dependent on each resource provider and
|
resource. This is dependent on each resource provider and
|
||||||
is fully documented within our
|
is fully documented within our
|
||||||
[providers reference](/docs/providers/index.html). For our EC2 instance, we specify
|
[providers reference](/docs/providers/index.html). For our EC2 instance, we specify
|
||||||
an AMI for Ubuntu, and request a "t1.micro" instance so we
|
an AMI for Ubuntu, and request a "t2.micro" instance so we
|
||||||
qualify under the free tier.
|
qualify under the free tier.
|
||||||
|
|
||||||
## Execution Plan
|
## Execution Plan
|
||||||
@ -111,16 +115,24 @@ $ terraform plan
|
|||||||
...
|
...
|
||||||
|
|
||||||
+ aws_instance.example
|
+ aws_instance.example
|
||||||
ami: "" => "ami-408c7f28"
|
ami: "ami-0d729a60"
|
||||||
availability_zone: "" => "<computed>"
|
availability_zone: "<computed>"
|
||||||
instance_type: "" => "t1.micro"
|
ebs_block_device.#: "<computed>"
|
||||||
key_name: "" => "<computed>"
|
ephemeral_block_device.#: "<computed>"
|
||||||
private_dns: "" => "<computed>"
|
instance_state: "<computed>"
|
||||||
private_ip: "" => "<computed>"
|
instance_type: "t2.micro"
|
||||||
public_dns: "" => "<computed>"
|
key_name: "<computed>"
|
||||||
public_ip: "" => "<computed>"
|
placement_group: "<computed>"
|
||||||
security_groups: "" => "<computed>"
|
private_dns: "<computed>"
|
||||||
subnet_id: "" => "<computed>"
|
private_ip: "<computed>"
|
||||||
|
public_dns: "<computed>"
|
||||||
|
public_ip: "<computed>"
|
||||||
|
root_block_device.#: "<computed>"
|
||||||
|
security_groups.#: "<computed>"
|
||||||
|
source_dest_check: "true"
|
||||||
|
subnet_id: "<computed>"
|
||||||
|
tenancy: "<computed>"
|
||||||
|
vpc_security_group_ids.#: "<computed>"
|
||||||
```
|
```
|
||||||
|
|
||||||
`terraform plan` shows what changes Terraform will apply to
|
`terraform plan` shows what changes Terraform will apply to
|
||||||
@ -148,8 +160,12 @@ since Terraform waits for the EC2 instance to become available.
|
|||||||
```
|
```
|
||||||
$ terraform apply
|
$ terraform apply
|
||||||
aws_instance.example: Creating...
|
aws_instance.example: Creating...
|
||||||
ami: "" => "ami-408c7f28"
|
ami: "" => "ami-0d729a60"
|
||||||
instance_type: "" => "t1.micro"
|
instance_type: "" => "t2.micro"
|
||||||
|
[...]
|
||||||
|
|
||||||
|
aws_instance.example: Still creating... (10s elapsed)
|
||||||
|
aws_instance.example: Creation complete
|
||||||
|
|
||||||
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
|
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
|
||||||
|
|
||||||
@ -171,18 +187,17 @@ You can inspect the state using `terraform show`:
|
|||||||
```
|
```
|
||||||
$ terraform show
|
$ terraform show
|
||||||
aws_instance.example:
|
aws_instance.example:
|
||||||
id = i-e60900cd
|
id = i-32cf65a8
|
||||||
ami = ami-408c7f28
|
ami = ami-0d729a60
|
||||||
availability_zone = us-east-1c
|
availability_zone = us-east-1a
|
||||||
instance_type = t1.micro
|
instance_state = running
|
||||||
key_name =
|
instance_type = t2.micro
|
||||||
private_dns = domU-12-31-39-12-38-AB.compute-1.internal
|
private_ip = 172.31.30.244
|
||||||
private_ip = 10.200.59.89
|
public_dns = ec2-52-90-212-55.compute-1.amazonaws.com
|
||||||
public_dns = ec2-54-81-21-192.compute-1.amazonaws.com
|
public_ip = 52.90.212.55
|
||||||
public_ip = 54.81.21.192
|
subnet_id = subnet-1497024d
|
||||||
security_groups.# = 1
|
vpc_security_group_ids.# = 1
|
||||||
security_groups.0 = default
|
vpc_security_group_ids.3348721628 = sg-67652003
|
||||||
subnet_id =
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can see that by creating our resource, we've also gathered
|
You can see that by creating our resource, we've also gathered
|
||||||
|
@ -28,13 +28,15 @@ resource in your configuration and change it to the following:
|
|||||||
|
|
||||||
```
|
```
|
||||||
resource "aws_instance" "example" {
|
resource "aws_instance" "example" {
|
||||||
ami = "ami-b8b061d0"
|
ami = "ami-13be557e"
|
||||||
instance_type = "t1.micro"
|
instance_type = "t2.micro"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
We've changed the AMI from being an Ubuntu 14.04 AMI to being
|
~> **Note:** EC2 Classic users please use AMI `ami-2106ed4c` and type `t1.micro`
|
||||||
an Ubuntu 12.04 AMI. Terraform configurations are meant to be
|
|
||||||
|
We've changed the AMI from being an Ubuntu 14.04 LTS AMI to being
|
||||||
|
an Ubuntu 16.04 LTS AMI. Terraform configurations are meant to be
|
||||||
changed like this. You can also completely remove resources
|
changed like this. You can also completely remove resources
|
||||||
and Terraform will know to destroy the old one.
|
and Terraform will know to destroy the old one.
|
||||||
|
|
||||||
@ -47,15 +49,18 @@ $ terraform plan
|
|||||||
...
|
...
|
||||||
|
|
||||||
-/+ aws_instance.example
|
-/+ aws_instance.example
|
||||||
ami: "ami-408c7f28" => "ami-b8b061d0" (forces new resource)
|
ami: "ami-0d729a60" => "ami-13be557e" (forces new resource)
|
||||||
availability_zone: "us-east-1c" => "<computed>"
|
availability_zone: "us-east-1a" => "<computed>"
|
||||||
key_name: "" => "<computed>"
|
ebs_block_device.#: "0" => "<computed>"
|
||||||
private_dns: "domU-12-31-39-12-38-AB.compute-1.internal" => "<computed>"
|
ephemeral_block_device.#: "0" => "<computed>"
|
||||||
private_ip: "10.200.59.89" => "<computed>"
|
instance_state: "running" => "<computed>"
|
||||||
public_dns: "ec2-54-81-21-192.compute-1.amazonaws.com" => "<computed>"
|
instance_type: "t2.micro" => "t2.micro"
|
||||||
public_ip: "54.81.21.192" => "<computed>"
|
private_dns: "ip-172-31-17-94.ec2.internal" => "<computed>"
|
||||||
security_groups: "" => "<computed>"
|
private_ip: "172.31.17.94" => "<computed>"
|
||||||
subnet_id: "" => "<computed>"
|
public_dns: "ec2-54-82-183-4.compute-1.amazonaws.com" => "<computed>"
|
||||||
|
public_ip: "54.82.183.4" => "<computed>"
|
||||||
|
subnet_id: "subnet-1497024d" => "<computed>"
|
||||||
|
vpc_security_group_ids.#: "1" => "<computed>"
|
||||||
```
|
```
|
||||||
|
|
||||||
The prefix "-/+" means that Terraform will destroy and recreate
|
The prefix "-/+" means that Terraform will destroy and recreate
|
||||||
@ -77,11 +82,33 @@ the change.
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ terraform apply
|
$ terraform apply
|
||||||
|
aws_instance.example: Refreshing state... (ID: i-64c268fe)
|
||||||
aws_instance.example: Destroying...
|
aws_instance.example: Destroying...
|
||||||
aws_instance.example: Modifying...
|
aws_instance.example: Destruction complete
|
||||||
ami: "ami-408c7f28" => "ami-b8b061d0"
|
aws_instance.example: Creating...
|
||||||
|
ami: "" => "ami-13be557e"
|
||||||
|
availability_zone: "" => "<computed>"
|
||||||
|
ebs_block_device.#: "" => "<computed>"
|
||||||
|
ephemeral_block_device.#: "" => "<computed>"
|
||||||
|
instance_state: "" => "<computed>"
|
||||||
|
instance_type: "" => "t2.micro"
|
||||||
|
key_name: "" => "<computed>"
|
||||||
|
placement_group: "" => "<computed>"
|
||||||
|
private_dns: "" => "<computed>"
|
||||||
|
private_ip: "" => "<computed>"
|
||||||
|
public_dns: "" => "<computed>"
|
||||||
|
public_ip: "" => "<computed>"
|
||||||
|
root_block_device.#: "" => "<computed>"
|
||||||
|
security_groups.#: "" => "<computed>"
|
||||||
|
source_dest_check: "" => "true"
|
||||||
|
subnet_id: "" => "<computed>"
|
||||||
|
tenancy: "" => "<computed>"
|
||||||
|
vpc_security_group_ids.#: "" => "<computed>"
|
||||||
|
aws_instance.example: Still creating... (10s elapsed)
|
||||||
|
aws_instance.example: Still creating... (20s elapsed)
|
||||||
|
aws_instance.example: Creation complete
|
||||||
|
|
||||||
Apply complete! Resources: 0 added, 1 changed, 1 destroyed.
|
Apply complete! Resources: 1 added, 0 changed, 1 destroyed.
|
||||||
|
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
@ -59,24 +59,35 @@ will look something like the following:
|
|||||||
|
|
||||||
```
|
```
|
||||||
$ terraform plan
|
$ terraform plan
|
||||||
...
|
|
||||||
|
|
||||||
+ aws_eip.ip
|
+ aws_eip.ip
|
||||||
instance: "" => "${aws_instance.example.id}"
|
allocation_id: "<computed>"
|
||||||
private_ip: "" => "<computed>"
|
association_id: "<computed>"
|
||||||
public_ip: "" => "<computed>"
|
domain: "<computed>"
|
||||||
|
instance: "${aws_instance.example.id}"
|
||||||
|
network_interface: "<computed>"
|
||||||
|
private_ip: "<computed>"
|
||||||
|
public_ip: "<computed>"
|
||||||
|
|
||||||
+ aws_instance.example
|
+ aws_instance.example
|
||||||
ami: "" => "ami-b8b061d0"
|
ami: "ami-13be557e"
|
||||||
availability_zone: "" => "<computed>"
|
availability_zone: "<computed>"
|
||||||
instance_type: "" => "t1.micro"
|
ebs_block_device.#: "<computed>"
|
||||||
key_name: "" => "<computed>"
|
ephemeral_block_device.#: "<computed>"
|
||||||
private_dns: "" => "<computed>"
|
instance_state: "<computed>"
|
||||||
private_ip: "" => "<computed>"
|
instance_type: "t2.micro"
|
||||||
public_dns: "" => "<computed>"
|
key_name: "<computed>"
|
||||||
public_ip: "" => "<computed>"
|
placement_group: "<computed>"
|
||||||
security_groups: "" => "<computed>"
|
private_dns: "<computed>"
|
||||||
subnet_id: "" => "<computed>"
|
private_ip: "<computed>"
|
||||||
|
public_dns: "<computed>"
|
||||||
|
public_ip: "<computed>"
|
||||||
|
root_block_device.#: "<computed>"
|
||||||
|
security_groups.#: "<computed>"
|
||||||
|
source_dest_check: "true"
|
||||||
|
subnet_id: "<computed>"
|
||||||
|
tenancy: "<computed>"
|
||||||
|
vpc_security_group_ids.#: "<computed>"
|
||||||
```
|
```
|
||||||
|
|
||||||
Terraform will create two resources: the instance and the elastic
|
Terraform will create two resources: the instance and the elastic
|
||||||
@ -89,11 +100,22 @@ Next, run `terraform apply`. The output will look similar to the
|
|||||||
following:
|
following:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
$ terraform apply
|
||||||
aws_instance.example: Creating...
|
aws_instance.example: Creating...
|
||||||
ami: "" => "ami-b8b061d0"
|
ami: "" => "ami-13be557e"
|
||||||
instance_type: "" => "t1.micro"
|
instance_type: "" => "t2.micro"
|
||||||
|
[..]
|
||||||
|
aws_instance.example: Still creating... (10s elapsed)
|
||||||
|
aws_instance.example: Creation complete
|
||||||
aws_eip.ip: Creating...
|
aws_eip.ip: Creating...
|
||||||
instance: "" => "i-0e737b25"
|
allocation_id: "" => "<computed>"
|
||||||
|
association_id: "" => "<computed>"
|
||||||
|
domain: "" => "<computed>"
|
||||||
|
instance: "" => "i-f3d77d69"
|
||||||
|
network_interface: "" => "<computed>"
|
||||||
|
private_ip: "" => "<computed>"
|
||||||
|
public_ip: "" => "<computed>"
|
||||||
|
aws_eip.ip: Creation complete
|
||||||
|
|
||||||
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
|
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
|
||||||
```
|
```
|
||||||
@ -144,8 +166,8 @@ created in parallel to everything else.
|
|||||||
|
|
||||||
```
|
```
|
||||||
resource "aws_instance" "another" {
|
resource "aws_instance" "another" {
|
||||||
ami = "ami-b8b061d0"
|
ami = "ami-13be557e"
|
||||||
instance_type = "t1.micro"
|
instance_type = "t2.micro"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ To define a provisioner, modify the resource block defining the
|
|||||||
|
|
||||||
```
|
```
|
||||||
resource "aws_instance" "example" {
|
resource "aws_instance" "example" {
|
||||||
ami = "ami-b8b061d0"
|
ami = "ami-13be557e"
|
||||||
instance_type = "t1.micro"
|
instance_type = "t2.micro"
|
||||||
|
|
||||||
provisioner "local-exec" {
|
provisioner "local-exec" {
|
||||||
command = "echo ${aws_instance.example.public_ip} > file.txt"
|
command = "echo ${aws_instance.example.public_ip} > file.txt"
|
||||||
@ -61,8 +61,8 @@ then run `apply`:
|
|||||||
```
|
```
|
||||||
$ terraform apply
|
$ terraform apply
|
||||||
aws_instance.example: Creating...
|
aws_instance.example: Creating...
|
||||||
ami: "" => "ami-b8b061d0"
|
ami: "" => "ami-13be557e"
|
||||||
instance_type: "" => "t1.micro"
|
instance_type: "" => "t2.micro"
|
||||||
aws_eip.ip: Creating...
|
aws_eip.ip: Creating...
|
||||||
instance: "" => "i-213f350a"
|
instance: "" => "i-213f350a"
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ support for the "us-west-2" region as well:
|
|||||||
variable "amis" {
|
variable "amis" {
|
||||||
type = "map"
|
type = "map"
|
||||||
default = {
|
default = {
|
||||||
us-east-1 = "ami-b8b061d0"
|
us-east-1 = "ami-13be557e"
|
||||||
us-west-2 = "ami-ef5e24df"
|
us-west-2 = "ami-06b94666"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -138,7 +138,7 @@ Then, replace the "aws\_instance" with the following:
|
|||||||
```
|
```
|
||||||
resource "aws_instance" "example" {
|
resource "aws_instance" "example" {
|
||||||
ami = "${lookup(var.amis, var.region)}"
|
ami = "${lookup(var.amis, var.region)}"
|
||||||
instance_type = "t1.micro"
|
instance_type = "t2.micro"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user