![](/img/trans.png)
[英]Reattaching a retained cloudformation resources, back to a cloudformation stack
[英]CloudFormation Stack resources
我正在嘗試使用 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' object has no attribute 'list_stack_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()))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.