Skip to content

Instantly share code, notes, and snippets.

@seiffert
Created May 19, 2015 07:35
Show Gist options
  • Save seiffert/12af9bf0d092bd3d7a43 to your computer and use it in GitHub Desktop.
Save seiffert/12af9bf0d092bd3d7a43 to your computer and use it in GitHub Desktop.
ECS Machines Cloud Init
#cloud-config
write_files:
- path: /etc/systemd/system/docker.service.d/50-insecure-registry.conf
content: |
[Service]
Environment='DOCKER_OPTS=--insecure-registry="<private-hosted-zone-domain-of-registry>" --registry-mirror="http://<private-hosted-zone-domain-of-registry>"'
- path: /etc/ecs/ecs.config
permissions: 0644
owner: root
content: |
ECS_CLUSTER=crims
ECS_DATADIR=/data/
ECS_CHECKPOINT=true
AWS_DEFAULT_REGION=eu-west-1
coreos:
units:
- name: ecs-agent.service
command: start
content: |
[Unit]
Description=The AWS ECS agent
After=docker.service
Requires=docker.service
Type=service
[Service]
TimeoutStartSec=0
TimeoutStopSec=0
Restart=on-failure
RestartSec=30
SyslogIdentifierg=ecs-agent
ExecStartPre=-/bin/mkdir -p /var/log/ecs /var/ecs-data
ExecStartPre=-/usr/bin/docker stop ecs-agent
ExecStartPre=-/usr/bin/docker pull amazon/amazon-ecs-agent
ExecStartPre=-/usr/bin/docker rm ecs-agent
ExecStart=/usr/bin/docker run --name ecs-agent -v /var/run/docker.sock:/var/run/docker.sock -v /var/log/ecs:/log -v /var/ecs-data:/data -p 127.0.0.1:51678:51678 --env-file /etc/ecs/ecs.config -e ECS_LOGFILE=/log/ecs-agent.log amazon/amazon-ecs-agent
[...]
- name: signal-cfn-success.service
command: start
content: |
[Unit]
Description=Signal CloudFormation success
After=ecs-agent.service [...]
Wants=ecs-agent.service [...]
[Service]
TimeoutStartSec=0
Type=oneshot
Restart=no
RemainAfterExit=yes
ExecStartPre=-/usr/bin/docker pull registry.wonderland/cfn-bootstrap
ExecStart=/usr/bin/docker run --rm mbabineau/cfn-bootstrap cfn-signal -e 0 --stack <stack-name> --resource <asg-name> --region eu-west-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment