View subnet_hack.txt
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
"${element(split(",", replace(replace(replace(replace(join(",", data.aws_subnet_ids.private.ids), "/subnet-ca201abd,/", ""), "/subnet-fc0870c1,/", ""), "/subnet-6630da5b/", ""), "/subnet-3f35c402,/", "")), count.index)}" |
View EC2_AMI_retention.sh
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/sh | |
date=`date +%Y-%m-%d -d "30 day ago"` | |
for region in us-east-1 us-west-2 ; do | |
aws ec2 describe-images --region $region --owners self --output text --filters 'Name=name,Values=IMAGE-NAME-*' --query 'Images[?CreationDate<=`'${date}'`][ImageId]' | grep -v `aws ec2 describe-instances --region $region --output text --filters 'Name=tag:Name,Values=IGNORE-STRING-*' --query 'Reservations[*].Instances[*].[ImageId]' | sed -n 1p` > remove_ami-$region.txt | |
for remove in `cat remove_ami-$region.txt` ; do | |
aws ec2 deregister-image --region $region --image-id $remove |
View ECS_policy.json
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "ECSAccess", | |
"Effect": "Allow", | |
"Action": [ | |
"ecs:Poll", | |
"ecs:StartTask", |
View terraform_cycle.tf
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
resource "aws_cloudwatch_metric_alarm" "cpu_credits" { | |
count = 2 | |
... | |
dimensions { InstanceId = "${element(list("i-07656896d6947814c", "i-042e664331a74e385"), count.index)}" } | |
dimensions { InstanceId = "${element(aws_instance.my_instance.*.id, count.index)}" } | |
} |
View ubuntu_find_java_home.sh
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 | |
# Find the absolute path of the java executable | |
# follow all symlinks (to cover /etc/alternatives/java ...) | |
jpath=$(readlink -e $(which java)) | |
if [[ "$jpath" != "" ]]; then | |
while [[ "$jpath" != "/" ]]; do | |
jpath=$(dirname $jpath) |
View runtest_function.sh
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/sh | |
email="email@example.com" | |
function runtest { | |
"$@" | |
local status=$? | |
if [ $status -ne 0 ]; then | |
echo "Script failed with error from '$@'" | mail -s "Script failure!" $email | |
exit 0 |
View aws_cloudwatch_metric_alarm_recover.tf
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
resource "aws_cloudwatch_metric_alarm" "example_host_alarm" { | |
alarm_name = "${aws_instance.example_host_alarm.id}" | |
comparison_operator = "GreaterThanOrEqualToThreshold" | |
evaluation_periods = "2" | |
metric_name = "StatusCheckFailed_System" | |
namespace = "AWS/EC2" | |
period = "60" | |
statistic = "Maximum" | |
threshold = "1.0" | |
alarm_description = "Created from EC2 Console" |
View terraform_remote_state.tf
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
data "terraform_remote_state" "network" { | |
backend = "s3" | |
workspace = "${terraform.workspace}" | |
config { | |
bucket = "bucket-name" | |
key = "terraform.tfstate" | |
region = "${var.region}" | |
} | |
} |