Skip to content

create_placement_group async

create_placement_group(
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    partition_count: Optional[Integer] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    spread_level: Optional[SpreadLevel] = None,
    linked_group_id: Optional[PlacementGroupId] = None,
    operator: Optional[OperatorRequest] = None,
    parent_group_id: Optional[PlacementGroupId] = None,
    dry_run: Optional[Boolean] = None,
    group_name: Optional[String] = None,
    strategy: Optional[PlacementStrategy] = None,
) -> CreatePlacementGroupResult

Creates 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. A precision-time placement group places instances on supported hardware with direct access to high-precision time sources in Amazon Web Services infrastructure.

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

Parameters:

  • partition_count (Optional[Integer], default: None ) –

    The number of partitions. Valid only when Strategy is set to partition.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to apply to the new placement group.

  • spread_level (Optional[SpreadLevel], default: None ) –

    Determines how placement groups spread instances.

    • Host – You can use host only with Outpost placement groups.

    • Rack – No usage restrictions.

  • linked_group_id (Optional[PlacementGroupId], default: None ) –

    Reserved for future use.

  • operator (Optional[OperatorRequest], default: None ) –

    Reserved for internal use.

  • parent_group_id (Optional[PlacementGroupId], default: None ) –

    The ID of a parent placement group. Valid only when Strategy is set to cluster.

  • dry_run (Optional[Boolean], default: None ) –

    Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • group_name (Optional[String], default: None ) –

    A name for the placement group. Must be unique within the scope of your account for the Region.

    Constraints: Up to 255 ASCII characters

  • strategy (Optional[PlacementStrategy], default: None ) –

    The placement strategy.

Raises:

Examples:

To create a placement group This example creates a placement group with the specified name.

>>> await client.create_placement_group(group_name='my-cluster', strategy='cluster')
Source code in docs_src/capo_ec2/_services/async_ec2.py
async def create_placement_group(
    self,
    *,
    config_overrides: Optional[AsyncEC2ClientConfig] = None,
    partition_count: Optional["capo_ec2.types.integer.Integer"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    spread_level: Optional["capo_ec2.types.spread_level.SpreadLevel"] = None,
    linked_group_id: Optional[
        "capo_ec2.types.placement_group_id.PlacementGroupId"
    ] = None,
    operator: Optional["capo_ec2.types.operator_request.OperatorRequest"] = None,
    parent_group_id: Optional[
        "capo_ec2.types.placement_group_id.PlacementGroupId"
    ] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    group_name: Optional["capo_ec2.types.string.String"] = None,
    strategy: Optional[
        "capo_ec2.types.placement_strategy.PlacementStrategy"
    ] = None,
) -> "capo_ec2.types.create_placement_group_result.CreatePlacementGroupResult":
    """<p>Creates a placement group in which to launch instances. The strategy of the placement group determines how the instances are organized within the group. </p> <p>A <code>cluster</code> placement group is a logical grouping of instances within a single Availability Zone that benefit from low network latency, high network throughput. A <code>spread</code> placement group places instances on distinct hardware. A <code>partition</code> 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. A <code>precision-time</code> placement group places instances on supported hardware with direct access to high-precision time sources in Amazon Web Services infrastructure.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html">Placement groups</a> in the <i>Amazon EC2 User Guide</i>.</p>

    Args:
        partition_count: <p>The number of partitions. Valid only when <b>Strategy</b> is set to <code>partition</code>.</p>
        tag_specifications: <p>The tags to apply to the new placement group.</p>
        spread_level: <p>Determines how placement groups spread instances. </p> <ul> <li> <p>Host – You can use <code>host</code> only with Outpost placement groups.</p> </li> <li> <p>Rack – No usage restrictions.</p> </li> </ul>
        linked_group_id: <p>Reserved for future use.</p>
        operator: <p>Reserved for internal use.</p>
        parent_group_id: <p>The ID of a parent placement group. Valid only when <b>Strategy</b> is set to <code>cluster</code>.</p>
        dry_run: <p>Checks whether you have the required permissions for the operation, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        group_name: <p>A name for the placement group. Must be unique within the scope of your account for the Region.</p> <p>Constraints: Up to 255 ASCII characters</p>
        strategy: <p>The placement strategy.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a placement group
        This example creates a placement group with the specified name.

        >>> await client.create_placement_group(group_name='my-cluster', strategy='cluster')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ec2.types.create_placement_group_request.CreatePlacementGroupRequest]",
    ) -> AsyncOperationResponse[
        "capo_ec2.types.create_placement_group_result.CreatePlacementGroupResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_placement_group

        (
            output,
            http_response,
        ) = await capo_ec2._operations.amazon_ec2.create_placement_group.async_create_placement_group(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreatePlacementGroup")
    )
    input_: capo_ec2.types.create_placement_group_request.CreatePlacementGroupRequest = {}
    if partition_count is not None:
        input_["partition_count"] = partition_count
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if spread_level is not None:
        input_["spread_level"] = spread_level
    if linked_group_id is not None:
        input_["linked_group_id"] = linked_group_id
    if operator is not None:
        input_["operator"] = operator
    if parent_group_id is not None:
        input_["parent_group_id"] = parent_group_id
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if group_name is not None:
        input_["group_name"] = group_name
    if strategy is not None:
        input_["strategy"] = strategy

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output