(ecs): Allow specifying that an imported TaskDefinition does not have a revision specified #32485
Labels
@aws-cdk/aws-ecs
Related to Amazon Elastic Container
effort/small
Small work item – less than a day of effort
feature-request
A feature should be added or improved.
p2
Describe the feature
Today, we cannot specify whether or not an imported TaskDefinition is "fully qualified" (e.g.,
MyTaskDef:123
) or not (e.g.,MyTaskDef
).There are certain cases, like granting IAM permissions - see #30390 / #31615, where different behaviors need to happen depending on if the task def is fully qualified with a revision or not.
Use Case
I expose various
pgdump
containers to assist with dumping Aurora Postgres databases to S3. I create a single, shared Task Definition that I expose via CloudFormation outputs. Then, I useFn.importValue
to import these in shared logic.Here's the some sample code to show the issue
If you synth this code, you'll see that
ecs:RunTask
specifies the Task Definition exactly as imported. This assumes that it has a revision attached:Specifically, this action:
Instead, I want to grant access to the imported value +
:*
(see #30390 for why). If I could specify that in myFargateTaskDefinition.fromFargateTaskDefinitionAttributes
call, then the downstream logic (implemented here: #31615) could check that.Proposed Solution
I suggest adding a field on
IFargateTaskDefinition
likearnIncludesRevision
or similar. Then, when we need to know about this (e.g., in #31615), we can use that value instead of checking the string, like @samson-keung added in that PR.Other Information
For a workaround to the sample code posted above, you can do something like this:
This forces the
:*
on the imported task def, as you can see in this synthed template:Acknowledgements
CDK version used
2.172.0
Environment details (OS name and version, etc.)
macOS
The text was updated successfully, but these errors were encountered: