简体   繁体   English

如何在 Cloudformation Yaml 文件上获取最新版本的 SSM 参数

[英]How to fetch latest version of SSM parameter on Cloudformation Yaml file

I have a Cloudformation Yaml file where it creates a lot of resources, one of them is an EC2 with Windows.我有一个 Cloudformation Yaml 文件,它在其中创建了大量资源,其中之一是带有 Windows 的 EC2。 My problem is I need to have this automated selection of the latest AMI, I made a Lambda function where it retrieves newest AMI ID and stores in an SSM parameter, then using the Cloudformation with YAML template I can access to ssm using the following command我的问题是我需要自动选择最新的 AMI,我创建了一个 Lambda 函数,它检索最新的 AMI ID 并存储在 SSM 参数中,然后使用带有 YAML 模板的 Cloudformation 我可以使用以下命令访问 ssm

{{resolve:ssm:parameter_name:version_number_int}}

but my problem is that it's not always the same version number, it will be changed everytime when there will be a new AMI, is there any method where I can write to get always the latest version?但我的问题是它并不总是相同的版本号,每次有新的 AMI 时都会更改它,有什么方法可以让我编写始终获得最新版本? or to stop versioning or anything?或停止版本控制或其他什么?

Thanks.谢谢。

SSM Parameter Store provides public parameters to retrieve latest AMIs. SSM Parameter Store 提供公共参数来检索最新的 AMI。

# Use public Systems Manager Parameter
Parameters:
  LatestAmiId:
    Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
    Default: '/aws/service/ami-windows-latest/Windows_Server-2019-English-Full-Base'

Resources:
 Instance:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: !Ref LatestAmiId

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Cloudformation 到 terraform 转换 SSM 参数 - Cloudformation to terraform conversion of SSM parameter 带有CloudFormation的AWS SSM参数存储 - AWS SSM Parameter Store with CloudFormation 如何在 Cloudformation 模板条件中使用 AWS SSM 参数存储值? - How to use AWS SSM parameter store values in Cloudformation template conditionals? Cloudformation 堆栈默认参数 SSM 参数存储 - Cloudformation stack default parameter SSM Parameter store 如何在cloudformation yml中获取最新的lambda版本? - How to get the latest lambda version in cloudformation yml? 将安全 SSM 参数传递给嵌套的 CloudFormation 堆栈 - Pass secure SSM parameter to a nested CloudFormation stack 在 Cloudformation 的 SSM Parameter Store 中创建 JSON 值 - Create JSON value in SSM Parameter Store in Cloudformation 如何在cloudformation yaml文件中指定使用参数值,否则如何通过FindInMap使用默认值 - How can I specify in cloudformation yaml file to use parameter value otherwise a default via FindInMap 如何识别 Cloudformation yaml 文件上的错误配置 - How to identify the misconfiguration on this yaml file for Cloudformation AWS/Cloudformation:如何将参数值导出/导入到另一个堆栈 (YAML) - AWS/Cloudformation: How to export/import parameter value to another stack (YAML)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM