This file contains hidden or 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
DATABASE_URL=$(sudo /opt/elasticbeanstalk/bin/get-config environment | jq .DATABASE_URL) | |
fields=( $(echo $DATABASE_URL | sed -e 's/^"mysql2:\/\/\([^:]*\):\([^@]*\)@\([^:]*\):\([^/]*\)\/\([^\?]*\)\?.*$/\1 \2 \3 \4 \5/') ) | |
docker exec -ti $(docker ps -a | grep web | awk '{print $1}') mysqldump -h ${fields[2]} -u ${fields[0]} --password="${fields[1]}" -P ${fields[3]} ${fields[4]} > ${fields[4]}.sql |
This file contains hidden or 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
awsargs="--profile aws-dev --region us-east-1" | |
now=$(date -j -f "%a %b %d %T %Z %Y" "$(date)" "+%s" 2>/dev/null); | |
oneweekago=$(expr $now - 604800); | |
aws elasticbeanstalk describe-application-versions $awsargs | \ | |
jq -r '.ApplicationVersions[] | .ApplicationName + " " + .VersionLabel + " " + .DateCreated'| \ | |
while read line ; do | |
fields=( $line ) | |
utime=$(date -j -f %Y-%m-%dT%H:%M:%S "${fields[2]};" "+%s" 2>/dev/null); | |
if [[ $utime -lt $oneweekago ]]; then | |
if [ -n "$(aws elasticbeanstalk describe-environments $awsargs \ |
This file contains hidden or 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
packages: | |
yum: | |
wget: [] | |
curl: [] | |
commands: | |
00_remove_99_swap.conf.bak: | |
command: rm -f /etc/sysctl.d/99_swap.conf.bak | |
test: test -f /etc/sysctl.d/99_swap.conf.bak | |
ignoreErrors: true | |
00_remove_99_filesystem.conf.bak: |
This file contains hidden or 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
aws cloudformation describe-stacks --stack-name myapp-dev --profile aws-dev --region us-east-1 | jq -r '.Stacks[].Outputs' | |
[ | |
{ | |
"Description": "VPC Id", | |
"OutputKey": "VpcId", | |
"OutputValue": "vpc-b7d1d8d2" | |
}, | |
{ | |
"Description": "VPC", | |
"OutputKey": "VPCDefaultNetworkAcl", |
This file contains hidden or 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
STACK:=myapp-dev | |
TEMPLATE:=cloudformation-template_vpc-iam.json | |
PARAMETERS:=cloudformation-parameters_myapp-dev.json | |
AWS_REGION:=us-east-1 | |
AWS_PROFILE:=aws-dev | |
all: | |
@which aws || pip install awscli | |
aws cloudformation create-stack --stack-name $(STACK) --template-body file://`pwd`/$(TEMPLATE) --parameters file://`pwd`/$(PARAMETERS) --capabilities CAPABILITY_IAM --profile $(AWS_PROFILE) --region $(AWS_REGION) |
This file contains hidden or 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
[ | |
{ "ParameterKey": "Project", "ParameterValue": "myapp" }, | |
{ "ParameterKey": "Environment", "ParameterValue": "dev" }, | |
{ "ParameterKey": "VPCNetworkCIDR", "ParameterValue": "10.0.0.0/16" }, | |
{ "ParameterKey": "VPCSubnet0CIDR", "ParameterValue": "10.0.0.0/24" }, | |
{ "ParameterKey": "VPCSubnet1CIDR", "ParameterValue": "10.0.1.0/24" }, | |
{ "ParameterKey": "VPCSubnet2CIDR", "ParameterValue": "10.0.2.0/24" } | |
] |
This file contains hidden or 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
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "MyApp VPC", | |
"Parameters" : { | |
"Project" : { | |
"Description" : "Project name to tag resources with", | |
"Type" : "String", | |
"MinLength": "1", | |
"MaxLength": "16", | |
"AllowedPattern" : "[a-z]*", |
This file contains hidden or 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
# See http://help.papertrailapp.com/kb/hosting-services/aws-elastic-beanstalk/ | |
sources: | |
/home/ec2-user: https://github.com/papertrail/remote_syslog2/releases/download/<VERSION>/remote_syslog_linux_amd64.tar.gz | |
files: | |
"/etc/log_files.yml": | |
mode: "00644" | |
owner: root | |
group: root |
This file contains hidden or 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
AWS_DEFAULT_REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region) | |
EC2_INSTANCE_ID=$(curl -sL http://169.254.169.254/latest/meta-data/instance-id) | |
EB_ENVIRONMENT_ID=$(aws ec2 describe-tags --filter Name=resource-id,Values=$EC2_INSTANCE_ID --region $AWS_DEFAULT_REGION | jq -r '.Tags | .[] | select(.Key=="elasticbeanstalk:environment-id") | .Value') | |
EB_APPLICATION_VERSION=$(aws elasticbeanstalk describe-environments --environment-ids $EB_ENVIRONMENT_ID --region $AWS_DEFAULT_REGION --region $AWS_DEFAULT_REGION | jq -r '.Environments | .[] | .VersionLabel') |
This file contains hidden or 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
curl -sLX GET 'https://api.newrelic.com/v2/servers.json' \ | |
-H "X-Api-Key:${NEW_RELIC_API_KEY}" | \ | |
jq -r '.servers | [ .[] | select(.reporting == 'false') ] | .[] | ."id" ' | \ | |
xargs -L1 -I% curl -X DELETE 'https://api.newrelic.com/v2/servers/%.json' \ | |
-H "X-Api-Key:${NEW_RELIC_API_KEY}" -i |