1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package ec2
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/ec2/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Creates a placement group in which to launch instances. The strategy of the
15// placement group determines how the instances are organized within the group. A
16// cluster placement group is a logical grouping of instances within a single
17// Availability Zone that benefit from low network latency, high network
18// throughput. A spread placement group places instances on distinct hardware. A
19// partition placement group places groups of instances in different partitions,
20// where instances in one partition do not share the same hardware with instances
21// in another partition. For more information, see Placement groups
22// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/placement-groups.html) in
23// the Amazon EC2 User Guide.
24func (c *Client) CreatePlacementGroup(ctx context.Context, params *CreatePlacementGroupInput, optFns ...func(*Options)) (*CreatePlacementGroupOutput, error) {
25	if params == nil {
26		params = &CreatePlacementGroupInput{}
27	}
28
29	result, metadata, err := c.invokeOperation(ctx, "CreatePlacementGroup", params, optFns, addOperationCreatePlacementGroupMiddlewares)
30	if err != nil {
31		return nil, err
32	}
33
34	out := result.(*CreatePlacementGroupOutput)
35	out.ResultMetadata = metadata
36	return out, nil
37}
38
39type CreatePlacementGroupInput struct {
40
41	// Checks whether you have the required permissions for the action, without
42	// actually making the request, and provides an error response. If you have the
43	// required permissions, the error response is DryRunOperation. Otherwise, it is
44	// UnauthorizedOperation.
45	DryRun bool
46
47	// A name for the placement group. Must be unique within the scope of your account
48	// for the Region. Constraints: Up to 255 ASCII characters
49	GroupName *string
50
51	// The number of partitions. Valid only when Strategy is set to partition.
52	PartitionCount int32
53
54	// The placement strategy.
55	Strategy types.PlacementStrategy
56
57	// The tags to apply to the new placement group.
58	TagSpecifications []types.TagSpecification
59}
60
61type CreatePlacementGroupOutput struct {
62
63	// Describes a placement group.
64	PlacementGroup *types.PlacementGroup
65
66	// Metadata pertaining to the operation's result.
67	ResultMetadata middleware.Metadata
68}
69
70func addOperationCreatePlacementGroupMiddlewares(stack *middleware.Stack, options Options) (err error) {
71	err = stack.Serialize.Add(&awsEc2query_serializeOpCreatePlacementGroup{}, middleware.After)
72	if err != nil {
73		return err
74	}
75	err = stack.Deserialize.Add(&awsEc2query_deserializeOpCreatePlacementGroup{}, middleware.After)
76	if err != nil {
77		return err
78	}
79	if err = addSetLoggerMiddleware(stack, options); err != nil {
80		return err
81	}
82	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
83		return err
84	}
85	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
86		return err
87	}
88	if err = addResolveEndpointMiddleware(stack, options); err != nil {
89		return err
90	}
91	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
92		return err
93	}
94	if err = addRetryMiddlewares(stack, options); err != nil {
95		return err
96	}
97	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
98		return err
99	}
100	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
101		return err
102	}
103	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
104		return err
105	}
106	if err = addClientUserAgent(stack); err != nil {
107		return err
108	}
109	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
110		return err
111	}
112	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
113		return err
114	}
115	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreatePlacementGroup(options.Region), middleware.Before); err != nil {
116		return err
117	}
118	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
119		return err
120	}
121	if err = addResponseErrorMiddleware(stack); err != nil {
122		return err
123	}
124	if err = addRequestResponseLogging(stack, options); err != nil {
125		return err
126	}
127	return nil
128}
129
130func newServiceMetadataMiddleware_opCreatePlacementGroup(region string) *awsmiddleware.RegisterServiceMetadata {
131	return &awsmiddleware.RegisterServiceMetadata{
132		Region:        region,
133		ServiceID:     ServiceID,
134		SigningName:   "ec2",
135		OperationName: "CreatePlacementGroup",
136	}
137}
138