gpt4 book ai didi

aws-cloudformation - 在 AWS::AutoScaling::AutoScalingGroup 中检索 LaunchTemplate 的 LatestVersionNumber 属性的 IAM 权限

转载 作者:行者123 更新时间:2023-12-03 07:30:36 28 4
gpt4 key购买 nike

在开发 CloudFormation 模板时,我遵循最小权限原则。因此,我为 CloudFormation 提供了一个角色来承担,并且该角色具有最小的权限集。

该模板包含一个 AWS::AutoScaling::AutoScalingGroup,它基于 AWS::EC2::LaunchTemplate:

ECSAutoScalingGroup:
DependsOn: ECSCluster
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier: !Ref Subnets
LaunchTemplate:
LaunchTemplateId: !Ref ECSLaunchTemplate
Version: !GetAtt ECSLaunchTemplate.LatestVersionNumber
MinSize: 1
MaxSize: 2
DesiredCapacity: 1
...

ECSLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Metadata:
AWS::CloudFormation::Init:
...
Properties:
LaunchTemplateName: test-template
LaunchTemplateData:
...

当我从此模板创建 CloudFormation 堆栈时,我在 ECSAutoScalingGroup 资源上收到以下错误:

Failed to retrieve attribute [LatestVersionNumber] for resource[ECSLaunchTemplate]: You are not authorized to perform this operation.(Service: AmazonEC2; Status Code: 403; Error Code:UnauthorizedOperation; Request ID:e0f01fd0-ee2a-4260-94f4-3c65177d05ee; Proxy: null)

我应该将哪个 IAM 策略添加到 CloudFormation 承担的 IAM 角色中?显然,如果我给它AdministratorAccess,它就会成功。但是,我想遵循最小特权原则。

有什么想法吗?谢谢。

最佳答案

在这里回答我自己的问题。应将这 2 项操作添加到其 IAM 角色策略中:

  • ec2:描述启动模板
  • ec2:描述LaunchTemplateVersions

关于aws-cloudformation - 在 AWS::AutoScaling::AutoScalingGroup 中检索 LaunchTemplate 的 LatestVersionNumber 属性的 IAM 权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69831209/

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