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

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.
主站蜘蛛池模板: 河曲县| 霍山县| 南丹县| 大宁县| 长岛县| 翼城县| 奉新县| 濮阳县| 太康县| 大方县| 邛崃市| 湖州市| 汉中市| 马公市| 临清市| 乐都县| 台南市| 威远县| 北安市| 双桥区| 麻城市| 威远县| 神池县| 略阳县| 阿荣旗| 铁力市| 太保市| 灵璧县| 儋州市| 和田市| 拜城县| 广水市| 赣榆县| 化州市| 福贡县| 嵊泗县| 淮滨县| 米泉市| 尼玛县| 南康市| 乌鲁木齐市|