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]: Importing an existing aws_cur_report_definition appears to hang the terraform client forever. #36446

Closed
spkane opened this issue Mar 18, 2024 · 8 comments · Fixed by #36540
Labels
bug Addresses a defect in current functionality. service/cur Issues and PRs that pertain to the cur service.
Milestone

Comments

@spkane
Copy link

spkane commented Mar 18, 2024

Terraform Core Version

1.5.7

AWS Provider Version

5.40.0

Affected Resource(s)

  • aws_cur_report_definition

Expected Behavior

When trying to import an existing aws_cur_report_definition, I expect it to work or provide an actionable error.

Actual Behavior

When running terraform import aws_cur_report_definition.daily_athena DailyCostReport the terraform client appears to hang forever.

$ terraform import aws_cur_report_definition.daily_athena DailyCostReport

aws_cur_report_definition.daily_athena: Importing from ID "DailyCostReport"...
aws_cur_report_definition.daily_athena: Import prepared!
  Prepared aws_cur_report_definition for import
aws_cur_report_definition.daily_athena: Refreshing state... [id=DailyCostReport]
module.account_base_one.data.aws_iam_policy_document.github_actions_assume_role_policy[0]: Reading...
module.account_base_one.data.aws_iam_policy_document.github_actions_assume_role_policy[0]: Read complete after 0s [id=2014869505]
module.account_base_two.data.aws_iam_policy_document.github_actions_assume_role_policy[0]: Reading...
module.account_base_two.data.aws_iam_policy_document.github_actions_assume_role_policy[0]: Read complete after 0s [id=930710228]
module.account_base_three.data.aws_iam_policy_document.github_actions_assume_role_policy[0]: Reading...
module.account_base_three.data.aws_iam_policy_document.github_actions_assume_role_policy[0]: Read complete after 0s [id=940565926]
module.account_base_four.data.aws_iam_policy_document.github_actions_assume_role_policy[0]: Reading...
module.account_base_four.data.aws_iam_policy_document.github_actions_assume_role_policy[0]: Read complete after 0s [id=1550200676]
  • It just hangs at this point

Relevant Error/Panic Output Snippet

  • Enabling TF_LOG=trace results in an endless loop of lines like this:
2024-03-18T15:52:18.378-0700 [DEBUG] provider.terraform-provider-aws_v5.40.0_x5: HTTP Request Sent: aws.region=us-west-2 http.request.header.x_amz_date=20240318T225218Z @module=aws http.request.header.x_amz_target=AWSOrigamiServiceGatewayService.DescribeReportDefinitions http.user_agent="APN/1.0 HashiCorp/1.0 Terraform/1.5.7 (+https://www.terraform.io) terraform-provider-aws/5.40.0 (+https://registry.terraform.io/providers/hashicorp/aws) aws-sdk-go/1.50.33 (go1.21.7; darwin; arm64)" rpc.method=DescribeReportDefinitions rpc.system=aws-api tf_aws.sdk=aws-sdk-go tf_req_id=5207dd45-0019-b5cf-038a-dba52d48b7cf tf_resource_type=aws_cur_report_definition http.request.header.authorization="AWS4-HMAC-SHA256 Credential=AKIA************IFOG/20240318/us-west-2/somewhere/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-target, Signature=*****" http.request.header.content_type=application/x-amz-json-1.1 net.peer.name=somewhere.us-west-2.amazonaws.com rpc.service="Cost and Usage Report Service" tf_mux_provider=*schema.GRPCProviderServer @caller=github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/[email protected]/logger.go:109 http.request.body="{}
" http.method=POST http.request_content_length=2 http.url=https://somewhere.us-west-2.amazonaws.com/ tf_provider_addr=registry.terraform.io/hashicorp/aws tf_rpc=ReadResource http.flavor=1.1 timestamp=2024-03-18T15:52:18.377-0700
2024-03-18T15:52:20.615-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:52:20.624-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:52:21.364-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:52:22.330-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"
2024-03-18T15:52:25.616-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:52:25.625-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:52:26.365-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:52:27.331-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"
2024-03-18T15:52:30.617-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:52:30.626-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:52:31.366-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:52:32.332-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"
2024-03-18T15:52:35.619-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:52:35.627-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:52:36.367-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:52:37.334-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"
2024-03-18T15:52:40.620-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:52:40.628-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:52:41.368-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:52:42.335-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"
2024-03-18T15:52:45.620-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:52:45.629-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:52:46.368-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:52:47.336-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"
2024-03-18T15:52:50.621-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:52:50.630-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:52:51.370-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:52:52.337-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"
2024-03-18T15:52:55.622-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:52:55.631-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:52:56.370-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:52:57.338-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"
2024-03-18T15:53:00.623-0700 [TRACE] dag/walk: vertex "root" is waiting for "aws_cur_report_definition.daily_athena (import id \"DailyCostReport\")"
2024-03-18T15:53:00.633-0700 [TRACE] dag/walk: vertex "root" is waiting for "import aws_cur_report_definition.daily_athena result"
2024-03-18T15:53:01.372-0700 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" is waiting for "aws_cur_report_definition.daily_athena (expand)"
2024-03-18T15:53:02.339-0700 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/aws\"] (close)"

Terraform Configuration Files

resource "aws_cur_report_definition" "daily_athena" {
  report_name                = "DailyCostReport"
  time_unit                  = "DAILY"
  format                     = "Parquet"
  compression                = "Parquet"
  additional_schema_elements = [ "RESOURCES" ]
  s3_bucket                  = aws_s3_bucket.cur.id
  s3_prefix                  = "daily"
  s3_region                  = "us-west-2"
  additional_artifacts       = ["ATHENA"]
  refresh_closed_reports     = true
  report_versioning          = "OVERWRITE_REPORT"
}

Steps to Reproduce

  • Based on the HCL definition below, create a new AWS Cost and Usage Report Definition manually via the console, named "DailyCostReport" and then wait 24 hours for it to be entirely made.
  • Create some placeholder HCL to import it into.
  • Run terraform import aws_cur_report_definition.daily_athena DailyCostReport

Debug Output

No response

Panic Output

No response

Important Factoids

  • To stop the terraform import, I need to forcefully kill the process and then remove the state lock, as it doesn't appear to ever timeout and does not respond to [Control-C].

References

No response

Would you like to implement a fix?

None

@spkane spkane added the bug Addresses a defect in current functionality. label Mar 18, 2024
Copy link

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/cur Issues and PRs that pertain to the cur service. label Mar 18, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Mar 18, 2024
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Mar 19, 2024
@justinretzolk
Copy link
Member

Hey @spkane 👋 Thank you for taking the time to raise this! Are you able to provide a sample Terraform configuration that can be used to reproduce this? If you're able to, providing a more complete set of trace logs (redacted as needed) may help whoever winds up picking this up.

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. needs-triage Waiting for first response or review from a maintainer. labels Mar 19, 2024
@acwwat
Copy link
Contributor

acwwat commented Mar 22, 2024

@spkane Which AWS region are you applying the Terraform configuration on? I noticed in the aws_cur_report_defintion resource documentation that the resource will only work with the us-east-1 region, presumably that it's a "global" resource. I also confirmed the same in AWS docs, including the AWS CLI cur command. It specifies cur.us-east-1.amazonaws.com only.

When I tried to create the report using your provided configuration in us-west-2 which is typical for my tests, it just hangs indefinitely. There is also no CloudTrail record of the request. But when I set AWS_DEFAULT_REGION to us-east-1 and apply the configuration, the resource is created within seconds. I also tried the remove the resource from the state using terraform state rm and import it via terraform import aws_cur_report_definition.daily_athena DailyCostReport, the state is retrieved successfully.

Given the reason above, could you please try to manage your aws_cur_report_definition resource using a provider that's tied to the us-east-1 region? Hope this addresses your problem.

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 22, 2024
@spkane
Copy link
Author

spkane commented Mar 22, 2024

I will give this a try next week.

However, the import still shouldn't be hanging the client. Ideally the logic would check the region and report a reasonable error back to the user if it is invalid for that resource type or at the very least timeout quickly.

@justinretzolk justinretzolk added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 22, 2024
@acwwat
Copy link
Contributor

acwwat commented Mar 22, 2024

Agreed with the comment about additional safeguards on the hung call, but we want to make sure that you are at least unblocked first. I meant to take a crack at it later today, but might also need help from someone more experienced :)

@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 22, 2024
@ewbankkit ewbankkit removed the needs-triage Waiting for first response or review from a maintainer. label Mar 25, 2024
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.43.0 milestone Mar 25, 2024
Copy link

This functionality has been released in v5.43.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 Apr 28, 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. service/cur Issues and PRs that pertain to the cur service.
Projects
None yet
4 participants