【问题标题】:How to read ami id dynamically from aws using cloudformation如何使用 cloudformation 从 aws 动态读取 ami id
【发布时间】:2020-02-13 00:23:13
【问题描述】:

我通过从相应区域读取最新的 ami id 来自动化 cloudformation 模板。我能够通过使用 terraform 来实现这一点。

在 terraform 中,我们有数据源来查询和过滤 aws ami-id。同样,我们在 cloudformation 中是否有任何来源来查询和过滤私有 aws ami-id?

在 terraform 中,我们可以使用下面的方式获取 ami id

data "aws_ami" "example" {
  executable_users = ["self"]
  most_recent      = true
  name_regex       = "^myami-\\d{3}"
  owners           = ["self"]

  filter {
    name   = "name"
    values = ["myami-*"]
  }

  filter {
    name   = "root-device-type"
    values = ["ebs"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }
}

然而,谁能帮助我使用 cloudformation 模板做同样的事情?

提前致谢:)

【问题讨论】:

    标签: amazon-cloudformation


    【解决方案1】:

    本演练向您展示如何创建自定义资源并将 Lambda 函数与其关联以查找 AMI ID。

    https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/walkthrough-custom-resources-lambda-lookup-amiids.html

    【讨论】:

    • 我必须使用 cloudformation 从一个 lambda 函数中读取两个 ami id。有没有办法从 cloudformation 中的 lambda 函数读取两个不同的 ami id?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多