1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package sqs
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/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Creates a new standard or FIFO queue. You can pass one or more attributes in the
14// request. Keep the following in mind:
15//
16// * If you don't specify the FifoQueue
17// attribute, Amazon SQS creates a standard queue. You can't change the queue type
18// after you create it and you can't convert an existing standard queue into a FIFO
19// queue. You must either create a new FIFO queue for your application or delete
20// your existing standard queue and recreate it as a FIFO queue. For more
21// information, see Moving From a Standard Queue to a FIFO Queue
22// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-moving)
23// in the Amazon Simple Queue Service Developer Guide.
24//
25// * If you don't provide a
26// value for an attribute, the queue is created with the default value for the
27// attribute.
28//
29// * If you delete a queue, you must wait at least 60 seconds before
30// creating a queue with the same name.
31//
32// To successfully create a new queue, you
33// must provide a queue name that adheres to the limits related to queues
34// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/limits-queues.html)
35// and is unique within the scope of your queues. After you create a queue, you
36// must wait at least one second after the queue is created to be able to use the
37// queue. To get the queue URL, use the GetQueueUrl action. GetQueueUrl requires
38// only the QueueName parameter. be aware of existing queue names:
39//
40// * If you
41// provide the name of an existing queue along with the exact names and values of
42// all the queue's attributes, CreateQueue returns the queue URL for the existing
43// queue.
44//
45// * If the queue name, attribute names, or attribute values don't match an
46// existing queue, CreateQueue returns an error.
47//
48// Some actions take lists of
49// parameters. These lists are specified using the param.n notation. Values of n
50// are integers starting from 1. For example, a parameter list with two elements
51// looks like this: &AttributeName.1=first&AttributeName.2=second Cross-account
52// permissions don't apply to this action. For more information, see Grant
53// cross-account permissions to a role and a user name
54// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name)
55// in the Amazon Simple Queue Service Developer Guide.
56func (c *Client) CreateQueue(ctx context.Context, params *CreateQueueInput, optFns ...func(*Options)) (*CreateQueueOutput, error) {
57	if params == nil {
58		params = &CreateQueueInput{}
59	}
60
61	result, metadata, err := c.invokeOperation(ctx, "CreateQueue", params, optFns, addOperationCreateQueueMiddlewares)
62	if err != nil {
63		return nil, err
64	}
65
66	out := result.(*CreateQueueOutput)
67	out.ResultMetadata = metadata
68	return out, nil
69}
70
71//
72type CreateQueueInput struct {
73
74	// The name of the new queue. The following limits apply to this name:
75	//
76	// * A queue
77	// name can have up to 80 characters.
78	//
79	// * Valid values: alphanumeric characters,
80	// hyphens (-), and underscores (_).
81	//
82	// * A FIFO queue name must end with the .fifo
83	// suffix.
84	//
85	// Queue URLs and names are case-sensitive.
86	//
87	// This member is required.
88	QueueName *string
89
90	// A map of attributes with their corresponding values. The following lists the
91	// names, descriptions, and values of the special request parameters that the
92	// CreateQueue action uses:
93	//
94	// * DelaySeconds – The length of time, in seconds, for
95	// which the delivery of all messages in the queue is delayed. Valid values: An
96	// integer from 0 to 900 seconds (15 minutes). Default: 0.
97	//
98	// * MaximumMessageSize –
99	// The limit of how many bytes a message can contain before Amazon SQS rejects it.
100	// Valid values: An integer from 1,024 bytes (1 KiB) to 262,144 bytes (256 KiB).
101	// Default: 262,144 (256 KiB).
102	//
103	// * MessageRetentionPeriod – The length of time, in
104	// seconds, for which Amazon SQS retains a message. Valid values: An integer from
105	// 60 seconds (1 minute) to 1,209,600 seconds (14 days). Default: 345,600 (4
106	// days).
107	//
108	// * Policy – The queue's policy. A valid AWS policy. For more information
109	// about policy structure, see Overview of AWS IAM Policies
110	// (https://docs.aws.amazon.com/IAM/latest/UserGuide/PoliciesOverview.html) in the
111	// Amazon IAM User Guide.
112	//
113	// * ReceiveMessageWaitTimeSeconds – The length of time, in
114	// seconds, for which a ReceiveMessage action waits for a message to arrive. Valid
115	// values: An integer from 0 to 20 (seconds). Default: 0.
116	//
117	// * RedrivePolicy – The
118	// string that includes the parameters for the dead-letter queue functionality of
119	// the source queue as a JSON object. For more information about the redrive policy
120	// and dead-letter queues, see Using Amazon SQS Dead-Letter Queues
121	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html)
122	// in the Amazon Simple Queue Service Developer Guide.
123	//
124	// * deadLetterTargetArn – The
125	// Amazon Resource Name (ARN) of the dead-letter queue to which Amazon SQS moves
126	// messages after the value of maxReceiveCount is exceeded.
127	//
128	// * maxReceiveCount –
129	// The number of times a message is delivered to the source queue before being
130	// moved to the dead-letter queue. When the ReceiveCount for a message exceeds the
131	// maxReceiveCount for a queue, Amazon SQS moves the message to the
132	// dead-letter-queue.
133	//
134	// The dead-letter queue of a FIFO queue must also be a FIFO
135	// queue. Similarly, the dead-letter queue of a standard queue must also be a
136	// standard queue.
137	//
138	// * VisibilityTimeout – The visibility timeout for the queue, in
139	// seconds. Valid values: An integer from 0 to 43,200 (12 hours). Default: 30. For
140	// more information about the visibility timeout, see Visibility Timeout
141	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html)
142	// in the Amazon Simple Queue Service Developer Guide.
143	//
144	// The following attributes
145	// apply only to server-side-encryption
146	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html):
147	//
148	// *
149	// KmsMasterKeyId – The ID of an AWS-managed customer master key (CMK) for Amazon
150	// SQS or a custom CMK. For more information, see Key Terms
151	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-sse-key-terms).
152	// While the alias of the AWS-managed CMK for Amazon SQS is always alias/aws/sqs,
153	// the alias of a custom CMK can, for example, be alias/MyAlias . For more
154	// examples, see KeyId
155	// (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters)
156	// in the AWS Key Management Service API Reference.
157	//
158	// * KmsDataKeyReusePeriodSeconds
159	// – The length of time, in seconds, for which Amazon SQS can reuse a data key
160	// (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#data-keys)
161	// to encrypt or decrypt messages before calling AWS KMS again. An integer
162	// representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24
163	// hours). Default: 300 (5 minutes). A shorter time period provides better security
164	// but results in more calls to KMS which might incur charges after Free Tier. For
165	// more information, see How Does the Data Key Reuse Period Work?
166	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-how-does-the-data-key-reuse-period-work).
167	//
168	// The
169	// following attributes apply only to FIFO (first-in-first-out) queues
170	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html):
171	//
172	// *
173	// FifoQueue – Designates a queue as FIFO. Valid values are true and false. If you
174	// don't specify the FifoQueue attribute, Amazon SQS creates a standard queue. You
175	// can provide this attribute only during queue creation. You can't change it for
176	// an existing queue. When you set this attribute, you must also provide the
177	// MessageGroupId for your messages explicitly. For more information, see FIFO
178	// Queue Logic
179	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-understanding-logic)
180	// in the Amazon Simple Queue Service Developer Guide.
181	//
182	// * ContentBasedDeduplication
183	// – Enables content-based deduplication. Valid values are true and false. For more
184	// information, see Exactly-Once Processing
185	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing)
186	// in the Amazon Simple Queue Service Developer Guide. Note the following:
187	//
188	// * Every
189	// message must have a unique MessageDeduplicationId.
190	//
191	// * You may provide a
192	// MessageDeduplicationId explicitly.
193	//
194	// * If you aren't able to provide a
195	// MessageDeduplicationId and you enable ContentBasedDeduplication for your queue,
196	// Amazon SQS uses a SHA-256 hash to generate the MessageDeduplicationId using the
197	// body of the message (but not the attributes of the message).
198	//
199	// * If you don't
200	// provide a MessageDeduplicationId and the queue doesn't have
201	// ContentBasedDeduplication set, the action fails with an error.
202	//
203	// * If the queue
204	// has ContentBasedDeduplication set, your MessageDeduplicationId overrides the
205	// generated one.
206	//
207	// * When ContentBasedDeduplication is in effect, messages with
208	// identical content sent within the deduplication interval are treated as
209	// duplicates and only one copy of the message is delivered.
210	//
211	// * If you send one
212	// message with ContentBasedDeduplication enabled and then another message with a
213	// MessageDeduplicationId that is the same as the one generated for the first
214	// MessageDeduplicationId, the two messages are treated as duplicates and only one
215	// copy of the message is delivered.
216	//
217	// Preview: High throughput for FIFO queues High
218	// throughput for Amazon SQS FIFO queues is in preview release and is subject to
219	// change. This feature provides a high number of transactions per second (TPS) for
220	// messages in FIFO queues. For information on throughput quotas, see Quotas
221	// related to messages
222	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html)
223	// in the Amazon Simple Queue Service Developer Guide. This preview includes two
224	// new attributes:
225	//
226	// * DeduplicationScope – Specifies whether message deduplication
227	// occurs at the message group or queue level. Valid values are messageGroup and
228	// queue.
229	//
230	// * FifoThroughputLimit – Specifies whether the FIFO queue throughput
231	// quota applies to the entire queue or per message group. Valid values are
232	// perQueue and perMessageGroupId. The perMessageGroupId value is allowed only when
233	// the value for DeduplicationScope is messageGroup.
234	//
235	// To enable high throughput for
236	// FIFO queues, do the following:
237	//
238	// * Set DeduplicationScope to messageGroup.
239	//
240	// * Set
241	// FifoThroughputLimit to perMessageGroupId.
242	//
243	// If you set these attributes to
244	// anything other than the values shown for enabling high throughput, standard
245	// throughput is in effect and deduplication occurs as specified. This preview is
246	// available in the following AWS Regions:
247	//
248	// * US East (Ohio); us-east-2
249	//
250	// * US East
251	// (N. Virginia); us-east-1
252	//
253	// * US West (Oregon); us-west-2
254	//
255	// * Europe (Ireland);
256	// eu-west-1
257	//
258	// For more information about high throughput for FIFO queues, see
259	// Preview: High throughput for FIFO queues
260	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/high-throughput-fifo.html)
261	// in the Amazon Simple Queue Service Developer Guide.
262	Attributes map[string]string
263
264	// Add cost allocation tags to the specified Amazon SQS queue. For an overview, see
265	// Tagging Your Amazon SQS Queues
266	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-tags.html)
267	// in the Amazon Simple Queue Service Developer Guide. When you use queue tags,
268	// keep the following guidelines in mind:
269	//
270	// * Adding more than 50 tags to a queue
271	// isn't recommended.
272	//
273	// * Tags don't have any semantic meaning. Amazon SQS
274	// interprets tags as character strings.
275	//
276	// * Tags are case-sensitive.
277	//
278	// * A new tag
279	// with a key identical to that of an existing tag overwrites the existing
280	// tag.
281	//
282	// For a full list of tag restrictions, see Limits Related to Queues
283	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-limits.html#limits-queues)
284	// in the Amazon Simple Queue Service Developer Guide. To be able to tag a queue on
285	// creation, you must have the sqs:CreateQueue and sqs:TagQueue permissions.
286	// Cross-account permissions don't apply to this action. For more information, see
287	// Grant cross-account permissions to a role and a user name
288	// (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name)
289	// in the Amazon Simple Queue Service Developer Guide.
290	Tags map[string]string
291}
292
293// Returns the QueueUrl attribute of the created queue.
294type CreateQueueOutput struct {
295
296	// The URL of the created Amazon SQS queue.
297	QueueUrl *string
298
299	// Metadata pertaining to the operation's result.
300	ResultMetadata middleware.Metadata
301}
302
303func addOperationCreateQueueMiddlewares(stack *middleware.Stack, options Options) (err error) {
304	err = stack.Serialize.Add(&awsAwsquery_serializeOpCreateQueue{}, middleware.After)
305	if err != nil {
306		return err
307	}
308	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpCreateQueue{}, middleware.After)
309	if err != nil {
310		return err
311	}
312	if err = addSetLoggerMiddleware(stack, options); err != nil {
313		return err
314	}
315	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
316		return err
317	}
318	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
319		return err
320	}
321	if err = addResolveEndpointMiddleware(stack, options); err != nil {
322		return err
323	}
324	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
325		return err
326	}
327	if err = addRetryMiddlewares(stack, options); err != nil {
328		return err
329	}
330	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
331		return err
332	}
333	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
334		return err
335	}
336	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
337		return err
338	}
339	if err = addClientUserAgent(stack); err != nil {
340		return err
341	}
342	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
343		return err
344	}
345	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
346		return err
347	}
348	if err = addOpCreateQueueValidationMiddleware(stack); err != nil {
349		return err
350	}
351	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateQueue(options.Region), middleware.Before); err != nil {
352		return err
353	}
354	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
355		return err
356	}
357	if err = addResponseErrorMiddleware(stack); err != nil {
358		return err
359	}
360	if err = addRequestResponseLogging(stack, options); err != nil {
361		return err
362	}
363	return nil
364}
365
366func newServiceMetadataMiddleware_opCreateQueue(region string) *awsmiddleware.RegisterServiceMetadata {
367	return &awsmiddleware.RegisterServiceMetadata{
368		Region:        region,
369		ServiceID:     ServiceID,
370		SigningName:   "sqs",
371		OperationName: "CreateQueue",
372	}
373}
374