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 / .editorconfig
Created May 27, 2018 04:14
Display settings for bash scripts
[*.sh]
end_of_line = lf
indent_size = 2
@endofcake
endofcake / .gitattributes
Created May 27, 2018 04:14
Always LF for bash scripts
# Always LF
*.sh text eol=lf
@endofcake
endofcake / cfn.tf
Created May 23, 2018 08:45
Auto Scaling group managed in CloudFormation and wrapped in Terraform
resource "aws_cloudformation_stack" "autoscaling_group" {
name = "${var.cfn_stack_name}"
template_body = <<EOF
Description: "${var.cfn_stack_description}"
Resources:
ASG:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier: ["${join("\",\"", var.subnets)}"]
@endofcake
endofcake / get_image_tags.py
Created May 22, 2018 21:22
An external data source for Terraform that returns the versions of all images in an ECS task definition
''' Return image tags specified in ECS task definition '''
import json
import sys
import boto3
ECR_CLIENT = boto3.client('ecr')
ECS_CLIENT = boto3.client('ecs')
def main(cluster_name, service_name):
@endofcake
endofcake / .gitattributes
Created May 20, 2018 04:46
Set LF line endings, otherwise bash scripts fail during the deployment
# Always LF for bash scripts
*.sh text eol=lf
@endofcake
endofcake / sample.tf
Last active May 20, 2018 05:00
Environment maps in Terraform
variable "instance_type" {
type = "map"
default = {
test = "m4.large"
uat = "m4.large"
prod = "m4.xlarge"
}
}
// <...>
@endofcake
endofcake / tree.sh
Last active May 20, 2018 04:22
Typical Terraform project
|-- .editorconfig
|-- .gitattributes
|-- .gitignore
|-- Jenkinsfile
|-- README.md
|-- scripts
| |-- run_terraform_deployer.sh
`-- src
|-- config.tf
|-- data_sources.tf
@endofcake
endofcake / docker.sh
Last active May 20, 2018 01:42
Pass base image version as an argument
docker build --build-arg VERSION=${version} .
@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
@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
}