Skip to content

Instantly share code, notes, and snippets.

View jg75's full-sized avatar

James Garner jg75

  • Amber Engine
  • Michigan
View GitHub Profile
@jg75
jg75 / child.yml
Last active November 14, 2019 21:42
Export value and import value is kind of annoying, because you can't change an export that's already being imported, but you can use a parameter and force an update if it changes.
AWSTemplateFormatVersion: 2010-09-09
Description: The child template needs the Arn for the task role and the bucket name for the task.
Parameters:
InputS3BucketArn:
Description: Parameter containing the Arn of the S3 Bucket for input
Type: AWS::SSM::Parameter::Value<String>
Default: /Yolo/Development/InputS3BucketArn
OutputS3BucketArn:
@jg75
jg75 / get_account.py
Last active December 16, 2019 18:22
Get the AWS account id for the current session user's credentials
import boto3
def get_account_id(session):
"""
Get Account Id.
Get the AWS account id for the current session user's credentials.
"""
client = session.client("sts")
@jg75
jg75 / user-data
Created January 24, 2020 05:18
Automatically associate an elastic ip to the running ec2 instance
#! /bin/bash
allocation_id=<ALLOCATION_ID>
metadata=169.254.169.254/latest/meta-data
get-region() {
curl -s http://$metadata/placement/availability-zone | awk '{
print(substr($0, 0, length($0)-1))
}'
}