Skip to content

aws_ecs_patterns: ApplicationLoadBalancedFargateService does not honor task image options (cpu, memory, environment,) and secrets are typed incorrectly not allowing them to be used. #33988

@Xenoha

Description

@Xenoha

Describe the bug

When I create a alb fargate construct as the following

const fargate = new ApplicationLoadBalancedFargateService(this, 'fargate', { cluster, publicLoadBalancer: true, memoryLimitMiB: 1024, cpu: 512, desiredCount: 1, circuitBreaker: { rollback: true, }, taskImageOptions: { image: ContainerImage.fromRegistry('nginx'), containerName: 'pdp', containerPort: 7000, enableLogging: true, environment: { ENVIRONMENT_ONE: process.env.environmentOne, }, }, })

It will create cloudformation that looks correct, however, the stack doesn't look to honor the configured cpu, memoryLimitMiB and the environment.

When I went to use a the secrets property in typescript it is typed with values being Secret.

When creating a new Secret and passing in as a value, I get a type error signifying that Secret is missing the property 'arn'.

when looking up a Secret you get back a type ISecret, so I don't see a way that this is used.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

I would expect environment to be passed to my fargate task def.

Current Behavior

environment is showing up as an empty array.

Reproduction Steps

Using typescript, create a ALB fargate service with a simple docker image from the registry and place environment variables per the props.

After this synth's correctly, see that the deployed task def doesn't include the properties in the environments array.

Try to use this construct while defining secrets.

Possible Solution

Secrets should be able to be defined from ISecret using the latest Secret.fromSecretNameV2 method on the Secret construct.

Additional Information/Context

No response

CDK CLI Version

2.1006.0 (build a3b9762)

Framework Version

2.1006.0

Node.js Version

22.12.0

OS

Linux 24.04.2 LTS

Language

TypeScript

Language Version

5.8.2

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecs-patternsRelated to ecs-patterns librarybugThis issue is a bug.closed-for-stalenessThis issue was automatically closed because it hadn't received any attention in a while.p3response-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions