hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.12k forks source link

[Bug]: Terraform unable to Update Amazon Connect Instance #38115

Open livlevi opened 3 months ago

livlevi commented 3 months ago

Terraform Core Version

1.8.x

AWS Provider Version

registry.terraform.io/hashicorp/aws v5.52.0

Affected Resource(s)

aws_connect_instance

Expected Behavior

the amazon_connect_resource should be able to deploy and modify the instance as needed.

Actual Behavior

When deploying an instance for the first time, it gets created successfully. However, when attempting to add / change configuration instance there is an error.

For

Relevant Error/Panic Output Snippet

This is the result from an Azure DevOps pipeline.

aws_connect_instance.connect_contactcenter: Creating...
╷
│ Error: creating Connect Instance: InvalidRequestException: Invalid Input. Instance alias is already used.
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "b9296daa-4b86-472b-9e4f-dd11ec11fa29"
│   },
│   Message_: "Invalid Input. Instance alias is already used."
│ }
│ 
│   with aws_connect_instance.connect_contactcenter,
│   on main.tf line 7, in resource "aws_connect_instance" "connect_contactcenter":
│    7: resource "aws_connect_instance" "connect_contactcenter" {
│ 
╵

##[error]Bash exited with code '1'.
Finishing: apply

This is the result of an attempt to deploy in AWS Cloudshell:

aws_connect_instance.connect_contactcenter: Destroying... [id=f48451f7-2710-47bc-99d8-577e662a6d79]
aws_connect_instance.connect_contactcenter: Destruction complete after 0s
aws_connect_instance.connect_contactcenter: Creating...
╷
│ Error: creating Connect Instance: InvalidRequestException: Invalid Input. Instance alias is already used.
│ {
│   RespMetadata: {
│     StatusCode: 400,
│     RequestID: "53c05779-a39c-446f-aed9-265cc1d507ad"
│   },
│   Message_: "Invalid Input. Instance alias is already used."
│ }
│ 
│   with aws_connect_instance.connect_contactcenter,
│   on main.tf line 7, in resource "aws_connect_instance" "connect_contactcenter":
│    7: resource "aws_connect_instance" "connect_contactcenter" {
│ 

Terraform Configuration Files

resource "aws_connect_instance" "connect_contactcenter" {
  identity_management_type  = "CONNECT_MANAGED"
  inbound_calls_enabled     = true
  instance_alias            = "connectInstance"
  outbound_calls_enabled    = true
  contact_flow_logs_enabled = true

}

resource "aws_connect_hours_of_operation" "hours_of_operation" {
  instance_id = aws_connect_instance.connect_contactcenter.id
  name        = "24/7 hours"
  description = "Amazon Connect Instance"
  time_zone   = "EST"

  config {
    day = "MONDAY"

    end_time {
      hours   = 0
      minutes = 0
    }

    start_time {
      hours   = 0
      minutes = 0
    }
  }

  config {
    day = "TUESDAY"

    end_time {
      hours   = 0
      minutes = 0
    }

    start_time {
      hours   = 0
      minutes = 0
    }
  }

  config {
    day = "WEDNESDAY"

    end_time {
      hours   = 0
      minutes = 0
    }

    start_time {
      hours   = 0
      minutes = 0
    }
  }

  config {
    day = "THURSDAY"

    end_time {
      hours   = 0
      minutes = 0
    }

    start_time {
      hours   = 0
      minutes = 0
    }
  }

  config {
    day = "FRIDAY"

    end_time {
      hours   = 0
      minutes = 0
    }

    start_time {
      hours   = 0
      minutes = 0
    }
  }

  config {
    day = "SATURDAY"

    end_time {
      hours   = 0
      minutes = 0
    }

    start_time {
      hours   = 0
      minutes = 0
    }
  }

  config {
    day = "SUNDAY"

    end_time {
      hours   = 0
      minutes = 0
    }

    start_time {
      hours   = 0
      minutes = 0
    }
  }
}

resource "aws_connect_contact_flow" "contact_flow_straightToQueue" {
  instance_id = aws_connect_instance.connect_contactcenter.id
  name = "straight_to_queue"
  description = "Contact flow that sends calls straight to queue"
  type = "CONTACT_FLOW"
  content = jsonencode ( <<json config>>)
}

resource "aws_connect_queue" "basic_queue" {
  instance_id = aws_connect_instance.connect_contactcenter.id
  name = "M1S Basic Queue"
  description = "Standard Queue for Amazon Connect"
  hours_of_operation_id = aws_connect_hours_of_operation.hours_of_operation.hours_of_operation_id

  tags = {
    "Name" = "Standard Queue"
  }
}

resource "aws_connect_routing_profile" "routing_profile" {
  instance_id = aws_connect_instance.connect_contactcenter.id
  name = "Basic Routing Profile"
  default_outbound_queue_id = aws_connect_queue.basic_queue.queue_id
  description = "Basic Routing Profile for M1S Connect instance"

  media_concurrencies {
    channel = "VOICE"
    concurrency = 1
  }

  media_concurrencies {
    channel = "CHAT"
    concurrency = 2
  }

  media_concurrencies {
    channel = "TASK"
    concurrency = 1
  }

  queue_configs {
    channel = "VOICE"
    delay = 0
    priority = 1
    queue_id = aws_connect_queue.basic_queue.queue_id
  }
  queue_configs {
    channel = "CHAT"
    delay = 0
    priority = 1
    queue_id = aws_connect_queue.basic_queue.queue_id
  }

  queue_configs {
    channel = "TASK"
    delay = 0
    priority = 1
    queue_id = aws_connect_queue.basic_queue.queue_id
  }

}

Steps to Reproduce

A simple terraform init / plan / apply

Debug Output

No response

Panic Output

No response

Important Factoids

This is a Gov account, I was unable to reproduce in my personal account because of service quota issues.

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 3 months ago

Hey @livlevi 👋 Thank you for taking the time to raise this, and for the heads up about this being related to Gov. I have a couple of follow ups to help whoever picks this up: