0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS GuardDutyをBoto3で有効化

0
Posted at

AWS GuardDutyをBoto3で有効化


AWS GuardDutyをGUIで有効化する場合、各リージョン毎でGUIによる
操作が必要(2019年5月時点)。

とても面倒なのでBoto3で自動的に有効化するスクリプトを書いた。
各リージョンのEC2を監視するコードにGuardDutyをEnableにする
コードに入れ替えただけ。

import boto3

ec2 = boto3.client('ec2')
regions = map(lambda x: x['RegionName'], ec2.describe_regions()['Regions'])

for region in regions:
    
    if region == 'ap-northeast-1':
        print('hello')
        
    else:
        
        client = boto3.client('guardduty', region_name=region)
    
        print(region)

        response = client.create_detector(
                ClientToken='string',
                Enable=True,
                FindingPublishingFrequency='SIX_HOURS'
                )

        print(response)

その他


なぜかGUIで有効化した東京リージョン(ap-northeast-1)のみエラーを返すため
東京リージョンを除外している。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?