Skip to content

Commit

Permalink
chore(ci): reduce payload and only send prod notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Melnyk committed Aug 9, 2022
1 parent 8abf6ec commit a71a0e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
18 changes: 14 additions & 4 deletions layer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,22 @@

if not POWERTOOLS_VERSION:
raise ValueError(
"Please set the version for Powertools by passing the '--context=version:<version>' parameter to the CDK "
"Please set the version for Powertools by passing the '--context version=<version>' parameter to the CDK "
"synth step."
)

LayerStack(app, "LayerStack", powertools_version=POWERTOOLS_VERSION, ssm_paramter_layer_arn=SSM_PARAM_LAYER_ARN)

CanaryStack(app, "CanaryStack", powertools_version=POWERTOOLS_VERSION, ssm_paramter_layer_arn=SSM_PARAM_LAYER_ARN)
LayerStack(
app,
"LayerStack",
powertools_version=POWERTOOLS_VERSION,
ssm_paramter_layer_arn=SSM_PARAM_LAYER_ARN,
)

CanaryStack(
app,
"CanaryStack",
powertools_version=POWERTOOLS_VERSION,
ssm_paramter_layer_arn=SSM_PARAM_LAYER_ARN,
)

app.synth()
13 changes: 9 additions & 4 deletions layer/layer/canary/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def on_create(event):


def check_envs():
logger.info('Checking required envs ["POWERTOOLS_LAYER_ARN", "AWS_REGION", "STAGE"]')
logger.info(
'Checking required envs ["POWERTOOLS_LAYER_ARN", "AWS_REGION", "STAGE"]'
)
if not layer_arn:
raise ValueError("POWERTOOLS_LAYER_ARN is not set. Aborting...")
if not powertools_version:
Expand Down Expand Up @@ -73,17 +75,20 @@ def send_notification():
"""
sends an event to version tracking event bridge
"""
if stage != "PROD":
logger.info(
"Not sending notification to event bus, because this is not the PROD stage"
)
return
event = {
"Time": datetime.datetime.now(),
"Source": "powertools.layer.canary",
"EventBusName": event_bus_arn,
"DetailType": "deployment",
"Detail": json.dumps(
{
"id": "powertools-python",
"stage": stage,
"region": os.environ["AWS_REGION"],
"version": powertools_version,
"region": os.environ["AWS_REGION"],
"layerArn": layer_arn,
}
),
Expand Down

0 comments on commit a71a0e5

Please sign in to comment.