Skip to content

Instantly share code, notes, and snippets.

View lantrix's full-sized avatar
:octocat:
always coding and merging

Ted B lantrix

:octocat:
always coding and merging
View GitHub Profile
@lantrix
lantrix / get_aws_saml_token.sh
Created February 6, 2015 05:57
How to request SAML assertion from ADFS for Amazon Web Services using curl
curl https://youradfsserver.com.au/adfs/services/trust/13/usernamemixed --data @aws_saml_request.xml -H "Content-Type: application/soap+xml" --verbose -o "saml.xml"
@lantrix
lantrix / bulk_tag.ps1
Created February 10, 2015 02:56
Change lots of Resource Tags in AWS
$a = Get-EC2Tag -Filter @{Name="tag:Environment Name"; Value="My Environment"}
New-EC2Tag -Resources $a.ResourceId -Tags @{Key='Project'; Value='My Project'}
@lantrix
lantrix / tag_per_item.ps1
Created March 14, 2015 08:50
Individually tag a bunch of AWS items - error handling per item (less efficient as not one operation)
$a = Get-EC2NetworkInterface -Region ap-southeast-2
$tag = New-Object Amazon.EC2.Model.Tag
$tag.Key = "Environment"
$tag.Value = "Dev"
$count = 0
$throwError =""
foreach ($i in $a) {
Clear-Variable -Name throwError #Reset Failure Variable
$count++
if ($count -gt 0) {
@lantrix
lantrix / aws.sh
Last active July 25, 2023 03:06
Bash functions to autenticate and assume roles in aws federated accounts - for ADFS3
#!/bin/bash
# bash functions to autenticate and assume roles in aws federated accounts
# required tools on $PATH - aws, date, curl, jq, libxml2-utils
# requried environment variables:
export AWS_CLI=`which aws`
# optional environment variable, to automatically assume a specific role when calling assume()
# AWS_ASSUME_ROLE=arn:aws:iam::369407384105:role/cross-account-federated-role
@lantrix
lantrix / re-register-instances.sh
Created April 1, 2015 06:50
Re-register stopped/started EC2 instances with AWS ELB
ELB_NAME="chef-dev"
#Get Instances
ARRAY=(); for i in \
`aws elb describe-load-balancers --load-balancer-names $ELB_NAME --output text |grep INSTANCES | awk '{print $2}'`; \
do ARRAY+=($i); \
done
#Dereg
for i in "${ARRAY[@]}"; do aws elb deregister-instances-from-load-balancer --load-balancer-name $ELB_NAME --instances $i; done
2015/04/02 22:47:09 ui: ==> vmware-vmx: Running post-processor: vagrant-cloud
==> vmware-vmx: Running post-processor: vagrant-cloud
2015/04/02 22:47:09 ui: ==> vmware-vmx (vagrant-cloud): Verifying box is accessible: seek/simianarmy-build
==> vmware-vmx (vagrant-cloud): Verifying box is accessible: seek/simianarmy-build
2015/04/02 22:47:09 packer-post-processor-vagrant-cloud: 2015/04/02 22:47:09 Post-Processor Vagrant Cloud API GET: https://vagrantcloud.com/api/v1/box/seek/simianarmy-build?access_token=ACCESS_TOKEN
2015/04/02 22:47:10 packer-post-processor-vagrant-cloud: 2015/04/02 22:47:10 Post-Processor Vagrant Cloud API Response:
2015/04/02 22:47:10 packer-post-processor-vagrant-cloud:
2015/04/02 22:47:10 packer-post-processor-vagrant-cloud: &{Status:200 OK StatusCode:200 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Date:[Thu, 02 Apr 2015 11:47:10 GMT] Etag:["ce6a8a8c23ea72b0361d7dc0bc502f0c"] X-Frame-Options:[SAMEORIGIN] X-Runtime:[0.303958] Cache-Control:[max-age=0, private, must-revalidate] Cont
{
"variables": {
"cloud_token": "$cloud_token",
"vagrant_box_version": "$vagrant_box_version"
},
"builders": [
{
"type": "vmware-vmx",
"source_path": "/Users/lantrix/AWS/simianarmy-build/.vagrant/machines/default/vmware_fusion/54800d00-774d-41b6-b0cf-3a593b08b056/packer-centos-6.6-x86_64.vmx",
"ssh_username": "root",
@lantrix
lantrix / iissites.ps1
Created May 14, 2015 06:50
Powershell to show all IIS site details
import-module webadministration; get-website | select name,id,state,physicalpath,applicationPool,
@{n="Bindings"; e= { ($_.bindings | select -expa collection) -join ';' }} ,
@{n="LogFile";e={ $_.logfile | select -expa directory}},
@{n="attributes"; e={($_.attributes | % { $_.name + "=" + $_.value }) -join ';' }} | Sort-Object id
@lantrix
lantrix / remove_tags.ps1
Created May 25, 2015 08:22
Bulk Remove EC2 Tags (PowerShell)
(Get-EC2Tag -Filter @{name="tag:JANITOR_META"; Value="*"}).Count
$remove = Get-EC2Tag -Filter @{name="tag:JANITOR_META"; Value="*"}
Remove-EC2Tag -Resource $remove.ResourceId -Tag @{Key="JANITOR_META"} -Force
(Get-EC2Tag -Filter @{name="tag:JANITOR_META"; Value="*"}).Count
@lantrix
lantrix / timestamp.ps1
Created May 28, 2015 06:41
Powershell AWS API time stamp in the Coordinated Universal Time (Greenwich Mean Time) time zone
((get-date).ToUniversalTime()).ToString("yyyy-MM-ddTHH:mm:ssZ")