I'm facing an issue with using JavaScript to execute a task in ECS Fargate. AWS suggested utilizing Cognito Identity Credentials for this task. However, when I provide the IdentityPoolId as shown below:
const aws = require("aws-sdk");
aws.config.credentials = new aws.CognitoIdentityCredentials({
IdentityPoolId: <identity-pool-id>
})
An error message appears in the console:
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
I am seeking assistance on resolving this issue. Upon reviewing the activity in ECS, it seems that the Unauth role was assumed and successfully accessed ECS. Nevertheless, the runTask
functionality is not working as expected. Could someone kindly share a sample code that resolves this problem?