-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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_batch_alpha: Role permissions error after upgrade from v2.73 to v2.79 #25675
Comments
Do you mean with escape hatches, manually removing the role from being associated with the container? With the current implementation, a role should always be created, so an execution role should always be specified using this construct. Do you mean that this is the issue, and that no role should be created in some circumstances?
|
@peterwoodworth thanks for the response. What I did was manually create a new revision of the job definition, and in that revision remove the execution role associated with the container.
I think always specifying an execution role is fine, but I would hope that the default role wouldn't cause permissions errors with the default logging. |
face this problem as well, the default execution_role should be add for create cloudwatch logs |
@wttat @paulharbulak-maxar are your containers actually calling I reproduced this by not specifying |
ReproductionI could reproduce it on my end. If we don't specify logging property, which means we don't specify logDriver explicitly in job definition, Batch uses awslogs with log group
In this context, CreateLogStream API is called by Docker daemon, because log driver is Docker's functionality. So user's containers don't call CloudWatch Logs API. ProblemFrom #25466, executionRole has been always created by default. This means that underlying ECS tasks always use not EC2 instance role but the execution role for API calls by log driver. However, if logging property is not specified, grantWrite for the execution role is never called. grantWrite is called in bind method. aws-cdk/packages/@aws-cdk/aws-batch-alpha/lib/ecs-container-definition.ts Lines 518 to 526 in dcf5352
SolutionI think that one possible solution is granting permission for default log group to the execution role when logging property is not specified. If this approach is acceptable, I'll submit PR later. |
) Grant `CreateLogStream` to the job definition's execution role by default. Without this permission, jobs will fail if they produce any output, unless `logging` is specified. Closes #25675. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…#26288) Grant `CreateLogStream` to the job definition's execution role by default. Without this permission, jobs will fail if they produce any output, unless `logging` is specified. Closes aws#25675. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Describe the bug
After changing ComputeEnvironment, JobDefinition, and other related Batch constructs to ManagedEc2EcsComputeEnvironment, EcsJobDefinition, etc. due to breaking changes in v2.79, Batch jobs fail with a CloudWatch permissions error.
Expected Behavior
I expected any default IAM roles created by Batch constructs to have necessary permissions for the default logging configuration.
Current Behavior
Batch jobs fail with the following error:
CannotStartContainerError: Error response from daemon: failed to initialize logging driver: failed to create Cloudwatch log stream: AccessDeniedException: User: <BatchContainerDefinitionExecutionRole ARN>.
Reproduction Steps
This is the section of code that is currently used to generate the Batch infrastructure producing the error:
Possible Solution
It appears as if the default container execution role of EcsEc2ContainerDefinition is not granted
logs:CreateLogStream
permissions. If you manually remove the container execution role from the job definition, the job will succeed. I'm guessing it gets the necessary permissions from the BatchEnvironmentInstanceProfileRole. However, if you set the EcsJobDefinitionexecution_role
property to None it will still create and assign a default execution role, which will fail with the permissions error.Additional Information/Context
Batch jobs created with JobDefinition/JobDefinitionContainer in v2.73 do not appear to use a default execution role, whereas batch jobs created in v2.79 do.
CDK CLI Version
2.79.1
Framework Version
No response
Node.js Version
16.20
OS
Ubuntu 22.04.2
Language
Python
Language Version
3.8
Other information
No response
The text was updated successfully, but these errors were encountered: