(ecs): defer the Fargate/Ec2Service essential container exception to the validation phase #13239
Closed
1 of 2 tasks
Labels
@aws-cdk/aws-ecs
Related to Amazon Elastic Container
feature-request
A feature should be added or improved.
I'd like
FargateService
andEc2Service
to defer throwing theirA TaskDefinition must have at least one essential container
exceptions until the validate phase.Use Case
When I'm creating an ECS service with a container that needs to discover its siblings in other tasks via service discovery, I may need to get the service's cloudmap service and add that to an environment variable on the default container.
There's a problem here because the container must exist before the service can exist or we get the exception, but the container needs to know the service discovery service after the service has been created.
Right now, I can use a
Lazy.string
to set the environment variable later, but the way to do this is cumbersome.Proposed Solution
If the services defer this validation error to the validate phase, we can still catch the user's mistake, but while also adding the ability to create the default container after the service exists. I can appreciate that one project philosophy is to validate as soon as possible, but I think this exception is thrown too soon.
Here's what I'd like to be able to do:
I'd be fine if I needed to set a feature flag in the parent scope to defer the error, but I'm not sure that is necessary as it seems the intent of the exception is to catch a user that has misconfigured their task definition, which still happens in the case of this deferral.
Other
Here's how I currently work around this limitation:
Ideally, I'd like to add the default container after the service has been created without needing to use this kind of lazy evaluation.
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: