Skip to content

Instantly share code, notes, and snippets.

@micahhausler
Last active April 4, 2017 19:25
Show Gist options
  • Save micahhausler/fad51bf3906b533ecb5c to your computer and use it in GitHub Desktop.
Save micahhausler/fad51bf3906b533ecb5c to your computer and use it in GitHub Desktop.
Boto3 ECS register_task_definition
import os
import boto3
def connect_ecs(region=None):
return boto3.client(
'ecs',
aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID'),
aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY'),
region_name=region or os.environ.get('AWS_EC2_REGION', 'us-east-1'),
)
conn = connect_ecs()
family = "demo"
container = {
"cpu": 512,
"essential": True,
"image": "busybox:latest",
"memory": 512,
"name": "busybox",
"command": "/bin/sh -c \"/bin/sleep 120; /bin/echo 'done'; /bin/true\"".split()
}
response = conn.register_task_definition(
family=family,
containerDefinitions=[container]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment