Skip to content

Instantly share code, notes, and snippets.

@SteveHoggNZ
SteveHoggNZ / minimal-custom-resource-hander.py
Created November 29, 2016 06:35
CloudFormation / CustomResource / minimal Python Lambda function for logging resource update requests
from __future__ import print_function
import json
import logging
import urllib2
logger = logging.getLogger()
logger.setLevel(logging.INFO)
SUCCESS = 'SUCCESS'
@SteveHoggNZ
SteveHoggNZ / mfa-cli-users.json
Created November 24, 2016 23:37
AWS / MFA + CLI / CloudFormation / Example / Users
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"BarbaraUser" : {
"Type": "AWS::IAM::User",
"Properties": {
"Groups": [ { "Fn::ImportValue": "MFAGroupsStack-BossGroup" } ],
"UserName": "barbara"
}
},
@SteveHoggNZ
SteveHoggNZ / mfa-cli-groups.json
Created November 24, 2016 23:36
AWS / MFA + CLI / CloudFormation / Example / Groups
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"BossRole" : {
"Type": "AWS::IAM::Role",
"Properties": {
"RoleName": "BossRole",
"AssumeRolePolicyDocument": {
"Version" : "2012-10-17",
"Statement": [ {
@SteveHoggNZ
SteveHoggNZ / company-shared-storage.json
Created November 24, 2016 23:34
AWS / MFA + CLI / CloudFormation / Example / Company Shared Storage
{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"CompanySharedBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName" : "h4-company-bucket"
}
},
},
@SteveHoggNZ
SteveHoggNZ / aws-cloudformation-snippets.json
Created November 23, 2016 03:21
AWS CloudFormation Snippets
// Get the Arn from a resource
"Principal": {
"AWS": { "Fn::GetAtt": [ "BarbaraBossUser", "Arn" ] }
},
@SteveHoggNZ
SteveHoggNZ / mfa-roles-cli-users-groups-roles.json
Created November 23, 2016 02:42
MFA-Roles-On-CLI: CloudFormation template for users, groups and roles - JSON
{}
@SteveHoggNZ
SteveHoggNZ / aws-cli-jq.sh
Last active June 24, 2020 21:44
Examples of AWS CLI using JQ
# jq reference: https://stedolan.github.io/jq/manual
# Get a list of each Lambda function that starts with ^test and output that as an array
# i.e. take the contents of the .Functions[] list, select the ones that have a .FunctionName property that
# starts with test, and record the .FunctionName value
aws lambda list-functions | jq '[ .Functions[] | select(.FunctionName | test("^test")) | .FunctionName ]'
# Create an array of new maps for Lambda functions
aws lambda list-functions | jq '[ .Functions[] | select(.FunctionName | test("^test")) | {name: .FunctionName, memory: .MemorySize} ]'
@SteveHoggNZ
SteveHoggNZ / Examples.js
Created May 10, 2016 23:26
React Notes
// Don't use fat arrow functions as props in pure components, use a named function instead e.g.
export const ChoiceKey = (props: Props) => {
const keyClickHandler = () => {
props.keyClick(props.id)
}
return <div className={classes.choiceKey}
onClick={keyClickHandler}>Choice Key {props.id}</div>
}
@SteveHoggNZ
SteveHoggNZ / gist:11b5209e2b00e38b54a3c921c2f39b8f
Created May 7, 2016 05:38
bash - filtered output to file and stdout
echo '1
2
3
4
LOG: 5
6
LOG: 7' | tee >(grep LOG | sed 's/LOG: //' > tmp.txt)
// shorthand for result that is a promise
it(() => {
return expect(result)
.to.eventually.deep.equal({url, options})
})
// ... longhand, which handles multiple promises in a test, and is
// easier to debug (by inserting console.log in then handler)
it(() => {
return Promise.all([