Amazon web services 云层资源

Amazon web services 云层资源,amazon-web-services,amazon-cloudformation,boto3,Amazon Web Services,Amazon Cloudformation,Boto3,我正在尝试使用boto3接收堆栈资源ARN信息。 我尝试使用: import boto3 client = boto3.resource('cloudformation', aws_access_key_id='xxxxxxxx', aws_secret_access_key='xxxxxxxxxxxx') response = client.list_stack_resources( StackName='ORG-ROLES') 我得到“AttributeError:'cl

我正在尝试使用boto3接收堆栈资源ARN信息。 我尝试使用:

import boto3

client = boto3.resource('cloudformation', 
  aws_access_key_id='xxxxxxxx',
  aws_secret_access_key='xxxxxxxxxxxx')

response = client.list_stack_resources(
  StackName='ORG-ROLES')
我得到“AttributeError:'cloudformation.ServiceResource'对象没有属性'list\u stack\u resources'” 这个堆栈运行9个资源,我想获得一个资源ARN信息。 希望你能帮助我。

你把和API弄混了。你需要使用其中一个。这里有一个例子

import boto3

session = boto3.Session(profile_name='xxxx', region_name='us-east-1')

STACK_NAME = 'ORG-ROLES'

# Use client-level API
client = session.client('cloudformation')
response = client.list_stack_resources(StackName=STACK_NAME)
print('Client API:', response['StackResourceSummaries'])

# Use resource-level API
resource = session.resource('cloudformation')
stack = resource.Stack(STACK_NAME)
print('Resource API:', list(stack.resource_summaries.all()))

boto3.resource
更改为
boto3.client