Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
LambdaでBilling Alertを拡張してみた
Search
Mamoru Ohashi
July 14, 2016
Technology
0
39
LambdaでBilling Alertを拡張してみた
JAWS-UG アーキテクチャ支部 クラウドネイティブ分科会#10
LT枠発表内容です。
Mamoru Ohashi
July 14, 2016
Tweet
Share
More Decks by Mamoru Ohashi
See All by Mamoru Ohashi
フルリモートワークはエンジニアの夢を叶えたか? #cm_odyssey
mamohacy
3
880
ソフトウェア開発子会社立ち上げのためのタスク管理術〜Asana活用で"混乱期"を乗り越える〜
mamohacy
3
700
NW-JAWS誕生秘話:シーズン1を終えるにあたって
mamohacy
1
210
リスキリングの特効薬!「技術コミュニティ」のススメ
mamohacy
2
1.8k
KDDIにおけるクラウド活⽤のあゆみ〜CCoEが率いる社内カルチャー変⾰〜
mamohacy
3
260
シゴトをジモトに運び込め〜大企業でCCoEやってた私が地元に事業所を作るまで〜
mamohacy
2
500
地域ICTクラブ 令和4年度 地域交流会 in 静岡(沼津)
mamohacy
1
740
コミュニティづくりは甘くない!〜亀田さんからの宿題回答編〜
mamohacy
2
180
SlideShareをやめて SpeakerDeckに移行します
mamohacy
1
2.9k
Other Decks in Technology
See All in Technology
IPA&AWSダブル全冠が明かす、人生を変えた勉強法のすべて
iwamot
PRO
2
150
ビズリーチにおけるリアーキテクティング実践事例 / JJUG CCC 2025 Spring
visional_engineering_and_design
1
130
オーティファイ会社紹介資料 / Autify Company Deck
autifyhq
10
130k
United airlines®️ USA Contact Numbers: Complete 2025 Support Guide
unitedflyhelp
0
310
OSSのSNSツール「Misskey」をさわってみよう(右下ワイプで私のOSCの20年を振り返ります) / 20250705-osc2025-do
akkiesoft
0
170
AWS認定を取る中で感じたこと
siromi
1
190
「クラウドコスト絶対削減」を支える技術—FinOpsを超えた徹底的なクラウドコスト削減の実践論
delta_tech
4
170
fukabori.fm 出張版: 売上高617億円と高稼働率を陰で支えた社内ツール開発のあれこれ話 / 20250704 Yoshimasa Iwase & Tomoo Morikawa
shift_evolve
PRO
2
7.8k
B2C&B2B&社内向けサービスを抱える開発組織におけるサービス価値を最大化するイニシアチブ管理
belongadmin
1
7.1k
LLM時代の検索
shibuiwilliam
2
180
自律的なスケーリング手法FASTにおけるVPoEとしてのアカウンタビリティ / dev-productivity-con-2025
yoshikiiida
1
17k
LangChain Interrupt & LangChain Ambassadors meetingレポート
os1ma
2
320
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
8
690
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
4 Signs Your Business is Dying
shpigford
184
22k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
How STYLIGHT went responsive
nonsquared
100
5.6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Done Done
chrislema
184
16k
Why Our Code Smells
bkeepers
PRO
336
57k
Building a Modern Day E-commerce SEO Strategy
aleyda
42
7.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
20k
Transcript
Mamoru Ohashi @mamohacy @mamohacy#20160714 LambdaでBilling Alertを 拡張してみた 〜 ⾮マネコン/⽇別31段階/無期限繰返通知 〜
2016.07.14
1 ⼤橋 衛(オオハシマモル) 1974/10/01(41歳) AWS Solution Architect(associate) アプリエンジニア12年 インフラエンジニア4年 クラウドエンジニア3年(=AWS歴)
2016/07現在、現在⼤⼿通信会社にて AWSコンサル/セキュリティ監査業務 家族︓妻、娘2⼈ 趣味︓スノーボード、読書、DIY 絶賛本名プレイ中 @mamohacy http://blog.mamohacy.com/ ⾃⼰紹介 @mamohacy#20160714
2 AWS Summit Tokyo 2016 に登壇しました @mamohacy#20160714 http://cloudblog.kddi.com/iaaspaas/4279/
使ってますか︖ Lambda
使ってますよ︕ Lambda
5 使ってますよ︕Lambda うちでは主に 「運⽤管理ツール」として使ってます ・Slackに投げた勤怠連絡をメールに転送 ・billing情報をSlackに通知 ・IAM管理統制とセキュリティ統制⾃動化 ・侵⼊テスト申請⾃動化 ・などなど @mamohacy#20160714
その中から今回は 「拡張版 Billing Alert」をご紹介︕
開発部⾨Y 開発部⾨X ⽀払アカウント @mamohacy#20160714 弊社のAWS利⽤費⽀払い管理 システムA 開発 商⽤ 検証 システムB
開発 システムC 開発/検 証 商⽤ AWS チーム 開発 部⾨ :AWSアカウント
7 Billingの課題 「予算策定は開発部⾨」 「⽀払とBilling Alert設定はAWSチーム」 p 各部⾨から予算情報を取得 p 予算情報/過去実績から閾値を算出・予測 p
アカウントAにBilling Alertを設定 p アカウントBにBilling Alertを設定 p アカウントCに・・・・ p あ、Alert⾶んだ。確認しなきゃ。 p え︖負荷試験中だから⼤丈夫︖そうですか・・・ p は︖来週に緊急リリース︖マジっすか︖ @mamohacy#20160714
@mamohacy#20160714 やってられるかァ︕
@mamohacy#20160714 ってことで Billing Alert を Lambda で 拡張してみました
10 純正Billing Alert機能の特徴 Ø 親の介在が必須 Ø ⼦側が簡単に扱えない @mamohacy#20160714 純正Billing Alertの特徴
ü要マネコン ü予算管理機能使えるのは親側だけ ü期間指定による閾値設定は出来ない üアラーム通知は閾値超過後の1回のみ
11 純正Billing Alert機能の特徴 Ø 親の介在は初期セットアップ時のみ Ø ⼦側が簡単に扱える @mamohacy#20160714 拡張版Billing Alertの特徴
üマネコン不要 ü⼦側で設定ファイルを作りS3アップロードすればOK ü⽉初からの経過⽇数毎に閾値を設定可能(Max31段階) ü閾値超過時は設定直すまで1時間おきにアラーム通知
12 アーキテクチャ @mamohacy#20160714 S3 bucket User confi g set billing
alarm reset alarm status Billing Alert CloudWatch email notification SNS upload invoke notify create 0:00/daily 0:00/hourly invoke invoke alarm アラーム状態の リセット Billing Alertの セット
13 config • ⽇毎に段階的に予算設定が可能 (最⼤31段階) • 実証実験中、負荷試験中、S-in、 キャンペーンなどのイベントに 合わせて予算を決め、ユーザー が⾃分⾃⾝でテキストファイル
をS3に保存する • configファイルを置かなければ Alert処理は無効になる @mamohacy#20160714 #day, threshold(USD) 10, 200 20, 400 ・・・・ 31, 600 aws_budget.txt
reset-alarm-status.py set-billing-alarm.py @mamohacy#20160714 コア・プログラム 43 steps(*include comments) 183 steps(*include comments)
15 ポイント その1 @mamohacy#20160714 cw_alarm_description = cw_alarm_description.replace("%THRESHOLD%", threshold) cw_alarm_action =
cw_alarm_action.replace("%ACCOUNT_ID%", account_id) #Alarmの設定 response = cloud_watch.put_metric_alarm(AlarmName=cw_alarm_name, AlarmDescription=cw_alarm_description, ActionsEnabled=True, AlarmActions=[cw_alarm_action], Namespace=cw_metric_namespace, MetricName=cw_metric_name, Statistic='Maximum', Dimensions=[ {'Name': 'Currency’, 'Value': 'USD’}, {'Name': 'LinkedAccount’, 'Value': account_id } ], Period=21600, EvaluationPeriods=1, Threshold=int(threshold), ComparisonOperator='GreaterThanThreshold' ) set-billing-alarm.py configから読んだ 閾値をalarmにセッ ト
16 ポイント その2 @mamohacy#20160714 alarm_name="Estimated Charges” # 実施要否判定() response =
cloud_watch.describe_alarms(AlarmNames=[alarm_name], StateValue='ALARM’) if len(response['MetricAlarms']) <= 0: return 0 # アラームステータスをリセット(強制的にアラームじゃない状態に戻す) response = cloud_watch.set_alarm_state(AlarmName=alarm_name, StateValue='INSUFFICIENT_DATA', StateReason='’,StateReasonData='{}’) return 0 reset-alarm-status.py 閾値超えてれば即 座にアラームが発 生!
17 拡張版 Billng Alertの導⼊効果 ü親による⼀括予算管理が不要に ü有効化/無効化の設定も⼦側で üAlert通知後の判断も⼦側からスタート (設定修正漏れ/恣意的/バグ/障害 etc...) 親アカウント側の予算管理&BillingBurst対応⼯数が
「実質ゼロ」 に︕ @mamohacy#20160714
@mamohacy#20160714 ご清聴ありがとうございました︕