This is the new *CloudFormation Template Reference Guide*. Please update your bookmarks and links. For help getting started with CloudFormation, see the [AWS CloudFormation User Guide](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/Welcome.html). # AWS::EC2::PlacementGroup Specifies a placement group in which to launch instances. The strategy of the placement group determines how the instances are organized within the group. A `cluster` placement group is a logical grouping of instances within a single Availability Zone that benefit from low network latency, high network throughput. A `spread` placement group places instances on distinct hardware. A `partition` placement group places groups of instances in different partitions, where instances in one partition do not share the same hardware with instances in another partition. For more information, see [Placement Groups](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html) in the *Amazon EC2 User Guide*. You can optionally specify the `GroupName` property in your template to create a placement group with a specific name. If you don't specify a name, CloudFormation generates a unique name. Updating the `GroupName` value requires replacement of the placement group. ## Syntax To declare this entity in your CloudFormation template, use the following syntax: ### JSON ``` { "Type" : "AWS::EC2::PlacementGroup", "Properties" : { "[PartitionCount](#cfn-ec2-placementgroup-partitioncount)" : {{Integer}}, "[SpreadLevel](#cfn-ec2-placementgroup-spreadlevel)" : {{String}}, "[Strategy](#cfn-ec2-placementgroup-strategy)" : {{String}}, "[Tags](#cfn-ec2-placementgroup-tags)" : {{[ Tag, ... ]}} } } ``` ### YAML ``` Type: AWS::EC2::PlacementGroup Properties: [PartitionCount](#cfn-ec2-placementgroup-partitioncount): {{Integer}} [SpreadLevel](#cfn-ec2-placementgroup-spreadlevel): {{String}} [Strategy](#cfn-ec2-placementgroup-strategy): {{String}} [Tags](#cfn-ec2-placementgroup-tags): {{ - Tag}} ``` ## Properties `PartitionCount` The number of partitions. Valid only when **Strategy** is set to `partition`. *Required*: No *Type*: Integer *Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement) `SpreadLevel` Determines how placement groups spread instances. + Host – You can use `host` only with Outpost placement groups. + Rack – No usage restrictions. *Required*: No *Type*: String *Allowed values*: `host | rack` *Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement) `Strategy` The placement strategy. *Required*: No *Type*: String *Allowed values*: `cluster | spread | partition | precision-time` *Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement) `Tags` The tags to apply to the new placement group. *Required*: No *Type*: Array of [Tag](aws-properties-ec2-placementgroup-tag.md) *Update requires*: [Replacement](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-update-behaviors.html#update-replacement) ## Return values ### Ref When you pass the logical ID of this resource to the intrinsic `Ref` function, `Ref` returns the name of the placement group. For more information about using the `Ref` function, see [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-ref.html). ### Fn::GetAtt The `Fn::GetAtt` intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values. For more information about using the `Fn::GetAtt` intrinsic function, see [https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/intrinsic-function-reference-getatt.html). #### `GroupName` The name of the placement group. You can also specify `GroupName` in your template's `Properties` section to create a placement group with a specific name. If you don't specify a name, CloudFormation generates a unique name. Updating `GroupName` requires replacement of the placement group. ## Examples **Topics** + [Create a placement group](#aws-resource-ec2-placementgroup--examples--Create_a_placement_group) + [Create a spread placement group with a specific name](#aws-resource-ec2-placementgroup--examples--Create_a_spread_placement_group_with_a_specific_name) + [Create a partition placement group with a specific name](#aws-resource-ec2-placementgroup--examples--Create_a_partition_placement_group_with_a_specific_name) ### Create a placement group The following example declares a placement group with a cluster placement strategy. #### JSON ``` "PlacementGroup" : { "Type" : "AWS::EC2::PlacementGroup", "Properties" : { "Strategy" : "cluster" } } ``` #### YAML ``` PlacementGroup: Type: AWS::EC2::PlacementGroup Properties: Strategy: cluster ``` ### Create a spread placement group with a specific name The following example declares a placement group with a spread placement strategy and a specific name. The placement group is created with the name `MySpreadGroup` and spreads instances across distinct racks. #### JSON ``` "PlacementGroup" : { "Type" : "AWS::EC2::PlacementGroup", "Properties" : { "GroupName" : "MySpreadGroup", "SpreadLevel" : "rack", "Strategy" : "spread" } } ``` #### YAML ``` PlacementGroup: Type: AWS::EC2::PlacementGroup Properties: GroupName: MySpreadGroup SpreadLevel: rack Strategy: spread ``` ### Create a partition placement group with a specific name The following example declares a placement group with a partition placement strategy, three partitions, and a specific name. #### JSON ``` "PlacementGroup" : { "Type" : "AWS::EC2::PlacementGroup", "Properties" : { "GroupName" : "MyPartitionGroup", "PartitionCount" : 3, "Strategy" : "partition" } } ``` #### YAML ``` PlacementGroup: Type: AWS::EC2::PlacementGroup Properties: GroupName: MyPartitionGroup PartitionCount: 3 Strategy: partition ```