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.63k stars 9.01k forks source link

[Bug]: aws_rds_cluster times out when creating servelessV2 cluster from snapshot #37154

Closed jjpzt87 closed 2 months ago

jjpzt87 commented 2 months ago

Terraform Core Version

1.5.6

AWS Provider Version

4.45.0

Affected Resource(s)

aws_rds_cluster

Expected Behavior

i am setting timeouts values greater that 120m (default value), the creation should timeout when the new custom value is reached.

Actual Behavior

i am setting timeouts as:

timeouts {
    create = try(var.cluster_timeouts.create, "360m")
    update = try(var.cluster_timeouts.update, "360m")
    delete = try(var.cluster_timeouts.delete, "120m")
}

The creation is timing out after 2h (120m default value)

Relevant Error/Panic Output Snippet

module.db-databases-data-analytics-nprd-serverless.aws_rds_cluster.this: Still creating... [1h58m10s elapsed]

------------ System Message ------------

WARNING: This apply has timed out and will now terminate!

A 2h0m0s maximum run time for this operation is enforced. Please review the
logs above to determine why the apply has exceeded its timeout.

----------------------------------------

Interrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...

Stopping operation...
╷
│ Warning: Argument is deprecated
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on provider.tf line 14, in provider "aws":
│   14:   shared_credentials_file = "./credentials"
│ 
│ Use shared_credentials_files instead.
╵
╷
│ Warning: Attribute Deprecated
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on provider.tf line 14, in provider "aws":
│   14:   shared_credentials_file = "./credentials"
│ 
│ Use shared_credentials_files instead.
╵
╷
│ Error: execution halted
│ 
│ 
╵
╷
│ Error: execution halted
│ 
│ 
╵
╷
│ Error: waiting for RDS Cluster (db-data-analytics-nprd-serverless) create: context canceled
│ 
│   with module.db-databases-data-analytics-nprd-serverless.aws_rds_cluster.this,
│   on .terraform/modules/db-databases-data-analytics-nprd-serverless/cluster.tf line 96, in resource "aws_rds_cluster" "this":
│   96: resource "aws_rds_cluster" "this" {
│ 
╵
Operation failed: failed running terraform apply (exit 1)

Terraform Configuration Files

# Cluster
resource "aws_rds_cluster" "this" {
  cluster_identifier              = var.cluster_name
  **snapshot_identifier             = local.cluster_snapshot_identifier**
  engine                          = var.engine
  engine_mode                     = var.engine_mode
  engine_version                  = var.engine_version
  database_name                   = var.database_name
  port                            = var.database_port
  master_username                 = var.snapshot_identifier == "" ? var.cluster_master_username : null
  master_password                 = var.snapshot_identifier == "" ? random_password.cluster_admin_password.result : null
  storage_type                    = var.storage_type
  iops                            = var.iops
  allocated_storage               = var.allocated_storage
  storage_encrypted               = var.storage_encrypted
  kms_key_id                      = var.storage_encrypted && var.custom_storage_key ? aws_kms_key.storage_kms_key[0].arn : var.storage_encrypted ? data.aws_kms_key.aws_managed_for_rds.arn : null
  vpc_security_group_ids          = [aws_security_group.database_internal.id, aws_security_group.database_icmp.id]
  db_subnet_group_name            = var.create_db_subnet_group ? aws_db_subnet_group.this[0].id : var.db_subnet_group_name
  db_cluster_parameter_group_name = var.create_db_cluster_parameter_group ? aws_rds_cluster_parameter_group.this[0].id : var.db_cluster_parameter_group_name
  availability_zones              = local.azs
  apply_immediately               = var.apply_immediately
  copy_tags_to_snapshot           = var.copy_tags_to_snapshot
  skip_final_snapshot             = var.skip_final_snapshot
  deletion_protection             = var.deletion_protection
  preferred_backup_window         = try(var.preferred_backup_window, null)
  backup_retention_period         = var.backup_retention_period
  preferred_maintenance_window    = try(var.preferred_maintenance_window, null)
  dynamic "serverlessv2_scaling_configuration" {
    for_each = length(var.serverlessv2_scaling_configuration) > 0 && var.engine_mode == "provisioned" ? [var.serverlessv2_scaling_configuration] : []
    content {
      max_capacity = serverlessv2_scaling_configuration.value.max_capacity
      min_capacity = serverlessv2_scaling_configuration.value.min_capacity
    }
  }
  timeouts {
    create = try(var.cluster_timeouts.create, "360m")
    update = try(var.cluster_timeouts.update, "360m")
    delete = try(var.cluster_timeouts.delete, "120m")
  }
  enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports
  tags = merge({ "Name" = var.cluster_name }, var.default_tags)
}

Steps to Reproduce

base RDS:

Migration:

resource "aws_rds_cluster" "this" {
  cluster_identifier              = var.cluster_name
  snapshot_identifier          = "dataanalytics-nprd-serveless-migration-psqlv13"

Debug Output

module.db-databases-data-analytics-nprd-serverless.aws_rds_cluster.this: Still creating... [1h58m10s elapsed]

------------ System Message ------------

WARNING: This apply has timed out and will now terminate!

A 2h0m0s maximum run time for this operation is enforced. Please review the
logs above to determine why the apply has exceeded its timeout.

----------------------------------------

Interrupt received.
Please wait for Terraform to exit or data loss may occur.
Gracefully shutting down...

Stopping operation...
╷
│ Warning: Argument is deprecated
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on provider.tf line 14, in provider "aws":
│   14:   shared_credentials_file = "./credentials"
│ 
│ Use shared_credentials_files instead.
╵
╷
│ Warning: Attribute Deprecated
│ 
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on provider.tf line 14, in provider "aws":
│   14:   shared_credentials_file = "./credentials"
│ 
│ Use shared_credentials_files instead.
╵
╷
│ Error: execution halted
│ 
│ 
╵
╷
│ Error: execution halted
│ 
│ 
╵
╷
│ Error: waiting for RDS Cluster (db-data-analytics-nprd-serverless) create: context canceled
│ 
│   with module.db-databases-data-analytics-nprd-serverless.aws_rds_cluster.this,
│   on .terraform/modules/db-databases-data-analytics-nprd-serverless/cluster.tf line 96, in resource "aws_rds_cluster" "this":
│   96: resource "aws_rds_cluster" "this" {
│ 
╵
Operation failed: failed running terraform apply (exit 1)

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 2 months ago

Hey @jjpzt87 👋 Thank you for taking the time to raise this! Are you using Terraform Enterprise by chance? This looks a lot like Terraform Enterprise's default runner timeout.

jjpzt87 commented 2 months ago

hey @justinretzolk! yes i am using TerraformCloud (TFC) for my backend, but the apply timeout is supposed to be 24h on TFC. I will try creating it locally and see if the timeout is from TFC or the resource. Thanks!

jjpzt87 commented 2 months ago

hey @justinretzolk! you were right, the timeout was coming from TFC. running it locally worked and then i just imported. Thanks a lot

github-actions[bot] commented 2 months ago

[!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[bot] commented 1 month ago

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.