Skip to content

Instantly share code, notes, and snippets.

@ryohang
ryohang / datalake_s3.yaml
Created June 16, 2021 20:25
LakeFormation Cross Account Data Catalog https://youtu.be/jxa6eEO54dI
AWSTemplateFormatVersion: "2010-09-09"
Description: Share S3 as data location to Lake Formation main account
Parameters:
DataS3Bucket:
Description: Name of your data S3 bucket
Type: String
Resources:
DataLocationBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
@ryohang
ryohang / cloudfront-with-lambda.yml
Created August 6, 2020 17:36
cloudformation-for-cloudfront-content-delivery-customization reference video https://youtu.be/3Nwma7W3uiw
Parameters:
PrerenderToken:
Type: String
Resources:
WebBucket:
Type: "AWS::S3::Bucket"
Properties:
AccessControl: PublicRead
WebsiteConfiguration:
ErrorDocument: index.html
@ryohang
ryohang / termination-wrap.sh
Last active July 26, 2017 14:50
cron job check spot instance 2 minutes termination to deregister from application load balancer target group
#!/bin/bash
echo "start spot termination check"
meta_url=http://169.254.169.254/latest/meta-data
if curl -s $meta_url/spot/termination-time | grep -q .*T.*Z; then
target_group=${tgARN};
role_arn='${role}'
keyId=`curl -s $meta_url/iam/security-credentials/$role_arn | python -c "import sys, json; obj = json.load(sys.stdin); print(obj['AccessKeyId'])"`
secretKey=`curl -s $meta_url/iam/security-credentials/$role_arn | python -c "import sys, json; obj = json.load(sys.stdin); print(obj['SecretAccessKey'])"`
token=`curl -s $meta_url/iam/security-credentials/$role_arn | python -c "import sys, json; obj = json.load(sys.stdin); print(obj['Token'])"`
export AWS_ACCESS_KEY_ID=$keyId
@ryohang
ryohang / 404.html
Last active August 29, 2015 14:20 — forked from cbednarski/404.html
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
background-color: #333;
font: 60px 'Helvetica, Arial, Ubuntu, sans-serif';
color: #111;
}
h1 {
@ryohang
ryohang / maven_pom_file_for_jmvc_project
Created July 5, 2012 19:52 — forked from nafeger/maven_pom_file_for_jmvc_project
A maven pom file for the project
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>StaticContent</artifactId>
<packaging>jar</packaging>
<name>StaticContent</name>
<version>${version.properties}</version>
<url>http://maven.apache.org</url>
<build>
<plugins>
def patiently(&block)
cycles = 0
begin
yield
rescue => e
cycles += 1
sleep 0.1
if cycles < 10
retry
else