mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-03 04:10:28 -06:00
website: started updating examples
This commit is contained in:
parent
5f6fe1f931
commit
d7e77202ba
@ -9,7 +9,7 @@ sidebar_current: "examples-aws"
|
||||
This provides a template for running a simple two-tier architecture on Amazon
|
||||
Web services.
|
||||
|
||||
The basic premise is you have stateless app servers running behind
|
||||
The premise is that you have stateless app servers running behind
|
||||
an ELB serving traffic.
|
||||
|
||||
To simplify the example, this intentionally ignores deploying and
|
||||
@ -22,26 +22,14 @@ After you run `terraform apply` on this configuration, it will
|
||||
automatically output the DNS address of the ELB. After your instance
|
||||
registers, this should respond with the default nginx web page.
|
||||
|
||||
The configuration file contains comments describing each
|
||||
resource.
|
||||
|
||||
## Command
|
||||
|
||||
```
|
||||
terraform apply \
|
||||
-var 'aws_access_key=YOUR_ACCESS_KEY' \
|
||||
-var 'aws_secret_key=YOUR_SECRET_KEY' \
|
||||
-var 'key_path=/path/to/key/pair.pem' \
|
||||
-var 'key_name=keypair-name'
|
||||
```
|
||||
As with all examples, just copy and paste the example and run
|
||||
`terraform apply` to see it work.
|
||||
|
||||
## Configuration
|
||||
|
||||
```
|
||||
variable "aws_access_key" {}
|
||||
variable "aws_secret_key" {}
|
||||
variable "key_path" {}
|
||||
variable "key_name" {}
|
||||
variable "key_path" {}
|
||||
variable "aws_region" {
|
||||
default = "us-west-2"
|
||||
}
|
||||
@ -58,8 +46,6 @@ variable "aws_amis" {
|
||||
|
||||
# Specify the provider and access details
|
||||
provider "aws" {
|
||||
access_key = "${var.aws_access_key}"
|
||||
secret_key = "${var.aws_secret_key}"
|
||||
region = "${var.aws_region}"
|
||||
}
|
||||
|
||||
@ -106,16 +92,6 @@ resource "aws_elb" "web" {
|
||||
|
||||
|
||||
resource "aws_instance" "web" {
|
||||
# The connection block tells our provisioner how to
|
||||
# communicate with the resource (instance)
|
||||
connection {
|
||||
# The default username for our AMI
|
||||
user = "ubuntu"
|
||||
|
||||
# The path to your keyfile
|
||||
key_file = "${var.key_path}"
|
||||
}
|
||||
|
||||
instance_type = "m1.small"
|
||||
|
||||
# Lookup the correct AMI based on the region
|
||||
@ -132,6 +108,16 @@ resource "aws_instance" "web" {
|
||||
# Our Security group to allow HTTP and SSH access
|
||||
security_groups = ["${aws_security_group.default.name}"]
|
||||
|
||||
# The connection block tells our provisioner how to
|
||||
# communicate with the resource (instance)
|
||||
connection {
|
||||
# The default username for our AMI
|
||||
user = "ubuntu"
|
||||
|
||||
# The path to your keyfile
|
||||
key_file = "${var.key_path}"
|
||||
}
|
||||
|
||||
# We run a remote provisioner on the instance after creating it.
|
||||
# In this case, we just install nginx and start it. By default,
|
||||
# this should be on port 80
|
||||
|
@ -9,14 +9,15 @@ sidebar_current: "examples"
|
||||
These examples are designed to help you understand some
|
||||
of the ways Terraform can be used.
|
||||
|
||||
Other than configuring the provider (with, for example, an API key),
|
||||
the examples are ready to run as-is.
|
||||
|
||||
All examples in this section are ready to run as-is. Terraform will
|
||||
ask for input of things such as variables and API keys. If you want to
|
||||
conitnue using the example, you should save those parameters in a
|
||||
"terraform.tfvars" file or in a `provider` config bock.
|
||||
|
||||
<div class="alert alert-block alert-warning">
|
||||
<div>
|
||||
<strong>Note:</strong> The examples use real providers that launch
|
||||
<strong>real</strong> resources. That means they can cost money to
|
||||
<em>real</em> resources. That means they can cost money to
|
||||
experiment with. To avoid unexpected charges, be sure to understand the price
|
||||
of resources before launching them, and verify any unneeded resources
|
||||
are cleaned up afterwards.</div>
|
||||
|
Loading…
Reference in New Issue
Block a user