Skip to content
4 changes: 4 additions & 0 deletions aws_lambda_powertools/utilities/data_classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
from .cloud_watch_custom_widget_event import CloudWatchDashboardCustomWidgetEvent
from .cloud_watch_logs_event import CloudWatchLogsEvent
from .cloudformation_custom_resource_event import CloudFormationCustomResourceEvent
from .code_deploy_lifecycle_hook_event import (
CodeDeployLifeCycleHookLambdaEvent,
)
from .code_pipeline_job_event import CodePipelineJobEvent
from .connect_contact_flow_event import ConnectContactFlowEvent
from .dynamo_db_stream_event import DynamoDBStreamEvent
Expand Down Expand Up @@ -59,6 +62,7 @@
"CloudWatchAlarmMetricStat",
"CloudWatchDashboardCustomWidgetEvent",
"CloudWatchLogsEvent",
"CodeDeployLifeCycleHookLambdaEvent",
"CodePipelineJobEvent",
"ConnectContactFlowEvent",
"DynamoDBStreamEvent",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from aws_lambda_powertools.utilities.data_classes.common import DictWrapper


class CodeDeployLifeCycleHookLambdaEvent(DictWrapper):
@property
def deployment_id(self) -> str:
"""The unique ID of the calling CodeDeploy Deployment."""
return self["DeploymentId"]

@property
def lifecycle_event_hook_execution_id(self) -> str:
"""The unique ID of a deployments lifecycle hook."""
return self["LifecycleEventHookExecutionId"]
4 changes: 4 additions & 0 deletions tests/events/codeDeployLifecycleHookEvent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"DeploymentId": "d-ABCDEF",
"LifecycleEventHookExecutionId": "xxxxxxxxxxxxxxxxxxxxxxxx"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from aws_lambda_powertools.utilities.data_classes import (
CodeDeployLifeCycleHookLambdaEvent,
)
from tests.functional.utils import load_event


@pytest.mark.parametrize(
"event_file",
[
"codeDeployLifecycleHookEvent.json",
],
)
def test_code_deploy_lifecycle_hook_event(event_file):
raw_event = load_event(event_file)
parsed_event = CodeDeployLifeCycleHookLambdaEvent(raw_event)

assert parsed_event.deployment_id == raw_event["DeploymentId"]
assert parsed_event.lifecycle_event_hook_execution_id == raw_event["LifecycleEventHookExecutionId"]