karkir subu
karkir subu

Reputation: 43

ECS Task Not Running - AWS Cognito

I'm trying to use JavaScript to run a task in ECS Fargate. AWS suggested to use Cognito Identity Credentials. When I pass in IdentityPoolId shown in:

const aws = require("aws-sdk");
aws.config.credentials = new aws.CognitoIdentityCredentials({
  IdentityPoolId: <identity-pool-id>
}) 

I get a message in the console like:

Uncaught (in promise) AccessDeniedException: User: arn:aws:sts::<accountid>:assumed-role/Cognito_<appname>Unauth_Role/CognitoIdentityCredentials is not authorized to perform: ecs:RunTask on resource: arn:aws:ecs:us-west-2:<accountid>:task-definition/<image-name>:<version> because no session policy allows the ecs:RunTask action

How do you resolve this issue. I'm looking at the activity in ECS and I see that the Unauth role did get assumed and it accessed ECS. It's just that the runTask doesn't work. Can someone provide example working code to solve this?

Upvotes: 0

Views: 156

Answers (1)

karkir subu
karkir subu

Reputation: 43

I didn't end up going the Cognito route. It's just that AWS Cognito seems super unintuitive and from an engineering standpoint, it would make sense that the backend should be handling ECS stuff for my use case. Plus, ECS with boto 3 is so much easier to use impo

Upvotes: 0

Related Questions