Skip to content

Instantly share code, notes, and snippets.

View HammoTime's full-sized avatar

Adam Hammond HammoTime

View GitHub Profile
@HammoTime
HammoTime / install_terraform.rh.sh
Last active April 22, 2019 11:04
Install Terrafrom on Red Hat and derivatives
sudo yum install -y jq wget unzip
cd ~
version=$(curl https://api.github.com/repos/hashicorp/terraform/releases/latest --silent | jq ".tag_name" -r)
version=$(echo $version | sed 's/v//g') # get rid of 'v' from version number
echo "Installing Terraform $version."
url="https://releases.hashicorp.com/terraform/$version/terraform_$(echo $version)_linux_amd64.zip"
wget $url
unzip "terraform_$(echo $version)_linux_amd64.zip"
chmod +x terraform
sudo mv terraform /usr/local/bin/
@HammoTime
HammoTime / install_terraform.mac.sh
Last active November 21, 2022 07:35
Install Terraform on a Mac
brew install jq
brew install wget
cd ~
version=$(curl https://api.github.com/repos/hashicorp/terraform/releases/latest --silent | jq ".tag_name" -r)
version=$(echo $version | sed 's/v//g') # get rid of 'v' from version number
echo "Installing Terraform $version."
url="https://releases.hashicorp.com/terraform/$version/terraform_$(echo $version)_darwin_amd64.zip"
wget $url
unzip "terraform_$(echo $version)_darwin_amd64.zip"
chmod +x terraform
@HammoTime
HammoTime / clone_s3_bucket.ps1
Last active May 30, 2018 06:23
Clone the contents of an S3 bucket locally
Import-Module AWSPowerShell
# So our AWS Scripts work well with Proxies.
$Browser = New-Object System.Net.WebClient
$Browser.Proxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials
$BucketName = 'TestBucket'
$Region = 'ex-ampleregion-1'
$TargetDirectory = 'C:\BucketOutput\'
$AllObjects = Get-S3Object $BucketName -KeyPrefix '/' -Region $Region
@HammoTime
HammoTime / deploy_test_stack.ps1
Last active May 27, 2018 23:34
Deploys a new template version to S3 and then recreates the stack.
Import-Module AWSPowerShell
# So our AWS Scripts work well with Proxies.
$Browser = New-Object System.Net.WebClient
$Browser.Proxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials
$StackName = 'TestStack'
$TemplateKey = '/CloudFormation/template.json'
$FileLocation = 'C:\Temp\template.json'
$BucketName = 'test-bucket'
@HammoTime
HammoTime / bucket_policy.json
Last active May 24, 2018 14:01
An S3 Bucket policy that allows access from an EC2 instance to an S3 bucket on another account
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EC2AccessToS3BucketOnSeparateAccount",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<account number>:root"
},
"Action": [
@HammoTime
HammoTime / iam_policy.json
Last active May 24, 2018 14:01
An IAM policy that allows access from an EC2 instance to an S3 bucket on another account
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EC2AccessToS3BucketOnSeparateAccount",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucketByTags",
"s3:GetBucketTagging",
<#
.SYNOPSIS
Updates the SimplePSLogging Module from GitHub.
.DESCRIPTION
Checks the current releases on GitHub. If there is a new release, downloads the source
files, copies them to the modules directory, and reloads the current runspace with
the new module.