Skip to content

Instantly share code, notes, and snippets.

@omerxx
Last active April 27, 2017 13:01
Show Gist options
  • Select an option

  • Save omerxx/7e522801e824b2ca189be9a5cdbe59bb to your computer and use it in GitHub Desktop.

Select an option

Save omerxx/7e522801e824b2ca189be9a5cdbe59bb to your computer and use it in GitHub Desktop.
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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment