Skip to content

aws_ecs: FargateTaskDefinition always adds default policy to execution role even when role is provided explicitly #35785

@juliangrueber

Description

@juliangrueber

Describe the bug

I want to manage the task execution policy my self such as its attached policies. In particular, I would like to attach metadata to specific policies to add cfn_nag ignore statements.
This is not work if policies are attached behind the scenes.
In addition, the docs do that state this behaviour

Regression Issue

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

Last Known Working CDK Library Version

No response

Expected Behavior

CDK does not attach any inline policies to the provided task execution IAM role.

Current Behavior

Even though all required permissions are already attached to the custom task execution role, CDK attaches the default execution policy.

Reproduction Steps

Create a FargateTaskDefinition with your custom execution role with custom inline permissions. Once deployed, look at the attached inline policies of that role. There will be the default execution policy be attached.

Possible Solution

Do not attach the default policy

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

/local/home/****/***** └── (empty)

AWS CDK CLI version

2.1030.0 (build e46adaf)

Node.js Version

v24.5.0

OS

Linux CentOS

Language

Python

Language Version

Python 3.12

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecsRelated to Amazon Elastic ContainerbugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions