Skip to content

Commit

Permalink
Add check to skip toggling CloudWatch alarms
Browse files Browse the repository at this point in the history
  • Loading branch information
krysal committed Jan 19, 2024
1 parent ce5424f commit 8467b5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions catalog/dags/common/cloudwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import boto3
from botocore.exceptions import ClientError
from airflow.models import Variable

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -48,6 +49,11 @@ def enable_alarm_actions(self, alarm_name, enable):


def enable_or_disable_alarms(enable):
skip_toggling = Variable.get("SKIP_TOGGLING_CLOUDWATCH_ALARMS", False)
if skip_toggling:
logger.info("Skipping toggling CloudWatch alarms.")
return

cw_wrapper = CloudWatchWrapper(boto3.resource("cloudwatch"))

sensitive_alarms_list = [
Expand Down
3 changes: 3 additions & 0 deletions catalog/env.template
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ AWS_SECRET_ACCESS_KEY=test_secret
AWS_DEFAULT_REGION=us-east-1
# General bucket used for TSV->DB ingestion and logging
OPENVERSE_BUCKET=openverse-storage
# Whether to toggle production CloudWatch alarms when running a data refresh DAG.
# Used to prevent requiring AWS credentials when running locally.
AIRFLOW_VAR_SKIP_TOGGLING_CLOUDWATCH_ALARMS=false
# Seconds to wait before poking for availability of the data refresh pool when running a data_refresh
# DAG. Used to shorten the time for testing purposes.
DATA_REFRESH_POKE_INTERVAL=5
Expand Down

0 comments on commit 8467b5d

Please sign in to comment.