Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / gist:4cc9e5d60fe546ffbd73870379fb5f64
Created November 30, 2016 21:58
CloudFormation / CreationPolicy / Minimal EC2 example
{
"Resources": {
"SSHServerSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"VpcId" : "vpc-fdcfd098",
"GroupDescription" : "Allow SSH access",
"SecurityGroupIngress" : [
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "<REDACTED>/32"}
]
@SteveHoggNZ
SteveHoggNZ / gist:9a58f2dba8e2205f84be33a706b052a9
Created December 1, 2016 00:26
CloudFormation / CreationPolicy / AutoScalingGroup example
{
"Resources": {
"AutoScalingGroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"AvailabilityZones": { "Fn::GetAZs": "" },
"LaunchConfigurationName": { "Ref": "LaunchConfig" },
"DesiredCapacity": "2",
"MinSize": "1",
"MaxSize": "4"
@SteveHoggNZ
SteveHoggNZ / gist:2319b3bf3c30a2f1876c0dbf7aaba5c6
Created December 1, 2016 06:44
CloudFormation / WaitCondition / WaitConditionHandler example
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Mappings" : {
"RegionMap" : {
"us-east-1" : {
"AMI" : "ami-76f0061f"
},
"us-west-1" : {
"AMI" : "ami-655a0a20"
},
@SteveHoggNZ
SteveHoggNZ / gist:bdc55a1a6c633346f44620f1a9a9d848
Created December 1, 2016 22:50
CloudFormation / DeletionPolicy example
{
"Resources": {
"myS3Bucket": {
"Type" : "AWS::S3::Bucket",
"Properties" : {},
"DeletionPolicy" : "Retain"
},
"myEBSVolume": {
"Type":"AWS::EC2::Volume",
"Properties" : {
@SteveHoggNZ
SteveHoggNZ / gist:cd3855a329632a3c3934adb80a5a646d
Created December 2, 2016 00:02
CloudFormation / Nested stack example
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Master template that includes nested templates",
"Parameters": {
"DeployBastion": {
"Description": "Should a bastion server be deployed?",
"Default": "No",
"Type": "String",
"AllowedValues": ["No", "Yes"]
}
@SteveHoggNZ
SteveHoggNZ / gist:3347bf2ab30f16a29b44c936ebcdd39a
Created December 2, 2016 00:12
CloudFormation / Nested stack bastion example
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "EC2 Bastion Server",
"Parameters": {
"VpcId": {
"Type": "AWS::EC2::VPC::Id",
"Description": "The VPC ID"
},
"DeployBastion": {
"Description": "Should a bastion server be deployed?",
@SteveHoggNZ
SteveHoggNZ / gist:222a8216ce0bbb6943b2d1029274b75d
Created January 20, 2017 02:49
CloudFormation / Public-readable bucket policy
"MyS3BucketPolicy": {
"Type": "AWS::S3::BucketPolicy",
"Properties": {
"Bucket": { "Ref": "MyS3Bucket" },
"PolicyDocument" : {
"Version":"2012-10-17",
"Statement":[{
"Sid": "PublicReadAccess",
"Effect": "Allow",
"Principal": "*",