Configure IAM roles for Amazon EMR
developWhen creating a cluster, you must ensure the EMR service has the necessary permissions. You can either:
- Use the
--use-default-rolesflag to automatically use the default service role and instance profile. - Explicitly specify the
--service-roleand the--ec2-attributes(specifically theInstanceProfilekey). - Use
--instance-fleetsor--instance-groupswhich may require specific role configurations.
# Using explicit roles
aws emr create-cluster \
--release-label emr-5.14.0 \
--service-role EMR_DefaultRole \
--ec2-attributes InstanceProfile=EMR_EC2_DefaultRole \
--instance-groups InstanceGroupType=MASTER,InstanceCount=1,InstanceType=m4.large InstanceGroupType=CORE,InstanceCount=2,InstanceType=m4.large
# Using default roles
aws emr create-cluster \
--release-label emr-5.9.0 \
--use-default-roles \
--instance-groups InstanceGroupType=MASTER,InstanceCount=1,InstanceType=m4.large InstanceGroupType=CORE,InstanceCount=2,InstanceType=m4.large \
--auto-terminate