This file contains 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 subprocess | |
def lambda_handler(event, context): | |
""" | |
Amazon Linux release 2 (Karoo) | |
runtime: python3.8 | |
date: 2020/05/28 | |
""" | |
proc = subprocess.run(['cat', '/etc/system-release'], stdout = subprocess.PIPE) | |
print(proc.stdout.decode("utf8")) |
This file contains 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 sys | |
import argparse | |
class Command: | |
def __init__(self, args): | |
parser = argparse.ArgumentParser(description='class sample') | |
parser.add_argument('--main', '-m', action='store_true', help='main command from class') | |
self.parser = parser | |
try: |
This file contains 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
_SKILL_JSON_PATH = os.getenv('SKILL_JSON', 'skill.json') | |
_SKILL_NAME = os.getenv('SKILL_NAME', '') | |
def get_skill_name(locale: str = 'ja-JP') -> str: | |
""" | |
Priority | |
1. skill.json "manifest.publishingInformation.locales.{your-locale}.name" | |
2. environment valuable from "lambda" | |
3. from python |
This file contains 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
CREATE EXTERNAL TABLE IF NOT EXISTS default.table | |
( | |
`id` int, | |
`name` string, | |
`timestamp` string, | |
`is_debug` boolean | |
) | |
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde' | |
WITH SERDEPROPERTIES ( | |
'escapeChar'='\\', |
This file contains 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 | |
import os | |
import boto3 | |
import botocore | |
def handler(event, context): | |
bucket = os.environ.get('BUCKET') | |
key = os.environ.get('KEY') |
This file contains 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 | |
LAMBDA_NAME="your-lambda-name" | |
cd venv/lib/python3.7/site-packages | |
zip -r9 ${OLDPWD}/function.zip . | |
cd ${OLDPWD} | |
cd ./lambda/custom/ | |
zip -g ../../function.zip your_function.py | |
cd ${OLDPWD} | |
aws lambda update-function-code \ | |
--function-name ${LAMBDA_NAME} \ |
This file contains 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
#!/bin/bash | |
# $ crontab -l | |
# * 23 * * * bash /path/to/s3_uploader.sh | |
# $ which aws | |
# /usr/local/bin/aws | |
# Add path to aws cli | |
PATH=$PATH:/usr/local/bin |