【问题标题】:Deleting expired AWS Hybrid Activations删除过期的 AWS 混合激活
【发布时间】:2020-07-28 03:29:40
【问题描述】:

以下代码基于 boto3 / API 文档,它会打印应删除的内容,但不会删除 Hybrid 激活,也不会产生错误。你能帮我确定为什么激活没有被删除吗?

import boto3
client = boto3.client('ssm')
response = client.describe_activations(
    Filters=[
        {
            'FilterKey': 'IamRole',
            'FilterValues': [
                'MySSMServiceRole'
            ]
        }
    ]
)

print('\n  These Hybrid Activations were deleted:')
for x in response['ActivationList']:
    a = x['ActivationId']
    b = x['Description'][0:3]
    c = x['Expired']
    if c == 'True':
        delete_activation(
            {
                'ActivationList': a
            }
        )
    print('     {}  {}  {}'.format(a, b, c))

我最初是用它来尝试删除过期的激活,但得到了相同的结果。

response = client.delete_activation(
    ActivationId = a
)

【问题讨论】:

    标签: python-3.x amazon-web-services aws-lambda boto3 ssm


    【解决方案1】:

    我更改了 if 语句以使用 c 变量并且它起作用了。原始 if 语句将字符串与布尔值进行比较,以及为什么它不起作用。

    if c:
        client.delete_activation(
            ActivationId = a
        )
    

    【讨论】:

      猜你喜欢
      • 2021-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-06
      • 2018-08-28
      • 1970-01-01
      • 2014-06-07
      • 2014-11-29
      相关资源
      最近更新 更多