This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
Updating policy of lambda function to allow DescribeContainerInstances #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Arn format of container instance do not have cluster name, so thats why lambda function provide this feedback:
[ERROR] AccessDeniedException: An error occurred (AccessDeniedException) when calling the DescribeContainerInstances operation: User: arn:aws:sts::user:assumed-role/test-draining-function-role/test-draining-function is not authorized to perform: ecs:DescribeContainerInstances on resource: arn:aws:ecs:eu-north-1:test:container-instance/instance_id
Traceback (most recent call last):
File "/var/task/index.py", line 47, in lambda_handler
if instance_has_running_tasks(msg['EC2InstanceId']):
File "/var/task/index.py", line 29, in instance_has_running_tasks
(instance_arn, container_status, running_tasks) = find_ecs_instance_info(instance_id)
File "/var/task/index.py", line 18, in find_ecs_instance_info
containerInstances=arns)
File "/var/runtime/botocore/client.py", line 316, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/var/runtime/botocore/client.py", line 635, in _make_api_call
raise error_class(parsed_response, operation_name)