Amazon web services 要使用terraform在vpc下创建两个ec2实例吗
我想通过terraform在vpc下创建两个ec2实例。使用我的代码,我可以轻松地部署vpc、安全组和子网,但在实例部分发现一些错误。你能帮我解决这个问题吗。但“地形规划”命令将成功执行Amazon web services 要使用terraform在vpc下创建两个ec2实例吗,amazon-web-services,terraform,terraform-provider-aws,Amazon Web Services,Terraform,Terraform Provider Aws,我想通过terraform在vpc下创建两个ec2实例。使用我的代码,我可以轻松地部署vpc、安全组和子网,但在实例部分发现一些错误。你能帮我解决这个问题吗。但“地形规划”命令将成功执行 provider "aws" { region = "us-west-2" access_key = "xxxxxxxx" secret_key = "xxxxxxxxxxxxx" } resource &quo
provider "aws" {
region = "us-west-2"
access_key = "xxxxxxxx"
secret_key = "xxxxxxxxxxxxx"
}
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
}
resource "aws_subnet" "public" {
vpc_id = "${aws_vpc.main.id}"
cidr_block = "10.0.1.0/24"
}
resource "aws_security_group" "allow_ssh" {
name = "allow_ssh"
description = "Allow ssh inbound traffic"
vpc_id = "${aws_vpc.main.id}"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "instance"{
ami = "ami-0fc025e3171c5a1bf"
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.allow_ssh.id}"]
subnet_id = "${aws_subnet.public.id}"
}
output "vpc_id" {
value = "${aws_vpc.main.id}"
}
output "subnet_id" {
value = "${aws_subnet.public.id}"
}
output "vpc_security_group_id" {
value = "${aws_security_group.allow_ssh.id}"
}
错误
ami-0fc025e3171c5a1bf适用于arm64体系结构,不适用于t2.micro。如果需要arm平台,则需要使用a1族中的实例类型
否则,您可以使用x86-64版本的Ubuntu Server 18.04 LTS(HVM),使用ami-0d1cd67c26f5fca19的SSD卷。这只是一个愚蠢的观察:在
{
实例中的{
尝试使用aws_实例部分中的空间之前,您不需要一个空间吗?但错误是相同的。谢谢,按照您的建议进行排序。