Skip to content

Instantly share code, notes, and snippets.

View HammoTime's full-sized avatar

Adam Hammond HammoTime

View GitHub Profile
<#
.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.
@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",
@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 / 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 / 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 / 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 / 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/

Keybase proof

I hereby claim:

  • I am hammotime on github.
  • I am hammo (https://keybase.io/hammo) on keybase.
  • I have a public key ASBfy_XHf_QZFYwvRKOV7EmJwY0Yip522dpcSQviBketRQo

To claim this, I am signing this object:

@HammoTime
HammoTime / install_terraform.ps1
Last active April 22, 2019 11:27
Install Terraform on Windows
$VersionInfo = ((Invoke-WebRequest https://api.github.com/repos/hashicorp/terraform/releases/latest).Content | ConvertFrom-Json).tag_name
$VersionInfo = $VersionInfo.Replace("v", "")
Write-Host "Installing Terraform $VersionInfo."
$Url = "https://releases.hashicorp.com/terraform/" + $VersionInfo + "/terraform_" + $VersionInfo + "_windows_amd64.zip"
$InstallDirectory = [Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData) + "\Terraform"
if(Test-Path $InstallDirectory) {
Remove-Item $InstallDirectory -Recurse
}
wget https://wordpress.org/latest.tar.gz
tar xvzf latest.tar.gz
sudo mv wordpress/ /var/www/<TENANT_NAME>-wp
sudo chown -R nginx:nginx /var/www/<TENANT_NAME>/