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

(ecs-patterns): ScheduledFargateTask - runtime platform ignored #27446

Open
daniellorenzin opened this issue Oct 9, 2023 · 2 comments
Open
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@daniellorenzin
Copy link

Describe the bug

The runtime platform on the pattern top level is getting ignored when set, for example as LINUX ARM64.

const scheduledTask = new ecsPatterns.ScheduledFargateTask(this, 'ScheduledTask', {
            cluster: cluster,
            schedule: Schedule.expression('cron(*/1 * * * ? *)'),
            subnetSelection: subnetsSelection,
            scheduledFargateTaskImageOptions: {
                image: ecs.ContainerImage.fromDockerImageAsset(dockerAsset),
                memoryLimitMiB: 512,
                cpu: 256,
                command: ['python', 'manage.py'],
                logDriver: new ecs.AwsLogDriver({streamPrefix: 'ScheduledTask'}),
                environment: {
                    DEBUG: "1",
                },
                secrets: {
                    ...secrets,
                },
            },
            runtimePlatform: {
                cpuArchitecture: ecs.CpuArchitecture.ARM64,
                operatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
            },
        });

Expected Behavior

The task definition should have the image arch set to LINUX/ARM64

Current Behavior

The task definition should have the image arch is not set. Therefore defaults to LINUX/X86_64 during deployment

Reproduction Steps

const scheduledTask = new ecsPatterns.ScheduledFargateTask(this, 'ScheduledTask', {
            cluster: cluster,
            schedule: Schedule.expression('cron(*/1 * * * ? *)'),
            subnetSelection: subnetsSelection,
            scheduledFargateTaskImageOptions: {
                image: ecs.ContainerImage.fromDockerImageAsset(dockerAsset),
                memoryLimitMiB: 512,
                cpu: 256,
                command: ['python', 'manage.py'],
                logDriver: new ecs.AwsLogDriver({streamPrefix: 'ScheduledTask'}),
                environment: {
                    DEBUG: "1",
                },
                secrets: {
                    ...secrets,
                },
            },
            runtimePlatform: {
                cpuArchitecture: ecs.CpuArchitecture.ARM64,
                operatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
            },
        });

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.100

Framework Version

No response

Node.js Version

20.8

OS

Mac

Language

TypeScript

Language Version

No response

Other information

No response

@daniellorenzin daniellorenzin added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 9, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ecs-patterns Related to ecs-patterns library label Oct 9, 2023
@pahud pahud self-assigned this Oct 9, 2023
@pahud
Copy link
Contributor

pahud commented Oct 9, 2023

this.task = new EcsTask( {
cluster: this.cluster,
taskDefinition: this.taskDefinition,
taskCount: this.desiredTaskCount,
subnetSelection: this.subnetSelection,
platformVersion: props.platformVersion,
securityGroups: props.securityGroups,
propagateTags: props.propagateTags,
tags: props.tags,
});

This essentially renders the ecs parameters for events rule target, but looks like EcsParameters in CFN does not allow to specify runtimePlatform or CpuArchitecture?
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-ecsparameters.html

@pahud pahud removed their assignment Oct 9, 2023
@pahud pahud added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Oct 9, 2023
@daniellorenzin
Copy link
Author

daniellorenzin commented Oct 9, 2023

I ended up working around the issue, by splitting up the task defination and putting the runtimePlatform settings on that and it deployed and runs as expected.

        const taskDefinitionScheduled = new ecs.FargateTaskDefinition(this, 'TaskSchDef', {
            memoryLimitMiB: 1024,
            cpu: 512,
            runtimePlatform: {
                cpuArchitecture: ecs.CpuArchitecture.ARM64,
                operatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
            },
        });
        const containerScheduled = taskDefinitionScheduled.addContainer('ScheduledContainer', {
            image: ecs.ContainerImage.fromDockerImageAsset(asset),
            containerName: 'djangoScheduled',
            command: ['python', 'manage.py'],
            environment: {
                DEBUG: "1",
            },
            secrets: {
                ...secrets
            },
            logging: new ecs.AwsLogDriver({ streamPrefix: 'ShovelTask' }),
        });
        const scheduledTask = new ecsPatterns.ScheduledFargateTask(this, 'ScheduledTask', {
            cluster: cluster,
            schedule: Schedule.expression('cron(*/1 * * * ? *)'),
            subnetSelection: subnetsSelection,
            scheduledFargateTaskDefinitionOptions: {
                taskDefinition: taskDefinitionScheduled,
            },
        });

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs-patterns Related to ecs-patterns library bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants