Last active
April 4, 2017 19:25
-
-
Save micahhausler/fad51bf3906b533ecb5c to your computer and use it in GitHub Desktop.
Boto3 ECS register_task_definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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