【问题标题】:Terraform - Can't install "aws linux ami" using t2.micro instance typeTerraform - 无法使用 t2.micro 实例类型安装“aws linux ami”
【发布时间】:2019-03-27 03:58:06
【问题描述】:

我正在尝试使用 t2.micro 的实例类型从北弗吉尼亚安装“aws linux ami”ami,但我找不到虚拟化类型为“hvm”的“aws linux ami”的 ami(我发现仅 pv 型)。有没有办法安装t2类型的“aws linux ami”?

我运行了以下 tf:

provider "aws" {
  access_key = "AKIAJHBBU5KDBVL26TBA"
  secret_key = "E3L4+tuTxQKdf+iD3wbWHg6FsHxB+9169ZT7Q4NL"
  region     = "us-east-1"
}

resource "aws_instance" "example" {
  ami           = "ami-2d387344"
  instance_type = "t2.micro"
}

* 这是我在弗吉尼亚北部为“aws linux ami”找到的唯一 ami,但它是 "Virtualization type: paravirtual",所以我收到以下错误:

 aws_instance.example: Error launching source instance: InvalidParameterCombination: Virtualization type 'hvm' is required for instances of type 't2.micro'.

只有当我使用t1.micro 时,它才有效。

我是 AWS 的新手,是我遗漏了什么,还是真的无法运行 t2 类型的“aws linux ami”?

【问题讨论】:

    标签: amazon-web-services amazon-ec2 amazon-ami


    【解决方案1】:

    您可以使用 AWS cli 搜索 AMI ID:

    aws ec2 --profile prof describe-images 
    --owners amazon
    --filters 
    'Name=name,Values=amzn2-ami-hvm-2.0.????????-x86_64-gp2' 'Name=state,Values=available'
    --output json | jq -r '.Images | sort_by(.CreationDate) | last(.[]).ImageId'
    

    这会返回:

    ami-09def150731bdbcc2

    为您的用例传递 --region us-east-1 为好。

    【讨论】:

    • 真的吗?!这看起来过于复杂的方式来获取图像。附:我尝试使用 ami-09def150731bdbcc2,但我得到“图像 id 不存在”。
    • 您还没有阅读我写的内容:“对于您的用例,请同时传入 --region us-east-1。”您的图像 ID 是:ami-0de53d8956e8dcf80
    猜你喜欢
    • 2020-08-08
    • 2018-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-13
    • 2014-09-05
    • 1970-01-01
    相关资源
    最近更新 更多