Specifying Amazon EMR-managed and additional security groups
You can specify security groups using the AWS Management Console, the AWS CLI, or the Amazon EMR API. If you don't specify security groups, Amazon EMR creates default security groups. Specifying additional security groups is optional. You can assign additional security groups for primary instances, core and task instances, and service access (private subnets only).
Specifying security groups with the AWS CLI
To specify security groups using the AWS CLI you use the create-cluster
command with the following parameters of the --ec2-attributes
option:
Parameter | Description |
---|---|
|
Use this parameter to specify a custom managed security group
for the primary instance. If this parameter is specified,
|
|
Use this parameter to specify a custom managed security group
for core and task instances. If this parameter is specified,
|
|
Use this parameter to specify a custom managed security group
for service access, which applies only to clusters in private
subnets. The security group you specify as
|
|
Use this parameter to specify up to four additional security groups for the primary instance. |
|
Use this parameter to specify up to four additional security groups for core and task instances. |
Example — specify custom Amazon EMR-managed security groups and additional security groups
The following example specifies custom Amazon EMR managed security groups for a cluster in a private subnet, multiple additional security groups for the primary instance, and a single additional security group for core and task instances.
Note
Linux line continuation characters (\) are included for readability. They can be removed or used in Linux commands. For Windows, remove them or replace with a caret (^).
aws emr create-cluster --name "
ClusterCustomManagedAndAdditionalSGs
" \ --release-label emr-emr-7.6.0
--applications Name=Hue
Name=Hive
\ Name=Pig
--use-default-roles --ec2-attributes \ SubnetIds=subnet-xxxxxxxxxxxx
,KeyName=myKey
,\ ServiceAccessSecurityGroup=sg-xxxxxxxxxxxx
,\ EmrManagedPrimarySecurityGroup=sg-xxxxxxxxxxxx
,\ EmrManagedCoreSecurityGroup=sg-xxxxxxxxxxx
,\ AdditionalPrimarySecurityGroups=['sg-xxxxxxxxxxx
',\ 'sg-xxxxxxxxxxx
','sg-xxxxxxxxxx
'],\ AdditionalCoreSecurityGroups=sg-xxxxxxxxxxx
\ --instance-typem5.xlarge
For more information, see create-cluster in the AWS CLI Command Reference.