Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge pull request #112 from zalando-stups/vpc-flow-log-retention
Browse files Browse the repository at this point in the history
Support setting vpc flow log retention time
  • Loading branch information
mikkeloscar authored Jun 11, 2021
2 parents bc3ee9b + 1846777 commit 509364d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions sevenseconds/config/cloudwatch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
def configure_log_group(session: object, region: str):
client = session.client('logs', region)
logs = client.describe_log_groups(logGroupNamePrefix='vpc-flowgroup')['logGroups']
def configure_log_group(session: object, region: str, config: dict):
retention_in_days = config.get("vpc", {}).get("flow_logs_retention_in_days", 3653)
client = session.client("logs", region)
logs = client.describe_log_groups(logGroupNamePrefix="vpc-flowgroup")["logGroups"]
for log in logs:
if log.get('logGroupName', '') == 'vpc-flowgroup':
if log.get("logGroupName", "") == "vpc-flowgroup":
if log.get("retentionInDays", 0) != retention_in_days:
client.put_retention_policy(
logGroupName="vpc-flowgroup",
retentionInDays=retention_in_days,
)
return
client.create_log_group(logGroupName='vpc-flowgroup')
client.create_log_group(logGroupName="vpc-flowgroup")
client.put_retention_policy(
logGroupName="vpc-flowgroup",
retentionInDays=retention_in_days,
)
2 changes: 1 addition & 1 deletion sevenseconds/config/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def configure_account_region(account: object, region: str, shared_data: SharedDa
base_images = shared_data.base_images.get(region, {})
default_base_ami = base_images[account.config['base_ami']['default_channel']]

configure_log_group(account.session, region)
configure_log_group(account.session, region, account.config)
configure_acm(account, region)
configure_kms_keys(account, region)
configure_ebs_encryption(account, region)
Expand Down

0 comments on commit 509364d

Please sign in to comment.