You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在CloudFormation资源中直接使用默认SSM参数值?

直接在CloudFormation资源中引用SSM参数值的方法

你可以使用CloudFormation内置的!GetParameter函数,跳过Parameters部分的定义,直接在资源配置中获取目标SSM参数的镜像ID值。

示例代码(以EC2实例资源为例):

Resources:
  MyEC2Instance:
    Type: AWS::EC2::Instance
    Properties:
      ImageId: !GetParameter '/aws/service/canonical/ubuntu/server/jammy/stable/current/arm64/hvm/ebs-gp2/ami-id'
      InstanceType: t4g.micro
      # 按需添加其他实例属性

注意事项

  • 执行CloudFormation栈的角色必须具备ssm:GetParameter权限,否则会因权限不足无法获取参数值。
  • 如果需要指定特定版本的SSM参数,可使用带版本参数的写法:!GetParameter [参数路径, Version=目标版本号]

内容的提问来源于stack exchange,提问作者shantanuo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 12:54:51