Shoaib Burq
Shoaib Burq

Reputation: 384

Error when creating aws emr default-roles

I'm trying to create a cluster using aws cli emr command. However, I can't seem to be able to create-default-roles needed before calling aws emr create-cluster

$ aws emr create-default-roles

A client error (NoSuchEntity) occurred when calling the GetRole operation: Unknown

I have made sure that my user has the following permissions:

IAMFullAccess - AWS Managed policy
AmazonElasticMapReduceforEC2Role - AWS Managed policy
AmazonElasticMapReduceFullAccess - AWS Managed policy

Any tips? Is there a place where I can just copy the roles json and create them manually?

The reason I started to do this is because when I run aws emr create-cluster it returns a cluster-id. But when that cluster-id is queries it state is set to terminated with the error: EMR service role arn:aws:iam::141703095098:role/EMR_DefaultRole is invalid

Upvotes: 3

Views: 3872

Answers (2)

James O'Brien
James O'Brien

Reputation: 1706

I had issues with the console. With the client this worked:

# upgrade aws cli (can't hurt)
pip install --upgrade --user awscli

# aws configure process if you haven't (look it up)

# delete all the defunct shizzles
aws iam remove-role-from-instance-profile --instance-profile-name EMR_EC2_DefaultRole \
    --role-name EMR_EC2_DefaultRole
aws iam delete-instance-profile \
    --instance-profile-name EMR_EC2_DefaultRole
aws iam detach-role-policy \
  --role-name EMR_EC2_DefaultRole \
  --policy-arn arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceforEC2Role
aws iam delete-role --role-name EMR_EC2_DefaultRole
aws iam detach-role-policy --role-name EMR_DefaultRole \
    --policy-arn arn:aws:iam::aws:policy/service-role/AmazonElasticMapReduceRole
aws iam delete-role --role-name EMR_DefaultRole

# now re-create them
aws emr create-default-roles

Note if you have attached policies, you might have to go into the console and delete them or find the appropriate aws cli command.

Source (our product is buggy and our role system is cumbersome, but if you buy premium support we'll tell you the workarounds): https://aws.amazon.com/premiumsupport/knowledge-center/emr-default-role-invalid/

Upvotes: 1

Shoaib Burq
Shoaib Burq

Reputation: 384

I DID manage to add these roles using the console by going to:

My Security Credentials > Roles > Create New Role

First Role with the following properties:

name: EMR_DefaultRole
policy: AmazonElasticMapReduceRole

Second Role with the following properties:

name: EMR_EC2_DefaultRole
policy: AmazonElasticMapReduceforEC2Role

Unfortunately I didn't get the command-line to work, but I suspect I might be something to do with my local setup.

Upvotes: 5

Related Questions