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

[Bug]: aws_chime_voice_connector and related resources error and auto-taint after SDK upgrade #34218

Closed
jeffhuenemann opened this issue Nov 2, 2023 · 4 comments · Fixed by #34334
Assignees
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/chime Issues and PRs that pertain to the chime service.
Milestone

Comments

@jeffhuenemann
Copy link

jeffhuenemann commented Nov 2, 2023

Terraform Core Version

1.6.2

AWS Provider Version

5.22.0

Affected Resource(s)

  • aws_chime_voice_connector
  • aws_chime_voice_connector_termination
  • maybe more in that area

Expected Behavior

A configuration containing these resources should apply successfully in one pass of terraform apply

Actual Behavior

The resources for Chime SDK Voice Connector service were updated on #33976 (from bug #33633), in v5.22.0 (though this was somehow excluded from the changelog for that release).

Following that release, running into what feels like some sort of race condition during resource creation (a get of some kind is failing while the create is still happening), and manual workaround (see below) is required to get all resources deployed successfully.

First attempt to deploy configuration:

aws_chime_voice_connector.vc: Creating...
╷
│ Error: getting Voice connector (---id redacted---): NotFoundException: Could not find VoiceConnector with Id '---id redacted---'
│
│   with aws_chime_voice_connector.vc,
│   on main.tf line 5, in resource "aws_chime_voice_connector" "vc":
│    5: resource "aws_chime_voice_connector" "vc" {
│
╵
Operation failed: failed running terraform apply (exit 1)

Following this, we see the resource in state file, but missing expected attributes, and with a status of tainted.

Second attempt recreates the tainted resource, but still fails the same a second time:

Plan:

  # aws_chime_voice_connector.vc is tainted, so must be replaced
-/+ resource "aws_chime_voice_connector" "vc" {
      ~ arn                = "arn:aws:chime:us-west-2:xxxxacctxxxx:vc/---id redacted---" -> (known after apply)
      ~ id                 = "---id redacted---" -> (known after apply)
        name               = "xxxxxxxx"
      ~ outbound_host_name = "---id redacted---.voiceconnector.chime.aws" -> (known after apply)
        # (3 unchanged attributes hidden)
    }

  # aws_chime_voice_connector_termination.vc_term will be created
  + resource "aws_chime_voice_connector_termination" "vc_term" {
        #... (snip)
    }

  # aws_chime_voice_connector_termination_credentials.vc_term_creds will be created
  + resource "aws_chime_voice_connector_termination_credentials" "vc_term_creds" {
      + id                 = (known after apply)
      + voice_connector_id = (known after apply)
    }

Plan: 3 to add, 0 to change, 1 to destroy.

Apply:

aws_chime_voice_connector.vc: Destroying... [id=---id redacted---]
aws_chime_voice_connector.vc: Destruction complete after 0s
aws_chime_voice_connector.vc: Creating...
╷
│ Error: getting Voice connector (---**NEW** id redacted---): NotFoundException: Could not find VoiceConnector with Id '---**NEW** id redacted---'
│
│   with aws_chime_voice_connector.vc,
│   on main.tf line 5, in resource "aws_chime_voice_connector" "vc":
│    5: resource "aws_chime_voice_connector" "vc" {
│
╵
Operation failed: failed running terraform apply (exit 1)

After this apply, the replacement voice connector was created in AWS, as it was the first time, but again already tainted and missing attributes like the ARN in state. Additionally, the terraform apply run does not continue on to create the remaining resources.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

terraform.tf:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.22.0"
    }
  }

  cloud {
    # Organization and Workspace to be configured as variables in CI/CD pipeline,
    # but that still requires empty "cloud {}" block here
  }
}

provider "aws" {
  # AWS Provider Configuration Options
  region = var.voice_connector_aws_region
  # "access_key" and "secret_key" to be filled in by environment variables
  # AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY stored in Terraform Cloud Workspace
}

main.tf:

resource "aws_chime_voice_connector" "vc" {
  name               = var.voice_connector_name
  aws_region         = var.voice_connector_aws_region
  require_encryption = true
  tags               = var.voice_connector_tags
}

resource "aws_chime_voice_connector_termination" "vc_term" {
  voice_connector_id = aws_chime_voice_connector.vc.id
  cidr_allow_list    = var.outbound_calling_cidr_allow_list
  calling_regions    = var.outbound_calling_allowed_regions
  disabled           = var.outbound_calling_disabled
  cps_limit          = var.outbound_calling_cps_limit
}

resource "aws_chime_voice_connector_termination_credentials" "vc_term_creds" {
  voice_connector_id = aws_chime_voice_connector.vc.id
  depends_on         = [aws_chime_voice_connector_termination.vc_term] # termination settings must be set first; this avoids race condition

  credentials {
    username = var.outbound_calling_SIP_credentials_username
    password = var.outbound_calling_SIP_credentials_password
  }
}

Steps to Reproduce

How to recreate and workaround:

  1. terraform apply - errors during creation of aws_chime_voice_connector.vc resource, but actual voice connector is provisioned in AWS and is immediately tainted in state
  2. terraform untaint aws_chime_voice_connector.vc - successful
  3. terraform apply -refresh-only - pulls missing attributes into state (resource was created fine the first time, but provider errored before capturing entire state)
  4. terraform apply - no change proposed for aws_chime_voice_connector.vc, errors similarly during creation of aws_chime_voice_connector_termination.vc_term, which is immediately tainted in state
  5. terraform untaint aws_chime_voice_connector_termination.vc_term - successful
  6. terraform apply -refresh-only - pulls missing attributes of aws_chime_voice_connector_termination.vc_term into state
  7. terraform apply - no change proposed for aws_chime_voice_connector.vc or aws_chime_voice_connector_termination.vc_term, and provisions aws_chime_voice_connector_termination_credentials.vc_term_creds successfully on first try.

Debug Output

No response

Panic Output

No response

Important Factoids

Running in Terraform Cloud. Did not experience this issue when running with var.voice_connector_aws_region set to us-east-1, but did have the problem repeatedly, with same main.tf, if var.voice_connector_aws_region set to us-west-2 for our secondary region.

References

#33633 - Initial bug report that voice connector resources were using outdated Chime SDK APIs (related to aws/amazon-chime-sdk-js/issues/2697)
#33976 - PR to update Chime SDK resources to newer AWS SDK version

Would you like to implement a fix?

No

@jeffhuenemann jeffhuenemann added the bug Addresses a defect in current functionality. label Nov 2, 2023
Copy link

github-actions bot commented Nov 2, 2023

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the service/chime Issues and PRs that pertain to the chime service. label Nov 2, 2023
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Nov 2, 2023
@justinretzolk justinretzolk added regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 2, 2023
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 2, 2023
@jeffhuenemann
Copy link
Author

Worked on our production deployments of the same configuration today, with similar results in an all-new workspace:

  • worked OK when API is targeting us-east-1
  • failed exactly as above (and same workaround necessary) when targeting us-west-2

Also tried with upgrade of aws provider to 5.24.0 with no change.

@johnsonaj johnsonaj self-assigned this Nov 9, 2023
@github-actions github-actions bot added this to the v5.26.0 milestone Nov 13, 2023
@github-actions github-actions bot removed the bug Addresses a defect in current functionality. label Nov 16, 2023
Copy link

This functionality has been released in v5.26.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 17, 2023
@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/chime Issues and PRs that pertain to the chime service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants