Skip to content

feat(ecs): add hookDetails support for deployment lifecycle hooks#37698

Open
rgoltz wants to merge 6 commits into
aws:mainfrom
rgoltz:EcsServiceHookDetailsField
Open

feat(ecs): add hookDetails support for deployment lifecycle hooks#37698
rgoltz wants to merge 6 commits into
aws:mainfrom
rgoltz:EcsServiceHookDetailsField

Conversation

@rgoltz
Copy link
Copy Markdown
Contributor

@rgoltz rgoltz commented Apr 27, 2026

Issue # (if applicable)

N/A

Reason for this change

The AWS::ECS::Service CloudFormation resource supports a HookDetails field on DeploymentConfiguration.LifecycleHooks, but the CDK L2 construct does not expose it. This field allows passing custom parameters (as a JSON object) to lifecycle hook targets (e.g. Lambda functions) during ECS deployments.

Description of changes

  • Added hookDetails property (Record<string, unknown>) to DeploymentLifecycleLambdaTargetProps
  • Added hookDetails (string) to the internal DeploymentLifecycleHookTargetConfig interface
  • Serialization via Fn.toJsonString to correctly handle CDK tokens at synth time
  • Input validation ensuring only plain JSON objects are accepted (no arrays, primitives, or null)
  • Passed the serialized value through DeploymentLifecycleHookTargetConfig into base-service.ts

Note: When hookDetails contains CDK tokens (e.g. cdk.Aws.STACK_NAME), the synthesized template will use Fn::ToJsonString, which requires the AWS::LanguageExtensions transform. CDK adds this transform automatically.

Describe any new or updated permissions being added

None.

Description of how you validated changes

  • 6 new unit tests covering: happy path (nested objects), absence when undefined, CDK token resolution, rejection of arrays, primitives, and null
  • Updated existing integration test (integ.blue-green-deployment-strategy) to include hookDetails
  • Integration test deployed successfully with hook invocation confirmed
  • Updated README example

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions Bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Apr 27, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team April 27, 2026 09:36
@github-actions github-actions Bot added the p2 label Apr 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
This security report is NOT a review blocker. Please try merge from main to avoid findings unrelated to the PR.
To suppress a specific rule, see Suppressing Rules.


TestsPassed ☑️SkippedFailed ❌️
Security Guardian Results24 ran23 passed1 failed
TestResult
Security Guardian Results
packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.blue-green-deployment-strategy.js.snapshot/aws-ecs-blue-green-deployment.template.json
ec2-no-open-security-groups.guard❌ failure

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

⚠️ Experimental Feature: This security report is currently in experimental phase. Results may include false positives and the rules are being actively refined.
This security report is NOT a review blocker. Please try merge from main to avoid findings unrelated to the PR.
To suppress a specific rule, see Suppressing Rules.


TestsPassed ☑️SkippedFailed ❌️
Security Guardian Results with resolved templates24 ran23 passed1 failed
TestResult
Security Guardian Results with resolved templates
packages/@aws-cdk-testing/framework-integ/test/aws-ecs/test/base/integ.blue-green-deployment-strategy.js.snapshot/aws-ecs-blue-green-deployment.template.json
ec2-no-open-security-groups.guard❌ failure

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2 pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants