Skip to content

Instantly share code, notes, and snippets.

View gregohardy's full-sized avatar

Greg Hardy gregohardy

  • Puppet Labs
  • Belfast
View GitHub Profile
@gregohardy
gregohardy / get_vpc.rb
Created March 12, 2019 19:59
Deferred puppet function
require 'aws-sdk-ec2'
Puppet::Functions.create_function(:'amazon_aws::get_vpc') do
dispatch :up do
param 'String', :vpc_name
end
def up(vpc_name)
client = Aws::EC2::Client.new(region: 'us-west-2')
vpc_id = ""
@gregohardy
gregohardy / delete_aws_resources.rb
Created August 8, 2019 17:23
delete_aws_resources.rb
#!/usr/bin/ruby
# Assumptions.
# You have tagged your resources with a common tag. This tag is passed by the ENV var below.
# The security group name is the tag_name as well.
require 'aws-sdk-ec2'
tag_name = ENV['PT_tag_name']
@gregohardy
gregohardy / command
Last active March 19, 2020 10:50
Find and replace uri's recursively with sed
grep -rl '/utils' ./ | xargs gsed -i "s+/utils+/lib/utils+g"
@gregohardy
gregohardy / colours-bash.sh
Last active February 19, 2025 11:55
Bash colours/italics/bold for echo. (works in macos)
#/bin/bash
function bold()
{
echo "\033[1m${1}\033[22m"
}
function dim()
{
echo "\033[2m${1}\033[22m"