hashicorp / terraform-provider-awscc

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

Refreshing state takes minutes for a handful of resources, CPU utilisation 150% #618

Open gevial opened 2 years ago

gevial commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Cloud Control Provider Version

Terraform v1.2.6 on darwin_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.

terraform {
  required_providers {
    aws = {
      version = ">= 4.0"
      source  = "hashicorp/aws"
    }
    awscc = {
      version = ">= 0.29"
      source  = "hashicorp/awscc"
    }
  }
}

provider "aws" {
  region = "eu-west-2"
}

provider "awscc" {
  region = "eu-west-2"
}

resource "awscc_connect_phone_number" "this" {
  country_code = "GB"
  target_arn   = aws_connect_instance.this.arn
  type         = "DID"
}

resource "awscc_lex_bot" "util" {
  name = "Util"
  data_privacy = {
    child_directed = false
  }
  idle_session_ttl_in_seconds = 300
  role_arn                    = aws_iam_role.bots.arn
  auto_build_bot_locales      = true
  bot_locales = [
    {
      locale_id                = "en_GB"
      nlu_confidence_threshold = 0.5
      intents = [
        {
          name = "Greeting"
          sample_utterances = [
            { utterance = "Hi" },
            { utterance = "Hello" },
            { utterance = "Hiya" },
            { utterance = "Hi there" },
            { utterance = "Good morning" },
            { utterance = "Good afternoon" },
            { utterance = "Greetings" },
          ]
        },
        {
          name = "Yes"
          sample_utterances = [
            { utterance = "Yes" },
            { utterance = "Yep" },
            { utterance = "Yeah" },
            { utterance = "Definitely" },
            { utterance = "I think so" },
            { utterance = "Absolutely" },
          ]
        },
        {
          name = "No"
          sample_utterances = [
            { utterance = "No" },
            { utterance = "Nope" },
            { utterance = "That's it" },
            { utterance = "No, thank you" },
            { utterance = "No, thanks" },
          ]
        },
        {
          name                    = "FallbackIntent"
          parent_intent_signature = "AMAZON.FallbackIntent"
        }
      ]
    }
  ]
}

Debug Output

Panic Output

Expected Behavior

State refreshed in reasonable time (I believe in under 1m for a couple of resources), no excessive CPU usage

Actual Behavior

State of awscc_lex_bot is being refreshed in several minutes with CPU utilisation of awscc-terraform-provider process of 150%

Screenshot 2022-08-10 at 11 19 45

Steps to Reproduce

  1. terraform plan

Important Factoids

References

gevial commented 2 years ago

I can now see the same behaviour when refreshing state of awscc_connect_phone_number

gevial commented 2 years ago

Also noticed that after Terraform showed this: Plan: 1 to add, 0 to change, 0 to destroy. it didn't release the console input back and CPU utilisation was still 150%. I think it would time out, but I just entered Yes without a prompt and it proceeds with creating.