Skip to content

Instantly share code, notes, and snippets.

View liks79's full-sized avatar
😀

Sungshik Jou liks79

😀
View GitHub Profile
@liks79
liks79 / 0-README.md
Created June 2, 2017 05:15 — forked from alexcasalboni/0-README.md
AWS Lambda: Advanced Coding Session - clda.co/aws-lambda-webinar

AWS Lambda: Advanced Coding Session (slides)

Live demos:

  1. Amazon API Gateway Access Control
  2. Amazon Kinesis Streams processing
  3. Amazon Cognito Sync trigger
  4. AWS CloudFormation Custom Resources
sudo curl -o /usr/local/bin/imgcat -O https://raw.githubusercontent.com/gnachman/iTerm2/master/tests/imgcat && sudo chmod +x /usr/local/bin/imgcat
# If you have a better way to fix the permissions, comment below!
@liks79
liks79 / lotto.py
Created April 28, 2017 03:57
lotto function for MAC OS
## 'say' command is needed. (only Mac OS available)
students = ['뽀로로','포비','크롱','루피','페티']
def lotto(students):
import random,os
random.shuffle(students)
try:
msg = students[0] + '님, 축하드립니다!'
print (msg)
@liks79
liks79 / get_aws_pub_ip.sh
Created February 10, 2017 05:24
get AWS public IP address range
# public ip for ap-northeast-1 / EC2
curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | if .service == "EC2" then . else empty end' | jq -r '. | if .region == "ap-northeast-1" then .ip_prefix else empty end'
@liks79
liks79 / ext_limit_policy.json
Created January 31, 2017 02:16
S3 bucket policy for limit file extention.
{
"Version": "2012-10-17",
"Id": "Policy1484600284333",
"Statement": [
{
"Sid": "Stmt1484600282259",
"Effect": "Deny",
"Principal": "*",
"Action": [
"s3:PutObject",
@liks79
liks79 / troposphere_example.py
Last active December 30, 2016 05:19
CloudFormation Troposphere example
from troposphere import Ref, Template
import troposphere.ec2 as ec2
t = Template()
instance = ec2.Instance("myinstance")
instance.ImageId = "ami-951945d0"
instance.InstanceType = "t1.micro"
t.add_resource(instance)
@liks79
liks79 / aws_kms.py
Created December 19, 2016 06:12
AWS KMS enc/dec code snippet
import boto3
keyId = '<Key ARN>'
text = 'Hello Cloud!'
kms = boto3.client('kms', region_name='ap-northeast-1')
enc = kms.encrypt(KeyId = keyId, Plaintext = text)['CiphertextBlob']
print (enc)
dec = kms.decrypt(CiphertextBlob = enc)['Plaintext']
@liks79
liks79 / presign.sh
Created December 18, 2016 07:42
Using S3 presign URL
aws configure set default.s3.signature_version s3v4
aws s3 presign s3://<bucket name>/<file name> --expires-in 30
@liks79
liks79 / custom_metric.sh
Created December 18, 2016 07:40
Send a custom metric value to AWS CloudWatch
aws cloudwatch put-metric-data --namespace "MyService" --metric-name "UserCount" --value 2000
@liks79
liks79 / send_sms.py
Created December 18, 2016 07:38
Send a SMS via AWS SNS
import boto3
client = boto3.client('sns', region_name='ap-northeast-1')
msg = 'Hello World'
number = '+821011112222'
client.publish(PhoneNumber=number, Message=msg)