简体   繁体   English

无法从AWS CLI或boto3查看ECS集群

[英]Unable to see ECS clusters from AWS CLI or boto3

I've created a few clusters using AWS ECS to run my workflows. 我已经使用AWS ECS创建了一些集群来运行我的工作流程。 So far, I've been managing their provisioning / task definition through a combination of Terraform and the console. 到目前为止,我一直通过Terraform和控制台的组合来管理它们的供应/任务定义。

Today, I wanted to use boto3 to add in some logic checks for tasks that were already running. 今天,我想使用boto3为已经在运行的任务添加一些逻辑检查。 However, when I tried to list my clusters, the client return an empty list: 但是,当我尝试列出集群时,客户端返回一个空列表:

session = boto3.Session(profile_name='default')
client = session.client('ecs')
print(client.list_clusters())

{'clusterArns': [], 'ResponseMetadata': {'RequestId': 'XXX', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'XXX', 'content-type': 'application/x-amz-json-1.1', 'content-length': '18', 'date': 'Fri, 18 Jan 2019 15:09:33 GMT'}, 'RetryAttempts': 0}} {'clusterArns':[],'ResponseMetadata':{'RequestId':'XXX','HTTPStatusCode':200,'HTTPHeaders':{'x-amzn-requestid':'XXX','content-type': 'application / x-amz-json-1.1','content-length':'18','date':'Fri,18 Jan 2019 15:09:33 GMT'},'RetryAttempts':0}}

This is baffling to me because I've made sure to use my default profile, and when I log into my ECS console, I see my clusters (there's more, but I am just showing one): 这让我感到困惑,因为我已经确保使用默认配置文件,并且当我登录到ECS控制台时,我看到了群集(还有更多,但我只显示了一个): 在此处输入图片说明

Moreover, I am able to list all of my S3 buckets with no issue: 而且,我能够列出所有我的S3存储桶,没有任何问题:

s3 = boto3.resource('s3')
for bucket in s3.buckets.all(): 
        print(bucket.name)

The above code returns a complete list of my S3 buckets. 上面的代码返回了我的S3存储桶的完整列表。 I've read through the documentation for ECS boto3 but am stuck as to why my clusters are not being found. 我已经阅读了ECS boto3的文档,但是对于为什么找不到我的集群感到boto3

检查默认配置文件的区域,并确保它与创建测试群集的位置匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM