-
Notifications
You must be signed in to change notification settings - Fork 4k
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: Issues with FargateTaskDestination #29748
Comments
Yes, at this moment it only supports Line 58 in bf2cf51
This is because it will Line 91 in bf2cf51
If you look at the TaskDefinition from CFN, the ContainerDefinitions is a prop of it, so when you import an existing TaskDefintion in CDK, CDK would not modify that TaskDefinition to render new ContainerDefinitions and that might be the reason. |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Thank you for the feedback. You placed this as a feature-request. Is there a place online to officially make that a feature request? |
Describe the bug
When I created a Task Definition with the class: new ecs.FargateTaskDefinition, the object is of type cdk.aws_ecs.FargateTaskDefinition.
If I use the function ecs.FargateTaskDefinition.fromFargateTaskDefinitionAttributes to import a task definition already created, the object is of type IFargateTaskDefinition.
In some cases this might be a non issue, however, if I try to import the task definition into aws_ecs_patterns.ApplicationLoadBalancedFargateService, the taskDefinition key is looking for a value of type cdk.aws_ecs.FargateTaskDefinition, not type IFargateTaskDefinition. My IDE highlights this issue.
There might be a workaround for it, but I'm actively trying to keep this modular. In the service class I'm building (using ApplicationLoadBalancedFargateService), i want to import the already made task definition created in the task deifnition class.
Expected Behavior
When calling ApplicationLoadBalancedFargateService and applying the taskDefinition value, I should be able to call fromFargateTaskDefinitionAttributes to import a task definition already created from soomewhere else.
Current Behavior
It is described in "Describe the Bug", unless you want more details?
Reproduction Steps
Created this class.
`import {Stack, StackProps, CfnOutput, aws_iam, Size} from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as cdk from "aws-cdk-lib";
import * as ecs from "aws-cdk-lib/aws-ecs";
import {EcsTaskDefinitionRoleStack} from "./ecs-task-definition-role-stack"
import {LogGroupStack} from "./log-group-stack";
import {EcrStack} from "./ecr-stack";
const stage = process.env.stage ?? "production"
const region = process.env.region ?? "ca-central-1"
const containerName =
api-${stage}
;const taskDefinitionArn = cdk.Fn.importValue('taskDefinitionArn')
export class EcsTaskDefinitionStack extends Stack {
private _taskDefinition: cdk.aws_ecs.FargateTaskDefinition;
}`
When calling getECSTaskDefinition in a different class, it highlights the issue
TS2740: Type IFargateTaskDefinition is missing the following properties from type FargateTaskDefinition:
family, containers, volumes, placementConstraints
, and 33 more.
Possible Solution
When calling ApplicationLoadBalancedFargateService, have taskDefinition accept either FargateTaskDefinition or IFargateTaskDefinition.
Additional Information/Context
No response
CDK CLI Version
2.117.0
Framework Version
No response
Node.js Version
20.8.1
OS
MacOS
Language
TypeScript
Language Version
5.3.3
Other information
No response
The text was updated successfully, but these errors were encountered: