Class Queue


  • public class Queue
    extends com.pulumi.resources.CustomResource
    Amazon SQS (Simple Queue Service) is a fully managed message queuing service that enables decoupling and scaling of microservices, distributed systems, and serverless applications. This resource allows you to create, configure, and manage an SQS queue, which acts as a reliable message buffer between producers and consumers. With support for standard and FIFO queues, SQS ensures secure, scalable, and asynchronous message processing. Use this resource to define queue attributes, configure access policies, and integrate seamlessly with AWS services like Lambda, SNS, and EC2. > AWS will hang indefinitely, leading to a `timeout while waiting` error, when creating or updating an `aws.sqs.Queue` with an associated `aws.sqs.QueuePolicy` if `Version = "2012-10-17"` is not explicitly set in the policy. ## Example Usage
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.sqs.Queue;
     import com.pulumi.aws.sqs.QueueArgs;
     import static com.pulumi.codegen.internal.Serialization.*;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var queue = new Queue("queue", QueueArgs.builder()
                 .name("example-queue")
                 .delaySeconds(90)
                 .maxMessageSize(2048)
                 .messageRetentionSeconds(86400)
                 .receiveWaitTimeSeconds(10)
                 .redrivePolicy(serializeJson(
                     jsonObject(
                         jsonProperty("deadLetterTargetArn", queueDeadletter.arn()),
                         jsonProperty("maxReceiveCount", 4)
                     )))
                 .tags(Map.of("Environment", "production"))
                 .build());
     
         }
     }
     
     
    ### FIFO queue
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.sqs.Queue;
     import com.pulumi.aws.sqs.QueueArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var queue = new Queue("queue", QueueArgs.builder()
                 .name("example-queue.fifo")
                 .fifoQueue(true)
                 .contentBasedDeduplication(true)
                 .build());
     
         }
     }
     
     
    ### High-throughput FIFO queue
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.sqs.Queue;
     import com.pulumi.aws.sqs.QueueArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var queue = new Queue("queue", QueueArgs.builder()
                 .name("pulumi-example-queue.fifo")
                 .fifoQueue(true)
                 .deduplicationScope("messageGroup")
                 .fifoThroughputLimit("perMessageGroupId")
                 .build());
     
         }
     }
     
     
    ### Dead-letter queue
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.sqs.Queue;
     import com.pulumi.aws.sqs.QueueArgs;
     import com.pulumi.aws.sqs.RedriveAllowPolicy;
     import com.pulumi.aws.sqs.RedriveAllowPolicyArgs;
     import static com.pulumi.codegen.internal.Serialization.*;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var exampleQueueDeadletter = new Queue("exampleQueueDeadletter", QueueArgs.builder()
                 .name("pulumi-example-deadletter-queue")
                 .build());
     
             var queue = new Queue("queue", QueueArgs.builder()
                 .name("pulumi-example-queue")
                 .redrivePolicy(exampleQueueDeadletter.arn().applyValue(_arn -> serializeJson(
                     jsonObject(
                         jsonProperty("deadLetterTargetArn", _arn),
                         jsonProperty("maxReceiveCount", 4)
                     ))))
                 .build());
     
             var exampleQueueRedriveAllowPolicy = new RedriveAllowPolicy("exampleQueueRedriveAllowPolicy", RedriveAllowPolicyArgs.builder()
                 .queueUrl(exampleQueueDeadletter.id())
                 .redriveAllowPolicy(queue.arn().applyValue(_arn -> serializeJson(
                     jsonObject(
                         jsonProperty("redrivePermission", "byQueue"),
                         jsonProperty("sourceQueueArns", jsonArray(_arn))
                     ))))
                 .build());
     
         }
     }
     
     
    ### Server-side encryption (SSE) Using [SSE-SQS](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-sqs-sse-queue.html):
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.sqs.Queue;
     import com.pulumi.aws.sqs.QueueArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var queue = new Queue("queue", QueueArgs.builder()
                 .name("pulumi-example-queue")
                 .sqsManagedSseEnabled(true)
                 .build());
     
         }
     }
     
     
    Using [SSE-KMS](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-sse-existing-queue.html):
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.sqs.Queue;
     import com.pulumi.aws.sqs.QueueArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     import java.util.Map;
     import java.io.File;
     import java.nio.file.Files;
     import java.nio.file.Paths;
     
     public class App {
         public static void main(String[] args) {
             Pulumi.run(App::stack);
         }
     
         public static void stack(Context ctx) {
             var queue = new Queue("queue", QueueArgs.builder()
                 .name("example-queue")
                 .kmsMasterKeyId("alias/aws/sqs")
                 .kmsDataKeyReusePeriodSeconds(300)
                 .build());
     
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `url` (String) URL of the SQS queue. Using `pulumi import`, import SQS Queues using the queue `url`. For example: ```sh $ pulumi import aws:sqs/queue:Queue example https://queue.amazonaws.com/80398EXAMPLE/MyQueue ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Queue​(java.lang.String name)  
      Queue​(java.lang.String name, QueueArgs args)  
      Queue​(java.lang.String name, QueueArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> arn()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> contentBasedDeduplication()  
      com.pulumi.core.Output<java.lang.String> deduplicationScope()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> delaySeconds()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> fifoQueue()  
      com.pulumi.core.Output<java.lang.String> fifoThroughputLimit()  
      static Queue get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, QueueState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.Integer> kmsDataKeyReusePeriodSeconds()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> kmsMasterKeyId()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> maxMessageSize()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> messageRetentionSeconds()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.lang.String> namePrefix()  
      com.pulumi.core.Output<java.lang.String> policy()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> receiveWaitTimeSeconds()  
      com.pulumi.core.Output<java.lang.String> redriveAllowPolicy()  
      com.pulumi.core.Output<java.lang.String> redrivePolicy()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.lang.Boolean> sqsManagedSseEnabled()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()  
      com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> tagsAll()  
      com.pulumi.core.Output<java.lang.String> url()  
      com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> visibilityTimeoutSeconds()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Queue

        public Queue​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Queue

        public Queue​(java.lang.String name,
                     @Nullable
                     QueueArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Queue

        public Queue​(java.lang.String name,
                     @Nullable
                     QueueArgs args,
                     @Nullable
                     com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        ARN of the SQS queue.
      • contentBasedDeduplication

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> contentBasedDeduplication()
        Returns:
        Enables content-based deduplication for FIFO queues. For more information, see the [related documentation](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing).
      • deduplicationScope

        public com.pulumi.core.Output<java.lang.String> deduplicationScope()
        Returns:
        Specifies whether message deduplication occurs at the message group or queue level. Valid values are `messageGroup` and `queue` (default).
      • delaySeconds

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> delaySeconds()
        Returns:
        Time in seconds that the delivery of all messages in the queue will be delayed. An integer from 0 to 900 (15 minutes). The default for this attribute is 0 seconds.
      • fifoQueue

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> fifoQueue()
        Returns:
        Boolean designating a FIFO queue. If not set, it defaults to `false` making it standard.
      • fifoThroughputLimit

        public com.pulumi.core.Output<java.lang.String> fifoThroughputLimit()
        Returns:
        Specifies whether the FIFO queue throughput quota applies to the entire queue or per message group. Valid values are `perQueue` (default) and `perMessageGroupId`.
      • kmsDataKeyReusePeriodSeconds

        public com.pulumi.core.Output<java.lang.Integer> kmsDataKeyReusePeriodSeconds()
        Returns:
        Length of time, in seconds, for which Amazon SQS can reuse a data key to encrypt or decrypt messages before calling AWS KMS again. An integer representing seconds, between 60 seconds (1 minute) and 86,400 seconds (24 hours). The default is 300 (5 minutes).
      • kmsMasterKeyId

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> kmsMasterKeyId()
        Returns:
        ID of an AWS-managed customer master key (CMK) for Amazon SQS or a custom CMK. For more information, see [Key Terms](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-sse-key-terms).
      • maxMessageSize

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> maxMessageSize()
        Returns:
        Limit of how many bytes a message can contain before Amazon SQS rejects it. An integer from 1024 bytes (1 KiB) up to 1048576 bytes (1024 KiB). The default for this attribute is 262144 (256 KiB).
      • messageRetentionSeconds

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> messageRetentionSeconds()
        Returns:
        Number of seconds Amazon SQS retains a message. Integer representing seconds, from 60 (1 minute) to 1209600 (14 days). The default for this attribute is 345600 (4 days).
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        Name of the queue. Queue names must be made up of only uppercase and lowercase ASCII letters, numbers, underscores, and hyphens, and must be between 1 and 80 characters long. For a FIFO (first-in-first-out) queue, the name must end with the `.fifo` suffix. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
      • namePrefix

        public com.pulumi.core.Output<java.lang.String> namePrefix()
        Returns:
        Creates a unique name beginning with the specified prefix. Conflicts with `name`.
      • policy

        public com.pulumi.core.Output<java.lang.String> policy()
        Returns:
        JSON policy for the SQS queue. For more information about building AWS IAM policy documents see the AWS IAM Policy Document Guide. The provider will only perform drift detection of its value when present in a configuration. It is preferred to use the `aws.sqs.QueuePolicy` resource instead.
      • receiveWaitTimeSeconds

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> receiveWaitTimeSeconds()
        Returns:
        Time for which a ReceiveMessage call will wait for a message to arrive (long polling) before returning. An integer from 0 to 20 (seconds). The default for this attribute is 0, meaning that the call will return immediately.
      • redriveAllowPolicy

        public com.pulumi.core.Output<java.lang.String> redriveAllowPolicy()
        Returns:
        JSON policy to set up the Dead Letter Queue redrive permission, see [AWS docs](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html). The provider will only perform drift detection of its value when present in a configuration. It is preferred to use the `aws.sqs.RedriveAllowPolicy` resource instead.
      • redrivePolicy

        public com.pulumi.core.Output<java.lang.String> redrivePolicy()
        Returns:
        JSON policy to set up the Dead Letter Queue, see [AWS docs](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html). The provider will only perform drift detection of its value when present in a configuration. It is preferred to use the `aws.sqs.RedrivePolicy` resource instead. **Note:** when specifying `maxReceiveCount`, you must specify it as an integer (`5`), and not a string (`"5"`).
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • sqsManagedSseEnabled

        public com.pulumi.core.Output<java.lang.Boolean> sqsManagedSseEnabled()
        Returns:
        Boolean to enable server-side encryption (SSE) of message content with SQS-owned encryption keys. See [Encryption at rest](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html). The provider will only perform drift detection of its value when present in a configuration.
      • tags

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()
        Returns:
        Map of tags to assign to the queue. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
      • tagsAll

        public com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> tagsAll()
        Returns:
        Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
      • url

        public com.pulumi.core.Output<java.lang.String> url()
        Returns:
        Same as `id`: The URL for the created Amazon SQS queue.
      • visibilityTimeoutSeconds

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> visibilityTimeoutSeconds()
        Returns:
        Visibility timeout for the queue. An integer from 0 to 43200 (12 hours). The default for this attribute is 30. For more information about visibility timeout, see [AWS docs](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html).
      • get

        public static Queue get​(java.lang.String name,
                                com.pulumi.core.Output<java.lang.String> id,
                                @Nullable
                                QueueState state,
                                @Nullable
                                com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.