Skip to content
Snippets Groups Projects
Commit 554857da authored by shlo's avatar shlo Committed by Kubernetes Prow Robot
Browse files

add cluster name into filer if specifed in environment variable (#5085)

parent 9bf23fa4
No related branches found
No related tags found
No related merge requests found
...@@ -42,8 +42,11 @@ class SearchEC2Tags(object): ...@@ -42,8 +42,11 @@ class SearchEC2Tags(object):
region = os.environ['REGION'] region = os.environ['REGION']
ec2 = boto3.resource('ec2', region) ec2 = boto3.resource('ec2', region)
filters = [{'Name': 'tag:'+tag_key, 'Values': tag_value}, {'Name': 'instance-state-name', 'Values': ['running']}]
instances = ec2.instances.filter(Filters=[{'Name': 'tag:'+tag_key, 'Values': tag_value}, {'Name': 'instance-state-name', 'Values': ['running']}]) cluster_name = os.getenv('CLUSTER_NAME')
if cluster_name:
filters.append({'Name': 'tag-key', 'Values': ['kubernetes.io/cluster/'+cluster_name]})
instances = ec2.instances.filter(Filters=filters)
for instance in instances: for instance in instances:
##Suppose default vpc_visibility is private ##Suppose default vpc_visibility is private
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment