使用boto的clouldformation不列出堆栈的资源

时间:2014-08-20 01:18:37

标签: python amazon-web-services boto

cf_connection = boto.cloudformation.connect_to_region('us-east-1', aws_access_key_id='mykey',
                                                      aws_secret_access_key='mysecret')

resource = cf_connection.list_stack_resources(stack_id)
print resource

此列表不包含物理ID,而是提供逻辑ID和类型 另外我如何过滤此列表

CLI中提供了所有内容

        "StackId": "arn:aws:cloudformation:myid", 
        "ResourceStatus": "CREATE_COMPLETE", 
        "ResourceType": "AWS::EC2::XYZ", 
        "Timestamp": "time", 
        "StackName": "mystack", 
        "PhysicalResourceId": "myphysical", 
        "LogicalResourceId": "myLogicalName"

1 个答案:

答案 0 :(得分:0)

list_stack_resources方法返回StackResourceSummary个对象的列表。每个对象都具有以下属性:

  • last_updated_time
  • logical_resource_id
  • physical_resource_id
  • resource_status
  • resource_status_reason
  • RESOURCE_TYPE

您可以在列表中的每个对象上使用这些属性来获取您要查找的详细信息。

试试这段代码:

import boto.cloudformation
conn = boto.cloudformation.connect_to_region('us-east-1', ...)

resources = conn.list_stack_resources(stack_id)
for resource in resources:
    print(resource.last_updated_time)
    print(resource.logical_resource_id)
    print(resource.physical_resource_id)
    print(resource.status)
    print(resource.resource_type)

告诉我你的看法。