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

Regions

So far, all of our work has been done in the US-East region of AWS. The following map shows that there are a few other options too:  https://aws.amazon.com/about-aws/global-infrastructure/.

To increase the availability of our product, we'll add another region at the bottom of our main.tf file:

provider "aws" {
region = "us-west-2"
alias = "west"
}

A new VPC will allow us to further isolate our resources from tenants within our own organization. Let's create a vpc.tf file as follows. We'll keep the network address space the same for simplicity for the moment:

resource "aws_vpc" "mainvpc" {
cidr_block = "10.1.0.0/16"
}

resource "aws_vpc" "mainvpc_west" {
provider = "aws.west"
cidr_block = "10.2.0.0/16"
}

Now, let's create some new instance resources. We will use the same base AMI in both areas, but put these virtual machines in different regions, also in vpc.tf:

# Virginia
resource "aws_instance" "cheap_worker" {
# the below ami is for the latest Bitnami Wordpress East
ami = "ami-001e1c1159ccfe992"
instance_type = "t2.micro"
availability_zone = "us-east-1d"
associate_public_ip_address = true

tags {
Name = "CheapWorker"
}
}
output "id" {
value = "${aws_instance.cheap_worker.id}"
}
output "ip" {
value = "${aws_instance.cheap_worker.public_ip}"
}

# Oregon
resource "aws_instance" "cheap_worker_west" {
# the below ami is for the latest Bitnami Wordpress West
ami = "ami-000ce50ab0df5943f"
provider = "aws.west"
instance_type = "t2.micro"
availability_zone = "us-west-2c"
associate_public_ip_address = true

tags {
Name = "CheapWorker"
}
}
output "id_west" {
value = "${aws_instance.cheap_worker_west.id}"
}
output "ip_west" {
value = "${aws_instance.cheap_worker_west.public_ip}"
}
Notice that, even though we are using the same version of WordPress provided by Bitnami, the AMIs are different in the east and west catalogs.
主站蜘蛛池模板: 五常市| 三台县| 温宿县| 隆回县| 定安县| 马边| 卢湾区| 齐河县| 阿坝县| 鲜城| 壶关县| 平陆县| 共和县| 桑植县| 德保县| 绿春县| 那曲县| 新津县| 临沂市| 无锡市| 乌兰浩特市| 道孚县| 夏邑县| 闸北区| 石阡县| 永年县| 汉寿县| 高碑店市| 吉安市| 盐池县| 晋江市| 临泽县| 手游| 象州县| 天峻县| 开原市| 东安县| 谢通门县| 静海县| 太湖县| 云浮市|