Skip to content

Commit 054c6c5

Browse files
authored
fix(ec2): don't use inferenceAccellerators in the constructors if not needed (#34618)
### Issue # (if applicable) Closes #33505 ### Reason for this change The Ec2TaskDefinition should not pass the `@deprecated` `props.inferenceAccelerators` property if it's unset or empty, because this results in showing deprecation notices in the console. See [this comment](#33505 (comment)). ### Description of changes Do not rely only on passing the props, but check if the array actually contains any elements. ### Describe any new or updated permissions being added ### Description of how you validated changes Cannot test by hand due to #34610. UPDATE: manually tested in a production CDK stack. Result as expected, warnings are not shown during `cdk diff`. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 063f4e7 commit 054c6c5

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

packages/aws-cdk-lib/aws-ecs/lib/ec2/ec2-task-definition.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,26 @@ export class Ec2TaskDefinition extends TaskDefinition implements IEc2TaskDefinit
143143
* Constructs a new instance of the Ec2TaskDefinition class.
144144
*/
145145
constructor(scope: Construct, id: string, props: Ec2TaskDefinitionProps = {}) {
146-
super(scope, id, {
147-
...props,
148-
compatibility: Compatibility.EC2,
149-
placementConstraints: props.placementConstraints,
150-
ipcMode: props.ipcMode,
151-
pidMode: props.pidMode,
152-
inferenceAccelerators: props.inferenceAccelerators,
153-
});
146+
// don't pass @deprecated inferenceAccelerators if not needed as this renders console warnings
147+
if (props.inferenceAccelerators) {
148+
super(scope, id, {
149+
...props,
150+
compatibility: Compatibility.EC2,
151+
placementConstraints: props.placementConstraints,
152+
ipcMode: props.ipcMode,
153+
pidMode: props.pidMode,
154+
inferenceAccelerators: props.inferenceAccelerators,
155+
});
156+
} else {
157+
super(scope, id, {
158+
...props,
159+
compatibility: Compatibility.EC2,
160+
placementConstraints: props.placementConstraints,
161+
ipcMode: props.ipcMode,
162+
pidMode: props.pidMode,
163+
});
164+
}
165+
154166
// Enhanced CDK Analytics Telemetry
155167
addConstructMetadata(this, props);
156168

0 commit comments

Comments
 (0)