How to copy rds cluster snapshot with Terraform aws?

Viewed 107

I'm trying to create a copy of aws rds cluster snapshot using terraform aws provider and it seems that "aws_db_snapshot_copy" is not applicable for cluster snapshots, but there is no method "aws_db_cluster_snapshot_copy". Is there any way to create a copy of an aws rds cluster snapshot via terraform? My terraform code:

provider "aws" {
  region  = "eu-west-1"
  profile = "preprod"
}

provider "aws" {
  region  = "eu-central-1"
  profile = "prod"
  alias   = "prod"
}

data "aws_db_cluster_snapshot" "source_snapshot" {
  db_cluster_identifier = "my-rds"
  most_recent           = true
  provider              = aws.prod
}

output "most_recent_snapshot" {
  value = data.aws_db_cluster_snapshot.source_snapshot.db_cluster_snapshot_identifier
}

resource "aws_db_snapshot_copy" "copy_snapshot" {
  source_db_snapshot_identifier = data.aws_db_cluster_snapshot.source_snapshot.db_cluster_snapshot_identifier
  destination_region            = "eu-west-1"
  target_db_snapshot_identifier = "my-rds-snapshot"
  provider                      = aws.prod
}

Terraform output:

    Changes to Outputs:
  + most_recent_snapshot = "rds:my-rds-2022-08-11-01-24"

│ Error: error creating RDS DB Snapshot Copy DBSnapshotNotFound: DBSnapshot not found: rds:my-rds-2022-08-11-01-24
0 Answers
Related