Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): ecs hotswap fails on log configuration enabled (#26876)
## Problem ECS hotswap fails on a task definition containing log configuration like the following. ```ts const taskDefinition = new ecs.FargateTaskDefinition(stack, 'Task', {}); taskDefinition.addContainer('EcsApp', { image: ecs.ContainerImage.fromRegistry('nginx:stable'), logging: ecs.LogDriver.awsLogs({ streamPrefix: 'log' }), }); ``` ## Root cause When we transform object keys in a task definition, we pass `excludeFromTransform` to avoid from transforming keys with arbitrary string, such as [`logDriver.options`](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_LogConfiguration.html#ECS-Type-LogConfiguration-options). However, it was not working when we transform keys with upperCaseFirstCharacter, because the keys in `excludeFromTransform` was uppercased, where the source object was lowercased. ``` // source task definition { "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "my-test-stack-TaskEcsAppLogGroupD5C9C1DD-BPB6zgX4S0wU", "awslogs-region": "ap-northeast-1", }, }, } // excludeFromTransform { LogConfiguration: { Options: true, }, }, } // where it should be { logConfiguration: { options: true, }, }, } ``` This misconfiguration resulted in the output task definition uppercased in an unexpected way: ```json { "logConfiguration": { "logDriver": "awslogs", "options": { "Awslogs-group": "my-test-stack-TaskEcsAppLogGroupD5C9C1DD-BPB6zgX4S0wU", "Awslogs-region": "ap-northeast-1", }, }, } ``` The problem was not detected by unit tests because they only contained cases with uppercase keys in a source task definition. ## Fix Use lowercased `excludeFromTransform` when we use it with `upperCaseFirstCharacter`, also adding a test case with lowercased keys in a source task definition. Closes #26871. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information