boto3 的 UpdateAutoScalingGroup 权限错误

发布于 2025-01-10 10:32:04 字数 1575 浏览 0 评论 0原文

我在运行此脚本时遇到错误:

def set_asg_launch_template_version_latest(asg_name, lt_id):
    try:
        response = client.update_auto_scaling_group(
            AutoScalingGroupName=asg_name,
            LaunchTemplate={
                'LaunchTemplateId': lt_id,
                'Version': '$Latest'
            }
        )
        print("Set launch template: {} version for asg: {} to $Latest".format(lt_id, asg_name))
        return response
    except ClientError as e:
        print('Error setting launch template version to $Latest')
        raise e
set_asg_launch_template_version_latest(ASGName,launch_template_id )

============> ClientError - 调用 UpdateAutoScalingGroup 操作时发生错误 (AccessDenied):您无权使用启动模板:lt-xxxxxxxxx

提示: 所有这些权限均已授权(检查最后一项):

        - resource-groups:ListGroupResources
        - tag:GetResources
        - s3:PutObject
        - s3:PutObjectAcl
        - s3:List*
        - ec2:Describe*
        - ec2:CreateSnapshot
        - ec2:CreateImage
        - kms:CreateGrant
        - ec2:StartInstances
        - ec2:RunInstances
        - ec2:TerminateInstances
        - autoscaling:StartInstanceRefresh
        - ec2:CreateSecurityGroup
        - ec2:AuthorizeSecurityGroupEgress
        - ec2:DeleteSecurityGroup
        - ec2:RevokeSecurityGroupEgress
        - ec2:ModifyLaunchTemplate
        - ec2:CreateLaunchTemplateVersion
        - autoscaling:Describe*
        - ec2:DescribeLaunchTemplateVersions
        - ec2:DescribeLaunchTemplates
        - autoscaling:UpdateAutoScalingGroup

i am getting error while running this script :

def set_asg_launch_template_version_latest(asg_name, lt_id):
    try:
        response = client.update_auto_scaling_group(
            AutoScalingGroupName=asg_name,
            LaunchTemplate={
                'LaunchTemplateId': lt_id,
                'Version': '$Latest'
            }
        )
        print("Set launch template: {} version for asg: {} to $Latest".format(lt_id, asg_name))
        return response
    except ClientError as e:
        print('Error setting launch template version to $Latest')
        raise e
set_asg_launch_template_version_latest(ASGName,launch_template_id )

============>
ClientError - An error occurred (AccessDenied) when calling the UpdateAutoScalingGroup operation: You are not authorized to use launch template: lt-xxxxxxxxx

hint :
all these permissions are authorized (check last one):

        - resource-groups:ListGroupResources
        - tag:GetResources
        - s3:PutObject
        - s3:PutObjectAcl
        - s3:List*
        - ec2:Describe*
        - ec2:CreateSnapshot
        - ec2:CreateImage
        - kms:CreateGrant
        - ec2:StartInstances
        - ec2:RunInstances
        - ec2:TerminateInstances
        - autoscaling:StartInstanceRefresh
        - ec2:CreateSecurityGroup
        - ec2:AuthorizeSecurityGroupEgress
        - ec2:DeleteSecurityGroup
        - ec2:RevokeSecurityGroupEgress
        - ec2:ModifyLaunchTemplate
        - ec2:CreateLaunchTemplateVersion
        - autoscaling:Describe*
        - ec2:DescribeLaunchTemplateVersions
        - ec2:DescribeLaunchTemplates
        - autoscaling:UpdateAutoScalingGroup

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文