Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Karsten Lang klang

🏠
Working from home
View GitHub Profile
View cloudtrail-unique-users.sh
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=UserAuthentication | jq '.Events|.[]|.Username' | sort | uniq
@klang
klang / bucket1.yaml
Created Jun 2, 2021
S3Bucket with notification
View bucket1.yaml
Resources:
Bucket:
Type: AWS::S3::Bucket
View s3_object
{
"Version": "2012-10-17",
"Id": "Policy1610637024575",
"Statement": [
{
"Sid": "Stmt1610637009631",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": [
@klang
klang / bettervpc.yaml
Last active Feb 5, 2021
simple vpc with a windows instance
View bettervpc.yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: "Simple VPC with one public subnet and one instance - access via ssm, rds (and port 80)"
Parameters:
KeyName:
Type: AWS::EC2::KeyPair::KeyName
Description: Name of an existing EC2 KeyPair to enable SSH/RDP access to the instance
VPCCIDR:
Type: String
Description: VPC address range
@klang
klang / readme.md
Last active Feb 4, 2021
The AWS E-learning course "Creating an IAM Role for AWS Partner-Led Support" describes how to make a specific support role, but doesn't provide the actual template. This is an advanced way to roll out the role needed, in a multi account structure.
View readme.md

The AWS E-learning course "Creating an IAM Role for AWS Partner-Led Support" describes how to make a specific support role, but doesn't provide the actual template.

This is an advanced way to roll out the role needed, in a multi account structure. If the Partner-Led customer is using AWS ControlTower or AWS LandingZone or some other home baked control mechanism under AWS Organizations, a StackSet is probably the way to go.

@klang
klang / readme.md
Last active Oct 16, 2020
Using AWS::SSM::Parameter to break AWS CloudFormation dependencies
View readme.md
View AWSLandingZoneAdminExecutionRolesParameter.yaml
---
Parameters:
RootAccountID:
Type: String
Description: AccountID for the Organization hosting the Automated Landing Zone Stack Sets
AWSTemplateFormatVersion: '2010-09-09'
Resources:
AWSCloudFormationStackSetExecutionRole:
Type: AWS::IAM::Role
View AWSCloudFormationStackSetExecutionRole.yaml
---
Parameters:
RootAccountID:
Type: String
Description: AccountID for the Organization hosting the Automated Landing Zone Stack Sets
AWSTemplateFormatVersion: '2010-09-09'
Resources:
AWSCloudFormationStackSetExecutionRole:
Type: AWS::IAM::Role
@klang
klang / variables.tf
Created Jun 21, 2019
Terraform 0.12+ does not support "."'s in hash keys
View variables.tf
locals {
project = "project-name"
env = {
# default.name = "default-workspace-name" # <= tf0.11 notation
default_name = "default-workspace-name" # <= tf0.12 notation
# other.name = "other-workspace-name"
other_name = "other-workspace-name"
}
name = "${lookup(local.env, "${terraform.workspace}_name")}"
}
@klang
klang / .bashrc
Created Feb 26, 2018
resolve dns via local hosts file
View .bashrc
function resolve {
hostfile=~/.hosts
if [[ -f "$hostfile" ]]; then
for arg in $(seq 1 $#); do
if [[ "${!arg:0:1}" != "-" ]]; then
ip=$(sed -n -e "/^\s*\(\#.*\|\)$/d" -e "/\<${!arg}\>/{s;^\s*\(\S*\)\s*.*$;\1;p;q}" "$hostfile")
if [[ -n "$ip" ]]; then
command "${FUNCNAME[1]}" "${@:1:$(($arg-1))}" "$ip" "${@:$(($arg+1)):$#}"
return
fi