Reputation: 368
I am trying to receive Stack resources ARN information using boto3. I tried to use:
import boto3
client = boto3.resource('cloudformation',
aws_access_key_id='xxxxxxxx',
aws_secret_access_key='xxxxxxxxxxxx')
response = client.list_stack_resources(
StackName='ORG-ROLES')
I get "AttributeError: 'cloudformation.ServiceResource' object has no attribute 'list_stack_resources'" This Stack runs 9 resources, I want to get one resource ARN information. Hope you can help me.
Upvotes: 1
Views: 422
Reputation: 78573
You're mixing up the client-level and resource-level APIs. You need to use one or the other. Here's an example of each.
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()))
Upvotes: 2