gpt4 book ai didi

amazon-web-services - AWS 云信息 : How to use username as a tag

转载 作者:行者123 更新时间:2023-12-03 07:31:46 26 4
gpt4 key购买 nike

我需要为 ec2 实例创建一个 Cloudformation 脚本,该脚本应该具有指定标签,其中包括指定运行脚本来创建实例的人员的 aws 用户名。获取 IAM 用户名的变量名称是什么?我的脚本的标记部分如下所示。虽然可以检索 AccountId,但我无法获取用户名。

    Tags:
- Key: Name
Value: !Ref InstanceName
- Key: team
Value: !Ref Team
- Key: awsAccount
Value: !Sub ${AWS::AccountId}
- Key: userName
Value: !Sub ${AWS::IAM::User}
- Key: purpose
Value: !Ref Purpose

最佳答案

不幸的是,CloudFormation 中没有这样的伪参数。所有可用参数的列表(例如 AWS::AccountId)为 here .

解决这个问题的一种方法是为您的 CloudFormation 模板创建一个参数(就像您对 Purposeteam 所做的那样),例如

Parameters:
UserName:
Type: String

并在您的标签中引用它:

- Key: userName
Value: !Ref UserName

关于amazon-web-services - AWS 云信息 : How to use username as a tag,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62145831/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com