Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_connect_queue - support delete #32538

Merged
merged 5 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/32538.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_connect_queue: add delete function
```
25 changes: 22 additions & 3 deletions internal/service/connect/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ func ResourceQueue() *schema.Resource {
CreateWithoutTimeout: resourceQueueCreate,
ReadWithoutTimeout: resourceQueueRead,
UpdateWithoutTimeout: resourceQueueUpdate,
// Queues do not support deletion today. NoOp the Delete method.
// Users can rename their queues manually if they want.
DeleteWithoutTimeout: schema.NoopContext,
DeleteWithoutTimeout: resourceQueueDelete,

Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
Expand Down Expand Up @@ -346,6 +344,27 @@ func resourceQueueUpdate(ctx context.Context, d *schema.ResourceData, meta inter
return resourceQueueRead(ctx, d, meta)
}

func resourceQueueDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
conn := meta.(*conns.AWSClient).ConnectConn(ctx)

instanceID, queueID, err := QueueParseID(d.Id())

if err != nil {
return diag.FromErr(err)
}

_, err = conn.DeleteQueueWithContext(ctx, &connect.DeleteQueueInput{
InstanceId: aws.String(instanceID),
QueueId: aws.String(queueID),
})

if err != nil {
return diag.Errorf("deleting Queue (%s): %s", d.Id(), err)
}

return nil
}

func expandOutboundCallerConfig(outboundCallerConfig []interface{}) *connect.OutboundCallerConfig {
if len(outboundCallerConfig) == 0 || outboundCallerConfig[0] == nil {
return nil
Expand Down
2 changes: 0 additions & 2 deletions internal/service/connect/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ func testAccQueue_basic(t *testing.T) {
}

func testAccQueue_disappears(t *testing.T) {
t.Skip("Queues do not support deletion today")

ctx := acctest.Context(t)

var v connect.DescribeQueueOutput
Expand Down
2 changes: 0 additions & 2 deletions website/docs/r/connect_queue.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ description: |-
Provides an Amazon Connect Queue resource. For more information see
[Amazon Connect: Getting Started](https://docs.aws.amazon.com/connect/latest/adminguide/amazon-connect-get-started.html)

~> **NOTE:** Due to The behaviour of Amazon Connect you cannot delete queues.

## Example Usage

### Basic
Expand Down