Help us understand the problem. What is going on with this article?

LambdaでCloudWatchLogsのログ保存期間を変更する

0. 筆者環境

AWS Lambda: Python 3.8

1. 概要

今回はCloudWatchLLogsの特定のロググループに対してログ保存期間の変更が必要になったので、
他環境への汎用も考えLambdaを叩けば一括で変更できるような仕組みを作った。

2. 使い方

Lambdaを作成、Lambdaの環境変数に以下を設定し実行。

days: 変更したいログ保存期間
pattern: 変更したいロググループの名前(正規表現)
region: 対象のリージョン(東京リージョンならap-northeast-1でよい)

image.png

3. こーど

Gistにあげることにしました。
簡素なコードなので以下挙動の概要のみ。

  1. ロググループを全て取得(get_Loggroups)
  2. ログ保存期間とロググループのlist作成(create_Policies)
  3. ログ保存期間設定(set_Logretention)

https://gist.github.com/tunalight/63d2f5260563de5103f844a1f4010b3d

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした