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 boto3 | |
import datetime | |
def lambda_handler(event, context): | |
# タイムゾーンの生成 | |
JST = timezone(timedelta(hours=+9), 'JST') | |
now = datetime.now(JST) | |
print(now.strftime("%Y/%m/%d")) #2018/10/02 |
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 DATABASE データベース名 |
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 データベース名.テーブル名 ( | |
version int, | |
account string, | |
interfaceid string, | |
sourceaddress string, | |
destinationaddress string, | |
sourceport int, | |
destinationport int, | |
protocol int, | |
numpackets int, |
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
ALTER TABLE ap_northeast_1 | |
ADD PARTITION (dt='2018/10/01') | |
location 's3://バケット名/AWSLogs/アカウント番号/vpcflowlogs/ap-northeast-1/2018/10/01'; |
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
SELECT * FROM "データベース名"."テーブル名" | |
where | |
dt = '2018/10/01' | |
order by numbytes desc limit 10 |
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
try: | |
# 処理 | |
expect Exception as e: | |
if str(e) = 'エラー文': | |
pass | |
else: | |
print(e) |
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
try: | |
# 処理 | |
expect client.expections.ClientError as e: | |
pass |