[英]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.