There are more AWS SDK examples available in the AWS Doc SDK Examples
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-groupexample creates a placement group with the specified name.aws ec2 create-placement-group \ --group-namemy-cluster\ --strategyclusterOutput:
{ "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-groupexample creates a partition placement group namedHDFS-Group-Awith five partitions.aws ec2 create-placement-group \ --group-nameHDFS-Group-A\ --strategypartition\ --partition-count5Output:
{ "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.
-
For API details, see CreatePlacementGroup
in AWS CLI Command Reference.
-
- 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-
For API details, see CreatePlacementGroup in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example creates a placement group with the specified name.
New-EC2PlacementGroup -GroupName my-placement-group -Strategy cluster-
For API details, see CreatePlacementGroup in AWS Tools for PowerShell Cmdlet Reference (V5).
-