Skip to content

Instantly share code, notes, and snippets.

View omerxx's full-sized avatar
🎱
All is as thinking makes it so

Omer H. omerxx

🎱
All is as thinking makes it so
View GitHub Profile
awscli:
image: omerxx/awscli
volumes:
- ~/.aws:/root/.aws
command: tail -f /dev/null
# Usage:
# Save as docker-compose.yml
# Run docker-compose up -d
# Run docker exec -it $(docker ps -q) /bin/sh
pipeline:
frontend:
image: node
commands:
- npm install
- npm test
backend:
image: golang
commands:
- go test -v
pipeline:
deploy-server-elastic-beanstalk:
image: peloton/drone-elastic-beanstalk
region: us-east-2
application: drone
version_label: ${DRONE_BUILD_NUMBER}-${DRONE_BRANCH}-drone-server
description: Drone server [Deployed with DroneCI]
environment_name: production-drone
environment_update: true
TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
VpcId: !Ref VPC
Port: 80
Protocol: HTTP
Matcher:
HttpCode: 200-299
HealthCheckIntervalSeconds: 80
HealthCheckPath: !Ref HealthCheckPath
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Cpu: !Ref VCpu
RequiresCompatibilities:
- !Ref RequiresCompatibilities
Family: !Ref ServiceName
NetworkMode: !Ref NetworkMode
ExecutionRoleArn: arn:aws:iam::000:role/EcsTaskExecutionRole
TaskRoleArn: arn:aws:iam::000:role/EcsTaskExecutionRole
Resources:
Service:
Type: AWS::ECS::Service
DependsOn: ListenerRule
Properties:
Cluster: !Ref Cluster
ServiceName: !Ref ServiceName
LaunchType: !Ref LaunchType
DesiredCount: !Ref DesiredCount
DeploymentConfiguration:
Resources:
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Ref EnvironmentName
ECSAutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier: !Ref Subnets
@omerxx
omerxx / example.yaml
Created August 31, 2017 13:47
Multi Container TaskDefinition in ECS, linked and mounted with Docker daemon
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref ServiceName
ContainerDefinitions:
- Name: !Sub ${ServiceName}-container
Essential: true
Image: !Ref DockerImage
Memory: !Ref Memory
PortMappings:
import os
import boto3
import datetime
import dateutil
DEFAULT_MAX_MEM = 3000
LOW_CLUSTER_CPU_TH = 20
HIGH_CLUSTER_CPU_TH = 65
CONTAINERS_MAX_MEM = {
'cluster1': 1200,
@omerxx
omerxx / chaos.py
Last active April 27, 2017 13:01
Lambda function for killing random task on an ecs family
def lambda_handler(event, context):
import boto3
client = boto3.client('ecs', aws_access_key_id='', aws_secret_access_key='')
response = client.list_tasks(cluster='mycluster', family='myservice', maxResults=1,desiredStatus='RUNNING')
stoptask = response['taskArns'][0].split('/')[1]
print client.stop_task(cluster='mycluster', task=stoptask, reason='chaos monkey')