View a markdown version of this page

Use CreatePlacementGroup with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use CreatePlacementGroup with a CLI

The following code examples show how to use CreatePlacementGroup.

CLI
AWS CLI

Example 1: To create a placement group

The following create-placement-group example creates a placement group with the specified name.

aws ec2 create-placement-group \ --group-name my-cluster \ --strategy cluster

Output:

{ "PlacementGroup": { "GroupName": "my-cluster", "State": "available", "Strategy": "cluster", "GroupId": "pg-0123456789example", "GroupArn": "arn:aws:ec2:us-west-2:123456789012:placement-group/my-cluster" } }

For more information, see Placement groups for your Amazon EC2 instances in the Amazon EC2 User Guide.

Example 2: To create a partition placement group

The following create-placement-group example creates a partition placement group named HDFS-Group-A with five partitions.

aws ec2 create-placement-group \ --group-name HDFS-Group-A \ --strategy partition \ --partition-count 5

Output:

{ "PlacementGroup": { "GroupName": "HDFS-Group-A", "State": "available", "Strategy": "partition", "PartitionCount": 5, "GroupId": "pg-0abcdef1234example", "GroupArn": "arn:aws:ec2:us-west-2:123456789012:placement-group/HDFS-Group-A" } }

For more information, see Placement strategies for your placement groups in the Amazon EC2 User Guide.

PowerShell
Tools for PowerShell V4

Example 1: This example creates a placement group with the specified name.

New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster
Tools for PowerShell V5

Example 1: This example creates a placement group with the specified name.

New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster