Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-ecs): support RuntimePlatform Property at TaskDefinition class for create windows OperatingSystem #17242

Closed
1 of 2 tasks
neilkuan opened this issue Oct 30, 2021 · 8 comments · Fixed by #17622
Closed
1 of 2 tasks
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/small Small work item – less than a day of effort feature/enhancement A new API to make things easier or more intuitive. A catch-all for general feature requests. feature-request A feature should be added or improved. p2

Comments

@neilkuan
Copy link
Contributor

neilkuan commented Oct 30, 2021

Description

support RuntimePlatform Property at TaskDefinition class for create windows OperatingSystem.

Use Case

Windows support for AWS Fargate on Amazon ECS on 28 OCT 2021 .
https://aws.amazon.com/tw/blogs/containers/running-windows-containers-with-amazon-ecs-on-aws-fargate/

Proposed Solution

support RuntimePlatform Property at TaskDefinition class.

Other information

No response

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change
@neilkuan neilkuan added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 30, 2021
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Oct 30, 2021
@neilkuan neilkuan changed the title (aws-ecs): support define RuntimePlatform in TaskDefinition for create windows OperatingSystem runtime (aws-ecs): support RuntimePlatform Property at TaskDefinition class for create windows OperatingSystem Oct 30, 2021
@peterwoodworth
Copy link
Contributor

Thanks for submitting this feature request @neilkuan,

The underlying taskDefinition doesn't get created with this property.

const taskDef = new CfnTaskDefinition(this, 'Resource', {
containerDefinitions: Lazy.any({ produce: () => this.renderContainers() }, { omitEmptyArray: true }),
volumes: Lazy.any({ produce: () => this.renderVolumes() }, { omitEmptyArray: true }),
executionRoleArn: Lazy.string({ produce: () => this.executionRole && this.executionRole.roleArn }),
family: this.family,
taskRoleArn: this.taskRole.roleArn,
requiresCompatibilities: [
...(isEc2Compatible(props.compatibility) ? ['EC2'] : []),
...(isFargateCompatible(props.compatibility) ? ['FARGATE'] : []),
...(isExternalCompatible(props.compatibility) ? ['EXTERNAL'] : []),
],
networkMode: this.renderNetworkMode(this.networkMode),
placementConstraints: Lazy.any({
produce: () =>
!isFargateCompatible(this.compatibility) ? this.placementConstraints : undefined,
}, { omitEmptyArray: true }),
proxyConfiguration: props.proxyConfiguration ? props.proxyConfiguration.bind(this.stack, this) : undefined,
cpu: props.cpu,
memory: props.memoryMiB,
ipcMode: props.ipcMode,
pidMode: props.pidMode,
inferenceAccelerators: Lazy.any({
produce: () =>
!isFargateCompatible(this.compatibility) ? this.renderInferenceAccelerators() : undefined,
}, { omitEmptyArray: true }),
ephemeralStorage: this.ephemeralStorageGiB ? {
sizeInGiB: this.ephemeralStorageGiB,
} : undefined,
});

CloudFormation docs on RuntimePlatform

To work around this before we officially support it, you should be able to use an escape hatch to apply this property as needed.

Contributions are welcome as well 😃

@peterwoodworth peterwoodworth added effort/small Small work item – less than a day of effort p2 feature/enhancement A new API to make things easier or more intuitive. A catch-all for general feature requests. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 1, 2021
@neilkuan
Copy link
Contributor Author

neilkuan commented Nov 2, 2021

yes, I already did that :).

const vpc = ec2.Vpc.fromLookup(this, 'VPC', { isDefault: true });
    const cluster = new ecs.Cluster(this, 'Cluster', {
      vpc,
      enableFargateCapacityProviders: true,
    });
    const taskdef = new ecs.TaskDefinition(this, 'TaskDef', { compatibility: ecs.Compatibility.FARGATE, memoryMiB: '2048', cpu: '1024' });
    taskdef.addContainer('Container', {
      logging: ecs.LogDriver.awsLogs({ streamPrefix: 'win-iis-on-fargate' }),
      portMappings: [{ containerPort: 80 }],
      image: ecs.ContainerImage.fromRegistry('mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019'),
    });
    (taskdef.node.defaultChild as ecs.CfnTaskDefinition).addPropertyOverride('RuntimePlatform', {
      OperatingSystemFamily: 'WINDOWS_SERVER_2019_CORE',
    });
    const fargateWindowsService = new ecs.FargateService(this, 'Service', {
      taskDefinition: taskdef,
      cluster,
      assignPublicIp: true,
    });
    ecs.WindowsOptimizedVersion.SERVER_2019;
    fargateWindowsService.connections.allowFrom(ec2.Peer.ipv4(`${process.env.MYIP}/32`), ec2.Port.tcp(80));

@pahud
Copy link
Contributor

pahud commented Nov 2, 2021

Looks like v46 spec has the RuntimePlatform property. Let's wait until the #17223 being merged.

@alisade
Copy link

alisade commented Nov 23, 2021

also for graviton
https://aws.amazon.com/blogs/aws/announcing-aws-graviton2-support-for-aws-fargate-get-up-to-40-better-price-performance-for-your-serverless-containers/

@suresh26k
Copy link

For python, we can do the same

   task_definition = ecs.TaskDefinition(
        .....
    )

    # Import resource as cfn resource
    cfn_task_definition = task_definition.node.find_child("Resource")
    # Override cfn resource property
    cfn_task_definition.add_override(
        "Properties.RuntimePlatform.OperatingSystemFamily", "WINDOWS_SERVER_2019_CORE")

@suresh26k
Copy link

Thanks for submitting this feature request @neilkuan,

The underlying taskDefinition doesn't get created with this property.

const taskDef = new CfnTaskDefinition(this, 'Resource', {
containerDefinitions: Lazy.any({ produce: () => this.renderContainers() }, { omitEmptyArray: true }),
volumes: Lazy.any({ produce: () => this.renderVolumes() }, { omitEmptyArray: true }),
executionRoleArn: Lazy.string({ produce: () => this.executionRole && this.executionRole.roleArn }),
family: this.family,
taskRoleArn: this.taskRole.roleArn,
requiresCompatibilities: [
...(isEc2Compatible(props.compatibility) ? ['EC2'] : []),
...(isFargateCompatible(props.compatibility) ? ['FARGATE'] : []),
...(isExternalCompatible(props.compatibility) ? ['EXTERNAL'] : []),
],
networkMode: this.renderNetworkMode(this.networkMode),
placementConstraints: Lazy.any({
produce: () =>
!isFargateCompatible(this.compatibility) ? this.placementConstraints : undefined,
}, { omitEmptyArray: true }),
proxyConfiguration: props.proxyConfiguration ? props.proxyConfiguration.bind(this.stack, this) : undefined,
cpu: props.cpu,
memory: props.memoryMiB,
ipcMode: props.ipcMode,
pidMode: props.pidMode,
inferenceAccelerators: Lazy.any({
produce: () =>
!isFargateCompatible(this.compatibility) ? this.renderInferenceAccelerators() : undefined,
}, { omitEmptyArray: true }),
ephemeralStorage: this.ephemeralStorageGiB ? {
sizeInGiB: this.ephemeralStorageGiB,
} : undefined,
});

CloudFormation docs on RuntimePlatform

To work around this before we officially support it, you should be able to use an escape hatch to apply this property as needed.

Contributions are welcome as well 😃

@peterwoodworth

Could you please share any docs to help me start contributing.

@peterwoodworth
Copy link
Contributor

Thanks for your interest @suresh26k, please check out CONTRIBUTING.md. Let me know if you have any further questions 🙂

@mergify mergify bot closed this as completed in #17622 Jan 11, 2022
mergify bot pushed a commit that referenced this issue Jan 11, 2022
…indows runtime. (#17622)

feat(aws-ecs): support runtime platform property for create fargate windows and Graviton2 runtime.

close #17242
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
…indows runtime. (aws#17622)

feat(aws-ecs): support runtime platform property for create fargate windows and Graviton2 runtime.

close aws#17242
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container effort/small Small work item – less than a day of effort feature/enhancement A new API to make things easier or more intuitive. A catch-all for general feature requests. feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants