This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello () { | |
set -e | |
echo "{\"statusCode\": 200, \"body\": \"Hello, from Bash\"}" >&2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check for arbitrary environment variables | |
UNSET_ENVS=false | |
function check_env() { | |
if [ -z "${!1}" ]; then | |
>&2 echo "ERROR: Environment Variable '$1' is not set" | |
export UNSET_ENVS=true | |
else | |
echo "$1 set to ${!1}" | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import boto3 | |
import sys | |
import re | |
ecs = boto3.client('ecs') | |
sys.argv.pop(0) | |
clusters=[]+sys.argv | |
if len(clusters) == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[general] | |
state_file = /var/awslogs/state/agent-state | |
[/var/log/ecs/ecs-agent.log] | |
file = /var/log/ecs/ecs-agent.log.* | |
log_group_name = MyCoolEnvironment-ecs | |
log_stream_name = ecs-agent/`curl http://169.254.169.254/latest/meta-data/instance-id` | |
datetime_format = %Y-%m-%dT%H:%M:%SZ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -f ./Gemfile.lock ]; then | |
# No Gemfile.lock present, create a new one | |
touch Gemfile.lock | |
fi | |
if [ -f ./.ruby-version ]; then | |
ruby_version="$(cat .ruby-version)" | |
else | |
ruby_version="latest" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function app-logs() { | |
if [ -z $1 ] || [ -z $2 ]; then | |
echo "usage: app-logs <env> <service> [<awslogs params>]" | |
return 1 | |
fi | |
if [ "$1" = "production" ] || [ "$1" = "staging" ]; then | |
ACCOUNT=prod | |
else | |
ACCOUNT=default | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG MY_ARG | |
RUN : "${MY_ARG:?ERROR - MY_ARG Build argument needs to be set and non-empty.}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Usage: | |
# 1) Build the AWS CLI into your container | |
# 2) Set your region, or pass env into the container | |
export AWS_DEFAULT_REGION=us-east-1 | |
function usage () { | |
echo "Usage: Container must be run with the following environment variables: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parameters: | |
PapertrailEndpoint: | |
Type: String | |
Default: logsX.papertrailapp.com:XXXXX | |
Resources: | |
LaunchConfig: | |
Properties: | |
... | |
UserData: | |
Fn::Base64: !Sub | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function aws-rm-ami-snap() { | |
if [[ ${1} == ami-* ]]; then | |
AMI_ID=${1} | |
SNAPSHOT_IDS=$(aws ec2 describe-images --filters Name=image-id,Values=${1} | jq '.Images[].BlockDeviceMappings[].Ebs.SnapshotId' | sed 's/"//g') | |
aws ec2 deregister-image --image-id ${AMI_ID} | |
for snapshot_id in ${SNAPSHOT_IDS}; do | |
aws ec2 delete-snapshot --snapshot-id ${snapshot_id} | |
done | |
else | |
echo "ERROR: Require \$1 to be an AMI ID, starting with 'ami-'" |
NewerOlder