Terraform 获得 UnsupportedOperation:尝试启动 amazon-linux 实例时的 Microsoft SQL

问题描述

我正在尝试使用 terraform 和 amazon-linux-2 映像在 aws 上启动一个实例。但是我得到了 Microsoft sql Server 企业版的错误

provider "aws" {
    version = "~> 2.0"
    region = "us-east-1"
}

resource "aws_instance" "dev" {
  ami = "${data.aws_ami.amazon-linux-2.id}"
  instance_type = "t2.micro"
  key_name = "terraform"
  tags = {
    "Name" = "dev-terraform"
  }
}

data "aws_ami" "amazon-linux-2" {
  most_recent = true
  owners = ["amazon"]

  filter {
    name   = "owner-alias"
    values = ["amazon"]
  }
  filter {
    name   = "name"
    values = ["amzn2-ami-hvm*"]
   }
  filter {
    name   = "architecture"
    values = ["x86_64"]
  }
}

错误

Error: Error launching source instance: UnsupportedOperation: Microsoft sql Server Enterprise Edition is not supported for the instance type 't2.micro'.
        status code: 400,request id: 72df60b9-46ac-4616-ab3f-b964ab2f3156

  on main.tf line 6,in resource "aws_instance" "dev":
   6: resource "aws_instance" "dev" {

我与 Microsoft 没有任何关系,我无法理解为什么会出现此错误

解决方法

错误是正确的。您的数据源查询返回:

amzn2-ami-hvm-2.0.20190313-x86_64-gp2-SQL_2017_Enterprise-2021.02.25

请改用以下数据源:

data "aws_ami" "latest_amazon_2" {
  most_recent = true
  owners      = ["amazon"]
  name_regex = "^amzn2-ami-hvm-.*x86_64-gp2$"
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...