Skip to content

Instantly share code, notes, and snippets.

View amancevice's full-sized avatar
🐠
oh hello

Alexander Mancevice amancevice

🐠
oh hello
View GitHub Profile
@amancevice
amancevice / template.yml
Last active December 3, 2023 17:13
Serverless Slackbot CloudFormation Template
---
AWSTemplateFormatVersion: "2010-09-09"
Description: Serverless Slackbot
Parameters:
ApiBasePath:
Description: Slack app REST API base path
Type: String
Default: ""
DomainCertificateArn:
@amancevice
amancevice / # terraform - 2023-11-13_09-57-36.txt
Created November 13, 2023 15:14
terraform on macOS 14 - Homebrew build logs
Homebrew build logs for terraform on macOS 14
Build date: 2023-11-13 09:57:36
@amancevice
amancevice / # aws-sam-cli - 2023-10-18_11-31-07.txt
Created October 18, 2023 15:34
aws-sam-cli on macOS 14 - Homebrew build logs
Homebrew build logs for aws-sam-cli on macOS 14
Build date: 2023-10-18 11:31:07
@amancevice
amancevice / dotenv.sh
Last active February 20, 2022 13:40
Source .env file into new shell
#!/bin/sh
function dotenv() {
dotfile="${1:-.env}"
# Error if file does not exist
if ! [ -f $dotfile ] ; then
echo "$dotfile: No such file or directory" >&2
return 1
fi
@amancevice
amancevice / ubuntu.html
Created November 16, 2021 16:55
Embed font in AWS Step Functions SVG
<defs>
<style type="text/css">
@import url('https://fonts.googleapis.com/css2?family=Ubuntu');
.label { font-family: "Ubuntu", monospace; font-size: 12px; }
</style>
</defs>
@amancevice
amancevice / http.rb
Last active October 21, 2021 15:44
Send signed HTTP requests to AWS with Ruby
require 'net/http'
require 'aws-sdk-core'
##
# Example usage:
# uri = URI 'https://events.ksr.io/fizz/buzz'
# req = Net::HTTP::Post.new(uri, 'content-type' => 'application/json')
# Aws::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
# http.request(req, { fizz: 'buzz' }.to_json)
@amancevice
amancevice / rainbow
Last active September 16, 2021 16:51
Prints the color codes for 256 colors
#!/bin/bash
rainbow_base_colors() {
for y in {0..1} ; do
for x in {0..7} ; do
c=$(( $x + (8 * $y) ))
tput $t $c
printf " %3s " $c
done
printf '\e[0m\n'

Managing ENV with AWS SecretsManager for NodeJS

AWS SecretsManager is a service that allows you to store encrypted secrets in the cloud as raw strings or JSON docs.

Storing secrets as JSON allows you to store ENV settings, similar to a .env file.

Using the aws-sdk library for NodeJS, we can update our application's process.env with the encrypted environment.

Install AWS SDK

@amancevice
amancevice / terraform-use.md
Last active March 30, 2021 13:39
Terraform version switching

Terraform Version Switching

Add the following to your bash profile:

function terraform-use {
  vsn=$1
  pkg="terraform_${vsn}_darwin_amd64.zip"
  url="https://releases.hashicorp.com/terraform/$vsn/$pkg"
 tf="$( which terraform || echo /usr/local/bin/terraform )"
@amancevice
amancevice / dynamodb_hash.rb
Created March 30, 2021 13:37
DynamoDB item exploder/contractor
class Hash
def to_dynamodb
self.map { |k,v| [ k.to_s, self.to_dynamodb_item(v) ] }.to_h
end
def from_dynamodb
self.map { |k,v| [ k.to_s, self.from_dynamodb_item(v) ] }.to_h
end
private