【问题标题】:Terraform getting UnsupportedOperation: Microsoft SQL when trying to start an amazon-linux instanceTerraform 获得 UnsupportedOperation:Microsoft SQL 尝试启动 amazon-linux 实例时
【发布时间】:2021-05-29 22:51:39
【问题描述】:

我正在尝试使用 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 没有任何关系,我无法理解为什么会出现此错误。

【问题讨论】:

    标签: amazon-web-services terraform amazon-linux


    【解决方案1】:

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

    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$"
    }
    

    【讨论】:

    • 只是得到同样的错误。我的代码现在看起来像这样:` provider "aws" { version = "~> 2.0" region = "us-east-1" } resource "aws_instance" "dev" { ami = "${data.aws_ami.latest_amazon_2.id }" instance_type = "t2.micro" key_name = "terraform-dati" tags = { "Name" = "dev-terraform" } } data "aws_ami" "latest_amazon_2" { most_recent = true owner = ["amazon"] name_regex = "^amzn2-ami-hvm-.*x86_64-gp2" } `
    • @ArthurÁvila 哇。你是对的。我提供的数据源是我个人使用的,现在我看到它停止工作了。请给我一点时间来检查发生了什么。
    • @ArthurÁvila 抱歉让您久等了。我更新了name_regex
    • 很棒的伙伴!刚刚工作正常!谢谢你!
    • @ArthurÁvila 没问题。很高兴它解决了:-)
    猜你喜欢
    • 1970-01-01
    • 2014-05-03
    • 2011-08-25
    • 2020-03-10
    • 2011-11-12
    • 2017-10-15
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多