Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
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
60
今の私を形作る4つの要素と偶然の出会い(セレンディピティ)
mamohacy
2
180
フルリモートワークはエンジニアの夢を叶えたか? #cm_odyssey
mamohacy
3
1k
ソフトウェア開発子会社立ち上げのためのタスク管理術〜Asana活用で"混乱期"を乗り越える〜
mamohacy
3
1k
NW-JAWS誕生秘話:シーズン1を終えるにあたって
mamohacy
1
300
リスキリングの特効薬!「技術コミュニティ」のススメ
mamohacy
2
2.1k
KDDIにおけるクラウド活⽤のあゆみ〜CCoEが率いる社内カルチャー変⾰〜
mamohacy
3
510
シゴトをジモトに運び込め〜大企業でCCoEやってた私が地元に事業所を作るまで〜
mamohacy
2
630
地域ICTクラブ 令和4年度 地域交流会 in 静岡(沼津)
mamohacy
1
930
Other Decks in Technology
See All in Technology
2026-09-04 SRE Tech Talk #15 怠惰なTerraform / Lazy Terraform
masasuzu
0
230
全員がプロダクトへ向き合う組織を持続成長させるために——組織づくりのフライホイールと4象限 / The Flywheel Model and Four Quadrants for Organizational Design
hiro_torii
4
930
synctest時代のhttptest Go 1.27で変わるHTTPサーバテストの裏側 / go conference2026 synctest and httptest
budougumi0617
1
320
PfEingのアプローチで働こう
rindrics
0
200
Adaptive Warehouse を今すぐ導入すべき理由と迷ったときの判断基準
__allllllllez__
0
130
AI時代におけるプロダクト横断勉強会の設計
zozotech
PRO
0
170
2026/09/10 Spring_Bootから_Jakarta_EE_MicroProfileへの移行
megascus
0
260
「重なり」は迎える側がつくる ― 人もAIエージェントも歓迎するプロダクトエンジニアリング ―
go0517go
PRO
0
270
AIに丸投げしないトイル削減 / Eliminating Toil Without Leaving It All to AI
kohbis
4
1k
module Synths; end
asonas
1
130
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
3
400
AI時代に、プロダクトの数だけ積み上がる所有コストをどうエンジニアリングするか / Engineering the Cost of Ownership
kzkmaeda
1
1.1k
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
470
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Navigating Team Friction
lara
192
16k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
380
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
410
Chasing Engaging Ingredients in Design
codingconduct
0
300
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
540
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 ご清聴ありがとうございました︕