Skip to content

Instantly share code, notes, and snippets.

View endofcake's full-sized avatar
🐢
slow to respond

Alexander Savchuk endofcake

🐢
slow to respond
  • Wellington, New Zealand
View GitHub Profile
@endofcake
endofcake / userdata.sh
Created May 11, 2018 00:35
Check that ecs-agent is running and signal back to CloudFormation
#!/bin/bash
set -euo pipefail
<...>
echo "Checking that agent is running"
until $(curl --output /dev/null --silent --head --fail http://localhost:51678/v1/metadata); do
printf '.'
sleep 1
done
exit_code=$?
printf "\nDone\n"
@endofcake
endofcake / asg.tf
Created May 11, 2018 00:39
Auto Scaling rolling updates (CloudFormation embedded in Terraform)
CreationPolicy:
AutoScalingCreationPolicy:
MinSuccessfulInstancesPercent: 80
ResourceSignal:
Count: "${var.cfn_signal_count}"
Timeout: PT10M
UpdatePolicy:
# Ignore differences in group size properties caused by scheduled actions
AutoScalingScheduledAction:
IgnoreUnmodifiedGroupSizeProperties: true
@endofcake
endofcake / ecs_task.tf
Created May 11, 2018 00:41
ECS task placement constraints that prevent ECS scheduler from putting a new task on an instance about to be drained
placement_constraints {
type = "memberOf"
expression = "attribute:drain !exists or attribute:drain != true"
}
@endofcake
endofcake / pipeline.groovy
Created May 11, 2018 00:43
Post build step for Jenkins to untaint all instances in ECS cluster
post {
always{
// Clear up old instances
tag('false')
}
}
@endofcake
endofcake / Dockerfile
Last active May 6, 2024 17:20
Copy *.csproj files during a docker build, preserving the directory structure (kudos to @aidansteele)
COPY src/*/*.csproj ./
RUN for file in $(ls *.csproj); do mkdir -p ${file%.*}/ && mv $file ${file%.*}/; done
@endofcake
endofcake / ecs.tf
Last active May 11, 2018 02:06
Sample ECS task definition for app deployment
{
"name": "${app}",
"image": "${image}", <<< THE CHANGE GOES HERE
"cpu": ${cpu},
...
}
@endofcake
endofcake / Jenkinsfile
Created May 14, 2018 00:22
Trigger an external deployment pipeline
stage('Start deployment') {
when {
branch 'master'
}
steps {
build job: "Deployment/${serviceName}/${env.BRANCH_NAME}",
propagate: true,
wait: true,
parameters: [
[$class: 'StringParameterValue', name: 'imageName', value: imageName],
@endofcake
endofcake / Jenkinsfile
Last active November 22, 2018 00:15
Approve deployment to production
def release = false
pipeline {
agent any
options {
timestamps()
disableConcurrentBuilds()
}
@endofcake
endofcake / ecs.tf
Created May 14, 2018 01:14
ECS service configuration in Terraform
resource "aws_ecs_service" "web" {
deployment_maximum_percent = 200
deployment_minimum_healthy_percent = 70
}
@endofcake
endofcake / Dockerfile
Last active May 20, 2018 01:40
Parameterised FROM clause
# This will be overridden at build time
ARG VERSION=2.0.6
FROM microsoft/aspnetcore:$VERSION