-1
特定のタグ名を持たないec2インスタンスをリストするbotoスクリプトを手伝ってもらえますか?特定のタグ(名前)を持たないec2インスタンスをフェッチするためのBotoスクリプト
名前の値は何でもかまいません。名前が設定されていないインスタンスが必要です。
私はこれを試しました:これは正しいですか?それはいくつかのインスタンスを返すだけでなく、このエラーを取得している:私はそれらに関連付けられた名前のタグを持っていないインスタンスを一覧表示する必要がcosをFooの の代わりに行く何
Traceback (most recent call last):
File "try6.py", line 7, in <module>
if 'Foo' not in [t['Key'] for t in i.tags]:
TypeError: 'NoneType' object is not iterable
import boto3
instances = [i for i in boto3.resource('ec2', region_name='us-east-1').instances.all()]
# Print instance_id of instances that do not have a Tag of Key='Foo'
for i in instances:
if 'Foo' not in [t['Key'] for t in i.tags]:
print i.instance_id
。 〜
awt-cliと同様にboto、boto3でタグ付けします。あなたが使っているもの、それについてどれだけ読んだり、何を試してみたか、よく整形された質問をしてください – hjpotter92
これを行うにはAWS Configを使う方が良いかもしれません – Vorsprung