Repository: getmoto/moto

Issue:
SQS queue resources fail to complete creation with timeout error
# Problem
I'm unable to create _aws_sqs_queue_ resources. I'm using Terraform provider 4.67.0 & 5.34.0 (latest) with Terraform version 1.5.7.

Note: I did try different SQS queue configs but was unable to pinpoint this down to a specific resource attribute. I was able to successfully run the same code within AWS.

# Reproduction
```hcl
provider "aws" {
  region                      = "us-east-1"
  s3_use_path_style           = true
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    acm            = "http://localhost:5000"
    apigateway     = "http://localhost:5000"
    cloudformation = "http://localhost:5000"
    cloudwatch     = "http://localhost:5000"
    dynamodb       = "http://localhost:5000"
    es             = "http://localhost:5000"
    firehose       = "http://localhost:5000"
    iam            = "http://localhost:5000"
    kinesis        = "http://localhost:5000"
    lambda         = "http://localhost:5000"
    route53        = "http://localhost:5000"
    redshift       = "http://localhost:5000"
    s3             = "http://localhost:5000"
    secretsmanager = "http://localhost:5000"
    ses            = "http://localhost:5000"
    sns            = "http://localhost:5000"
    sqs            = "http://localhost:5000"
    ssm            = "http://localhost:5000"
    stepfunctions  = "http://localhost:5000"
    sts            = "http://localhost:5000"
    ec2            = "http://localhost:5000"
  }

  access_key = "my-access-key"
  secret_key = "my-secret-key"
}

terraform {
  required_providers {

    aws = {
      source  = "hashicorp/aws"
      version = "4.67.0"
    }
  }
}


resource "aws_sqs_queue" "queue" {
  name                        = "test-queue"
  fifo_queue                  = false
  delay_seconds               = 0
  max_message_size            = 16384
  message_retention_seconds   = 86400
  visibility_timeout_seconds  = 30
  receive_wait_time_seconds   = 0
  redrive_policy              = null
  content_based_deduplication = false
  sqs_managed_sse_enabled     = true
}
``` 

Error:
```
Terraform will perform the following actions:

  # aws_sqs_queue.queue will be created
  + resource "aws_sqs_queue" "queue" {
      + arn                               = (known after apply)
      + content_based_deduplication       = false
      + deduplication_scope               = (known after apply)
      + delay_seconds                     = 0
      + fifo_queue                        = false
      + fifo_throughput_limit             = (known after apply)
      + id                                = (known after apply)
      + kms_data_key_reuse_period_seconds = (known after apply)
      + max_message_size                  = 16384
      + message_retention_seconds         = 86400
      + name                              = "test-queue"
      + name_prefix                       = (known after apply)
      + policy                            = (known after apply)
      + receive_wait_time_seconds         = 0
      + redrive_allow_policy              = (known after apply)
      + redrive_policy                    = (known after apply)
      + sqs_managed_sse_enabled           = true
      + tags_all                          = (known after apply)
      + url                               = (known after apply)
      + visibility_timeout_seconds        = 30
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_sqs_queue.queue: Creating...
aws_sqs_queue.queue: Still creating... [10s elapsed]
aws_sqs_queue.queue: Still creating... [20s elapsed]
aws_sqs_queue.queue: Still creating... [30s elapsed]
aws_sqs_queue.queue: Still creating... [40s elapsed]
aws_sqs_queue.queue: Still creating... [50s elapsed]
aws_sqs_queue.queue: Still creating... [1m0s elapsed]
aws_sqs_queue.queue: Still creating... [1m10s elapsed]
aws_sqs_queue.queue: Still creating... [1m20s elapsed]
aws_sqs_queue.queue: Still creating... [1m30s elapsed]
aws_sqs_queue.queue: Still creating... [1m40s elapsed]
aws_sqs_queue.queue: Still creating... [1m50s elapsed]
aws_sqs_queue.queue: Still creating... [2m0s elapsed]
╷
│ Error: waiting for SQS Queue (http://localhost:5000/123456789012/test-queue) attributes create: timeout while waiting for state to become 'equal' (last state: 'notequal', timeout: 2m0s)
│ 
│   with aws_sqs_queue.queue,
│   on main.tf line 47, in resource "aws_sqs_queue" "queue":
│   47: resource "aws_sqs_queue" "queue" {
│ 
╵
``` 

Moto server logs during the apply: 
Note: Moto server is running in Docker using _motoserver/moto:latest_ image
```
2024-01-29 11:28:00  * Running on all addresses (0.0.0.0)
2024-01-29 11:28:00  * Running on http://127.0.0.1:5000
2024-01-29 11:28:00  * Running on http://172.25.0.2:5000
2024-01-29 11:28:00 Press CTRL+C to quit
2024-01-29 11:28:50 192.168.65.1 - - [29/Jan/2024 17:28:50] "POST / HTTP/1.1" 200 -
2024-01-29 11:28:50 192.168.65.1 - - [29/Jan/2024 17:28:50] "POST / HTTP/1.1" 200 -
2024-01-29 11:28:55 192.168.65.1 - - [29/Jan/2024 17:28:55] "POST / HTTP/1.1" 200 -
2024-01-29 11:29:05 192.168.65.1 - - [29/Jan/2024 17:29:05] "POST / HTTP/1.1" 200 -
2024-01-29 11:29:15 192.168.65.1 - - [29/Jan/2024 17:29:15] "POST / HTTP/1.1" 200 -
2024-01-29 11:29:25 192.168.65.1 - - [29/Jan/2024 17:29:25] "POST / HTTP/1.1" 200 -
2024-01-29 11:29:35 192.168.65.1 - - [29/Jan/2024 17:29:35] "POST / HTTP/1.1" 200 -
2024-01-29 11:29:45 192.168.65.1 - - [29/Jan/2024 17:29:45] "POST / HTTP/1.1" 200 -
2024-01-29 11:29:55 192.168.65.1 - - [29/Jan/2024 17:29:55] "POST / HTTP/1.1" 200 -
2024-01-29 11:30:05 192.168.65.1 - - [29/Jan/2024 17:30:05] "POST / HTTP/1.1" 200 -
2024-01-29 11:30:15 192.168.65.1 - - [29/Jan/2024 17:30:15] "POST / HTTP/1.1" 200 -
2024-01-29 11:30:25 192.168.65.1 - - [29/Jan/2024 17:30:25] "POST / HTTP/1.1" 200 -
2024-01-29 11:30:35 192.168.65.1 - - [29/Jan/2024 17:30:35] "POST / HTTP/1.1" 200 -
2024-01-29 11:30:45 192.168.65.1 - - [29/Jan/2024 17:30:45] "POST / HTTP/1.1" 200 -
``` 

# Additional testing with AWS provider 5.34.0
```
Initializing provider plugins...
- Finding latest version of hashicorp/aws...
- Installing hashicorp/aws v5.34.0...
- Installed hashicorp/aws v5.34.0 (signed by HashiCorp)

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Terraform/moto_testing/sqs_queue took 5.4s 
➜ tfa

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_sqs_queue.queue will be created
  + resource "aws_sqs_queue" "queue" {
      + arn                               = (known after apply)
      + content_based_deduplication       = false
      + deduplication_scope               = (known after apply)
      + delay_seconds                     = 0
      + fifo_queue                        = false
      + fifo_throughput_limit             = (known after apply)
      + id                                = (known after apply)
      + kms_data_key_reuse_period_seconds = (known after apply)
      + max_message_size                  = 16384
      + message_retention_seconds         = 86400
      + name                              = "test-queue"
      + name_prefix                       = (known after apply)
      + policy                            = (known after apply)
      + receive_wait_time_seconds         = 0
      + redrive_allow_policy              = (known after apply)
      + redrive_policy                    = (known after apply)
      + sqs_managed_sse_enabled           = true
      + tags_all                          = (known after apply)
      + url                               = (known after apply)
      + visibility_timeout_seconds        = 30
    }

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Warning: AWS account ID not found for provider
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 1, in provider "aws":
│    1: provider "aws" {
│ 
│ See https://registry.terraform.io/providers/hashicorp/aws/latest/docs#skip_requesting_account_id for
│ implications.
╵

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_sqs_queue.queue: Creating...
aws_sqs_queue.queue: Still creating... [10s elapsed]
aws_sqs_queue.queue: Still creating... [20s elapsed]
aws_sqs_queue.queue: Still creating... [30s elapsed]
aws_sqs_queue.queue: Still creating... [40s elapsed]
aws_sqs_queue.queue: Still creating... [50s elapsed]
aws_sqs_queue.queue: Still creating... [1m0s elapsed]
aws_sqs_queue.queue: Still creating... [1m10s elapsed]
aws_sqs_queue.queue: Still creating... [1m20s elapsed]
aws_sqs_queue.queue: Still creating... [1m30s elapsed]
aws_sqs_queue.queue: Still creating... [1m40s elapsed]
aws_sqs_queue.queue: Still creating... [1m50s elapsed]
aws_sqs_queue.queue: Still creating... [2m0s elapsed]
╷
│ Warning: AWS account ID not found for provider
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on main.tf line 1, in provider "aws":
│    1: provider "aws" {
│ 
│ See https://registry.terraform.io/providers/hashicorp/aws/latest/docs#skip_requesting_account_id for
│ implications.
╵
╷
│ Error: waiting for SQS Queue (http://localhost:5000/123456789012/test-queue) attributes create: timeout while waiting for state to become 'equal' (last state: 'notequal', timeout: 2m0s)
│ 
│   with aws_sqs_queue.queue,
│   on main.tf line 47, in resource "aws_sqs_queue" "queue":
│   47: resource "aws_sqs_queue" "queue" {
``` 

# Testing against AWS
```
provider "aws" {
  region  = "us-east-1"
  profile = "us-cloud-sandbox"
}

terraform {
  required_providers {

    aws = {
      source  = "hashicorp/aws"
      version = "4.67.0"
    }
  }
}


resource "aws_sqs_queue" "queue" {
  name                        = "rafal-test-queue"
  fifo_queue                  = false
  delay_seconds               = 0
  max_message_size            = 16384
  message_retention_seconds   = 86400
  visibility_timeout_seconds  = 30
  receive_wait_time_seconds   = 0
  redrive_policy              = null
  content_based_deduplication = false
  sqs_managed_sse_enabled     = true
}
``` 

Result:
```
Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_sqs_queue.queue will be created
  + resource "aws_sqs_queue" "queue" {
      + arn                               = (known after apply)
      + content_based_deduplication       = false
      + deduplication_scope               = (known after apply)
      + delay_seconds                     = 0
      + fifo_queue                        = false
      + fifo_throughput_limit             = (known after apply)
      + id                                = (known after apply)
      + kms_data_key_reuse_period_seconds = (known after apply)
      + max_message_size                  = 16384
      + message_retention_seconds         = 86400
      + name                              = "rafal-test-queue"
      + name_prefix                       = (known after apply)
      + policy                            = (known after apply)
      + receive_wait_time_seconds         = 0
      + redrive_allow_policy              = (known after apply)
      + redrive_policy                    = (known after apply)
      + sqs_managed_sse_enabled           = true
      + tags_all                          = (known after apply)
      + url                               = (known after apply)
      + visibility_timeout_seconds        = 30
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_sqs_queue.queue: Creating...
aws_sqs_queue.queue: Still creating... [10s elapsed]
aws_sqs_queue.queue: Still creating... [20s elapsed]
aws_sqs_queue.queue: Creation complete after 25s [id=https://sqs.us-east-1.amazonaws.com/$ACCOUNT_NUM/rafal-test-queue]
``` 


Discussion:

Resolving patch:
diff --git a/moto/sqs/models.py b/moto/sqs/models.py
--- a/moto/sqs/models.py
+++ b/moto/sqs/models.py
@@ -243,6 +243,7 @@ class Queue(CloudFormationModel):
         "RedrivePolicy",
         "ReceiveMessageWaitTimeSeconds",
         "VisibilityTimeout",
+        "SqsManagedSseEnabled",
     ]
     FIFO_ATTRIBUTES = [
         "ContentBasedDeduplication",
@@ -298,6 +299,7 @@ def __init__(self, name: str, region: str, account_id: str, **kwargs: Any):
             "ReceiveMessageWaitTimeSeconds": 0,
             "RedrivePolicy": None,
             "VisibilityTimeout": 30,
+            "SqsManagedSseEnabled": True,
         }
 
         defaults.update(kwargs)


Test patch: