-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(aws-ecs): cannot set ephemeralStorageGiB for Windows platform v1.0.0 #37510
Description
Describe the bug
I’m encountering an issue when trying to set ephemeralStorageGiB on FargateTaskDefinition while using platformVersion 1.0.0 for FargateService.
cdk synth failed with following error:
«EphemeralStorageGibFeatureRequires» The ephemeralStorageGiB feature requires platform version 1.4.0 or later, got 1.0.0
This validation is correct for Linux container, but it is incorrect for Windows container, where you can set ephemeralStorageGiB Fargate platform version to v1.0
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version
No response
Expected Behavior
Synth completed successfully
Current Behavior
Reproduction Steps
To reproduce the issue:
import * as ecs from 'aws-cdk-lib/aws-ecs';
import * as cdk from 'aws-cdk-lib/core';
import { Construct } from 'constructs';
export class TestStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const cluster = new ecs.Cluster(this, "Cluster");
const taskDefinition = new ecs.FargateTaskDefinition(this, "TaskDefinition", {
runtimePlatform: {
operatingSystemFamily: ecs.OperatingSystemFamily.WINDOWS_SERVER_2022_CORE,
cpuArchitecture: ecs.CpuArchitecture.X86_64,
},
ephemeralStorageGiB: 40,
cpu: 1024,
memoryLimitMiB: 1024,
});
taskDefinition.addContainer("Container", {
image: ecs.ContainerImage.fromRegistry("mcr.microsoft.com/windows/server:ltsc2022"),
});
new ecs.FargateService(this, "Service", {
cluster,
taskDefinition,
platformVersion: ecs.FargatePlatformVersion.VERSION1_0,
});
/**
* Workaround for now
*/
// const cfnTaskDef = taskDefinition.node.defaultChild as ecs.CfnTaskDefinition;
// cfnTaskDef.addPropertyOverride('EphemeralStorage', {
// 'SizeInGiB': 40,
// });
}
}Possible Solution
The error was thrown here:
aws-cdk/packages/aws-cdk-lib/aws-ecs/lib/fargate/fargate-service.ts
Lines 181 to 183 in 9aceb58
| if (props.taskDefinition.ephemeralStorageGiB && isUnsupportedPlatformVersion) { | |
| throw new ValidationError(lit`EphemeralStorageGibFeatureRequires`, `The ephemeralStorageGiB feature requires platform version ${FargatePlatformVersion.VERSION1_4} or later, got ${props.platformVersion}.`, scope); | |
| } |
We probably need to:
- Make the
runtimePlatformproperty inTaskDefinitionpublicprivate runtimePlatform?: RuntimePlatform; - Use OperatingSystemFamily.isWindows function, and exclude Windows so that the validation error doesn't get triggered anymore
aws-cdk/packages/aws-cdk-lib/aws-ecs/lib/runtime-platform.ts
Lines 103 to 105 in 9aceb58
public isWindows(): boolean { return this._operatingSystemFamily?.toLowerCase().startsWith('windows'); }
Additional Information/Context
No response
AWS CDK Library version (aws-cdk-lib)
2.247.0
AWS CDK CLI version
2.1113.0
Node.js Version
v24.11.1
OS
Windows
Language
TypeScript
Language Version
5.9.3
Other information
No response