hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
249 stars 114 forks source link

Applying 'awscc_connect_approved_origin' causes crash in the awscc plugin #1058

Open StianHanssen opened 1 year ago

StianHanssen commented 1 year ago

Community Note

Terraform CLI and Terraform AWS Cloud Control Provider Version

Terraform v1.5.3 on linux_amd64

Also tested on: Terraform v1.4.6 on linux_amd64

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

This was a small module, but I move the provider into it to give a minimal example. I have changed things like names as this is an internal project at my company, but all configurations are the same.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
    awscc = {
      source  = "hashicorp/awscc"
      version = "~> 0.55"
    }
  }

  required_version = ">= 1.2.0"
}

provider "aws" {
  region  = "ap-northeast-1"
}

provider "awscc" {
  region = "ap-northeast-1"
}

resource "aws_connect_instance" "main" {
  identity_management_type  = "SAML"
  inbound_calls_enabled     = true
  instance_alias            = "MyCallCenter"
  outbound_calls_enabled    = true
  contact_lens_enabled      = true
  contact_flow_logs_enabled = true
  lifecycle {
    prevent_destroy = true
  }
}

resource "awscc_connect_approved_origin" "main" {
  instance_id = aws_connect_instance.main.arn
  origin      = "https://localhost:3000"
}

Debug Output

Sorry, I can't really provide the whole log as it is from an internal project. https://gist.github.com/StianHanssen/0c7217654f81945fb61fd8f71bb411cf

Panic Output

https://gist.github.com/StianHanssen/0c7217654f81945fb61fd8f71bb411cf

Expected Behavior

That it is able to create awscc_connect_approved_origin.

Actual Behavior

Crashes during terraform apply.

Steps to Reproduce

Just run terraform apply.

Important Factoids

After investigating for a while, I found that running the apply with an admin role did not crash like the log above. Instead, I got a much more sensible message:

Waiting for Cloud Control API service CreateResource operation
│ completion returned: waiter state transitioned to FAILED.
│ StatusMessage: This Approved Origin already exists. ErrorCode:
│ AlreadyExists

It is likely the crash is due to the plugin not handling the lack of permissions appropriately.

References

StianHanssen commented 1 year ago

We were initially quite confused as we had AmazonConnect_FullAccess attached to the role. We found that we lacked: