This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for f in *.yaml; do | |
printf "Check ${f}..." | |
aws cloudformation validate-template --template-body "file://${f}" > /dev/null 2>&1 | |
if [ "$?" != "0" ]; then | |
echo "\n${f} failed, run following for details" | |
echo " aws cloudformation validate-template --template-body file://${f}\n\n" | |
exit 1 | |
fi | |
printf " [OK]\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pushed = 0 | |
namespace = 'my cw space' | |
while pushed < len(metric_data): | |
left = pushed | |
if len(metric_data) - pushed >= 20: | |
right = left + 20 | |
else: | |
right = len(metric_data) | |
pushed += (right - left) | |
to_push = metric_data[left:right] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ap-northeast-1": "Asia Pacific (Tokyo)", | |
"ap-northeast-2": "Asia Pacific (Seoul)", | |
"ap-southeast-1": "Asia Pacific (Singapore)", | |
"ap-southeast-2": "Asia Pacific (Sydney)", | |
"ap-south-1": "Asia Pacific (Mumbai)", | |
"eu-central-1": "EU (Frankfurt)", | |
"eu-north-1": "Europe (Stockholm)", | |
"eu-west-1": "EU (Ireland)", | |
"eu-west-2": "Europe (London)", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isolate_binary() { | |
binary=$(which $1) | |
libs=$(ldd -v $binary | grep -o '/.*[[:space:]]') | |
libs=($libs) | |
mkdir -p ${2}$(dirname $binary) | |
cp -vn ${binary} ${2}${binary} | |
for l in "${libs[@]}"; do mkdir -p ${2}$(dirname $l) && cp -vn ${l} ${2}${l}; done | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import json | |
def handler(payload, context): | |
try: | |
response = CustomResourceResponse(payload) | |
# follow rule 2 - alway log the paylod | |
logging.info(json.dumps(payload)) | |
## TODO: handle request from CFN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_physical_id(r_properties): | |
""" Generated resource id """ | |
bucket = r_properties['Bucket'] | |
key = r_properties['Key'] | |
return f's3://{bucket}/{key}' | |
def cr_handler(event, context): | |
""" | |
Create, Update or Remove S3 object | |
as Custom Resource for AWS CloudFormation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
physical_id = get_physical_id(event) | |
if request_type == 'Create' or request_type == 'Update: | |
if resource_exists(physical_id): | |
print(f'{physical_id} will be overwritten') | |
create_resource() | |
response.success(physical_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parameters: | |
DeployCustomResource: | |
Type: String | |
Default: false | |
AllowedValues: [true, false] | |
Conditions: | |
DeployCustomResource: !Equals [ !Ref DeployCustomResource, 'true' ] | |
Resources: | |
# .. other definitions including backing lambda | |
MyCustomResource: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def handler(event, payload): | |
print(json.dumps(event)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from urllib.request import urlopen, Request, HTTPError, URLError | |
import json | |
logger = logging.getLogger() | |
class CustomResourceResponse: | |
def __init__(self, event): | |
self.event = event | |
self.response = { |