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
50
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
LambdaでBilling Alertを拡張してみた
JAWS-UG アーキテクチャ支部 クラウドネイティブ分科会#10
LT枠発表内容です。
Mamoru Ohashi
July 14, 2016
More Decks by Mamoru Ohashi
See All by Mamoru Ohashi
三島市移住アンバサダー卒業報告会 〜まもはしぃの4年間のぜんぶと、これから〜
mamohacy
1
44
今の私を形作る4つの要素と偶然の出会い(セレンディピティ)
mamohacy
2
180
フルリモートワークはエンジニアの夢を叶えたか? #cm_odyssey
mamohacy
3
1k
ソフトウェア開発子会社立ち上げのためのタスク管理術〜Asana活用で"混乱期"を乗り越える〜
mamohacy
3
990
NW-JAWS誕生秘話:シーズン1を終えるにあたって
mamohacy
1
290
リスキリングの特効薬!「技術コミュニティ」のススメ
mamohacy
2
2.1k
KDDIにおけるクラウド活⽤のあゆみ〜CCoEが率いる社内カルチャー変⾰〜
mamohacy
3
500
シゴトをジモトに運び込め〜大企業でCCoEやってた私が地元に事業所を作るまで〜
mamohacy
2
620
地域ICTクラブ 令和4年度 地域交流会 in 静岡(沼津)
mamohacy
1
920
Other Decks in Technology
See All in Technology
Data Hubグループ 紹介資料
sansan33
PRO
0
3.2k
ハーレムエンジニアリング
kazuma777777
0
180
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
5k
Goでデータパイプラインを作ろう
sansantech
PRO
1
510
Bill One 開発エンジニア 紹介資料
sansan33
PRO
7
20k
認知負荷をGemini で溶かす — GKE 基盤「Orbit」における AI エージェントの実践
sansantech
PRO
1
320
え?フロントエンドエンジニアの ワイがインフラも!?
puku0x
1
740
JavaScript 研修 (2026)
recruitengineers
PRO
2
620
20260807_第6回_関東kaggler会LT_claw系bot xangiと始める、"寂しくない" kaggle
sugupoko
0
330
生成 AI の基礎 〜 サンプル実装で学ぶ基本原理
enakai00
7
4.4k
ガバメント AI 源内を地方自治体は活用できるのか可能性と課題、期待について
takeda_h
2
440
Head First モブプログラミング / Head First Mobprogramming
takaking22
10
12k
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
470
The Language of Interfaces
destraynor
162
27k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Fireside Chat
paigeccino
42
4k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
660
Unsuck your backbone
ammeep
672
58k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Building Applications with DynamoDB
mza
96
7.2k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Chasing Engaging Ingredients in Design
codingconduct
0
270
Building Better People: How to give real-time feedback that sticks.
wjessup
370
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 ご清聴ありがとうございました︕