Skip to content

Instantly share code, notes, and snippets.

View DaneTheory's full-sized avatar
🏠
Working from home

Branden Dane DaneTheory

🏠
Working from home
View GitHub Profile
@fgassert
fgassert / ec2-get-security-credentials
Last active March 18, 2020 01:27
gets iam security credentials from instance metadata and writes them to awscli environment variables and .s3cfg (for s3cmd)
#!/bin/bash
# gets iam security credentials from instance metadata and writes them to
# awscli environment variables and .s3cfg (for s3cmd)
# Usage: ec2-get-security-credentials ROLENAME DEFAULT_REGION
# ROLE=$1
# DEFAULT_REGION=$2
@hibernado
hibernado / aws_repoint_to_my_ip.sh
Last active November 16, 2021 02:48
Repoint AWS EC2 Security Group inbound access to my current IP address
#!/bin/bash
# Summary:
# Bash script repoints all inbound access for a given AWS EC2 security group
# to your current IP addr(v4) as provided by ifconfig.me/ip
# To use this script:
# Pass the name of a security group as a command line argument
# e.g. $ aws_repoint_to_my_ip.sh SECURITYGROUPNAME
@jsianes
jsianes / ipassign
Last active September 5, 2021 08:04
Script to assign Public IP from Elastic IP pool for instances hosted in AWS. 'ec2-utils' and AWS CLI packages required. Instance role or access keys need to allow at least next EC2 actions: describe-addresses, associate-address and disassociate-address. Shell script is designed to be integrated with instance start-up
#!/bin/bash
# chkconfig: 2345 99 10
# description: Set Public IP from ElasticIP pool during instance startup
# processname: ipassign
# Provides: ipassign
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Set Public IP from ElasticIP pool during instance startup
var AWS = require('aws-sdk');
AWS.config.update({
logger: process.stdout,
region: 'ap-northeast-1'
});
var r53 = new AWS.Route53();
var params = {
@aaronlevin
aaronlevin / common_util.sh
Last active December 10, 2018 05:14
Example scaffolding and helpers for bash scripts
#!/bin/bash
###############################################################################
# Helpers #
###############################################################################
# `is_set` accepts a function and checks if a variable is set.
# The function it accepts should generate a string for an error
# message
is_set() {
@sgykfjsm
sgykfjsm / list_ami_images.sh
Last active December 10, 2018 05:02
AWS AMIをざっくり検索する
#!/bin/bash
#
# region information: http://docs.aws.amazon.com/general/latest/gr/rande.html
# aws-cli ec2 describe-images: http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-images.html
#
set -eu
aws_cmd=$(which aws ||:)
if [ -z "${aws_cmd}" ]; then
echo Please Install aws-cli >&2
#!/bin/sh
DEBUG=""
DATE=$(date +%Y-%m-%d)
HOSTNAME=`/bin/hostname`
AMINAME="$DATE-$HOSTNAME-AMI"
AMIDESC="$HOSTNAME backup to AMI on $DATE"
EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"
test -n "$EC2_INSTANCE_ID" || die 'cannot obtain instance-id'
@kaizhu256
kaizhu256 / example.js
Last active December 2, 2018 21:52
nodejs - standalone code to upload data to amazon s3
/*
this standalone nodejs code requires the following env variables to be set:
process.env.AWS_ACCESS_KEY_ID
process.env.AWS_S3_BUCKET
process.env.AWS_SECRET_ACCESS_KEY
*/
/*jslint
bitwise: true, browser: true,
indent: 2,
maxerr: 8,
@vszakats
vszakats / s3-upload-aws4.sh
Last active February 29, 2024 14:23
AWS S3 upload using signature v4
#!/bin/sh
# To the extent possible under law, Viktor Szakats
# has waived all copyright and related or neighboring rights to this
# script.
# CC0 - https://creativecommons.org/publicdomain/zero/1.0/
# SPDX-License-Identifier: CC0-1.0
# THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@benpearson2003
benpearson2003 / automated-snapshots
Last active December 2, 2018 22:15
Setting Up Automated Snapshots
Install AWS CLI if missing.
http://docs.aws.amazon.com/cli/latest/userguide/installing.html
Configure AWS CLI
http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
>> Roadblock: Missing keys: Ask [designated AWS admin] to give you keys.
>> Error: Region: Confirm your server's region.
Install EC2 API Tools if missing
https://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/set-up-ec2-cli-linux.html
>> Roadblock: Permission denied: Ask [designated AWS admin] to fix it.