在 aws cloudformation 模板中引用 "Self"?

Reference "Self" in aws cloudformation template?

我在 Cloudformation 中定义了一个 EC2 资源,如下所示:

Resources:
  FooInstance:
    Type: 'AWS::EC2::Instance'
    Properties:
      blah: blah
      blah: blah
      UserData:
        Fn::Base64: !Sub |
            #!/bin/bash
            /opt/aws/bin/cfn-init --stack ${AWS::StackId} --resource FooInstance --region ${AWS::Region}

在那个 UserData cfn-init 块中是否有一个特殊的 variable/replacement 字符串来引用 "self" 而不是显式声明 FooInstance?这将有助于让我的团队更容易复制粘贴定义。

谢谢!

很遗憾,没有。对于 UserDataAWS::CloudFormation::Init 部分来说,这将是一个非常好的附加组件,但 AWS 仍然不支持它。