Skip to content

Instantly share code, notes, and snippets.

@abtris
Created May 26, 2015 11:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abtris/19bda0f01b6f82fba724 to your computer and use it in GitHub Desktop.
Save abtris/19bda0f01b6f82fba724 to your computer and use it in GitHub Desktop.
Elastic Container Service
#!/bin/bash
yum install -y aws-cli
aws s3 cp s3://yours-ecs-config/ecs.config /etc/ecs/ecs.config
echo ECS_CLUSTER= cluster-name-demo >> /etc/ecs/ecs.config
ECS_ENGINE_AUTH_TYPE=dockercfg
ECS_ENGINE_AUTH_DATA={"https://docker.company.com/v1/":{"auth": "XXXX","email":"user@company.com"}}
# http://docs.aws.amazon.com/cli/latest/userguide/installing.html
yum install -y aws-cli
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
aws configure
# ECS
aws ecs create-cluster --cluster-name cluster-name-demo
# ecsInstanceRole by documentation: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/IAM_policies.html
aws ec2 run-instances --image-id ami-d0b9acb8 --count 1 --instance-type t2.small --key-name KEY_NAME --security-group-ids SECURITY_GROUP --iam-instance-profile Name=ecsInstanceRole --subnet-id SUBNET_ID --user-data file://cluster_setup
aws ecs list-container-instances --cluster cluster-name-demo
# http://docs.aws.amazon.com/AmazonECS/latest/developerguide/example_task_definitions.html
aws ecs register-task-definition --cli-input-json file://task.json
aws ecs list-task-definitions
aws ecs create-service --service-name service-name-demo --task-definition TASK:VERSION --desired-count 1 --cluster cluster-name-demo
aws ecs list-services --cluster cluster-name-demo
aws ecs describe-services --services service-name-demo --cluster cluster-name-demo
{
"containerDefinitions": [
{
"name": "wordpress",
"links": [
"mysql"
],
"image": "wordpress",
"essential": true,
"portMappings": [
{
"containerPort": 80,
"hostPort": 80
}
],
"memory": 500,
"cpu": 10
},
{
"environment": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "password"
}
],
"name": "mysql",
"image": "mysql",
"cpu": 10,
"memory": 500,
"essential": true
}
],
"family": "hello_world"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment