This also requires that you not use that naming convention for task definitions that are not services. For example: A Task Definition with the family name of 'cache-service' will have its hosting Container Instance's internal ip added to a Route53 private Zone as cache.local and other machines on the same subnet can address it that way. """ import argparse import logging import os import re import boto ecs = boto.connect_ec2containerservice(host='ecs.eu-central-1.amazonaws.com') ec2 = boto.connect_ec2(host='ecs.eu-central-1.amazonaws.com') route53 = boto.connect_route53(host='ecs.eu-central-1.amazonaws.com') logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%Y/%m/%d/ %I:%M:%S %p') log = logging.info if 'ECS_CLUSTER' in os.environ: cluster = os.environ['ECS_CLUSTER'] elif os.path.exists('/etc/ecs/ecs.config'): pat = re.compile(r'\bECS_CLUSTER\b\s*=\s*(\w*)') cluster = pat.findall(open('/etc/ecs/ecs.config').read())[-1] else: cluster = None
This also requires that you not use that naming convention for task definitions that are not services. For example: A Task Definition with the family name of 'cache-service' will have its hosting Container Instance's internal ip added to a Route53 private Zone as cache.local and other machines on the same subnet can address it that way. """ import argparse import logging import os import re import boto ecs = boto.connect_ec2containerservice() ec2 = boto.connect_ec2() route53 = boto.connect_route53() logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%Y/%m/%d/ %I:%M:%S %p') log = logging.info if 'ECS_CLUSTER' in os.environ: cluster = os.environ['ECS_CLUSTER'] elif os.path.exists('/etc/ecs/ecs.config'): pat = re.compile(r'\bECS_CLUSTER\b\s*=\s*(\w*)') cluster = pat.findall(open('/etc/ecs/ecs.config').read())[-1] else: cluster = None
def setUp(self): self.ecs = boto.connect_ec2containerservice()