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

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.
主站蜘蛛池模板: 宝清县| 陕西省| 图们市| 绥中县| 兴宁市| 昌图县| 普定县| 海城市| 金沙县| 同德县| 宝山区| 南漳县| 丹棱县| 资阳市| 正蓝旗| 安远县| 绥阳县| 贺兰县| 河东区| 定襄县| 沿河| 伊春市| 沧州市| 鄂尔多斯市| 湘阴县| 恩施市| 开封市| 庄浪县| 莱阳市| 星座| 海晏县| 岑溪市| 孝义市| 衡东县| 乾安县| 海南省| 奉新县| 库伦旗| 分宜县| 塔城市| 交口县|