Skip to content

Resource: awsDbInstanceAutomatedBackupsReplication

Manage cross-region replication of automated backups to a different AWS Region. Documentation for cross-region automated backup replication can be found at:

-> Note: This resource has to be created in the destination region.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dbInstanceAutomatedBackupsReplication.DbInstanceAutomatedBackupsReplication(
  this,
  "default",
  {
    retentionPeriod: 14,
    sourceDbInstanceArn: "arn:aws:rds:us-west-2:123456789012:db:mydatabase",
  }
);

Encrypting the automated backup with KMS

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.dbInstanceAutomatedBackupsReplication.DbInstanceAutomatedBackupsReplication(
  this,
  "default",
  {
    kmsKeyId:
      "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012",
    sourceDbInstanceArn: "arn:aws:rds:us-west-2:123456789012:db:mydatabase",
  }
);

Example including a RDS DB instance

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.provider.AwsProvider(this, "aws", {
  region: "us-east-1",
});
new aws.provider.AwsProvider(this, "aws_1", {
  alias: "replica",
  region: "us-west-2",
});
const awsDbInstanceDefault = new aws.dbInstance.DbInstance(this, "default", {
  allocatedStorage: 10,
  backupRetentionPeriod: 7,
  engine: "postgres",
  engineVersion: "13.4",
  identifier: "mydb",
  instanceClass: "db.t3.micro",
  name: "mydb",
  password: "mustbeeightcharacters",
  skipFinalSnapshot: true,
  storageEncrypted: true,
  username: "masterusername",
});
const awsKmsKeyDefault = new aws.kmsKey.KmsKey(this, "default_3", {
  description: "Encryption key for automated backups",
  provider: "aws.replica",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsKmsKeyDefault.overrideLogicalId("default");
const awsDbInstanceAutomatedBackupsReplicationDefault =
  new aws.dbInstanceAutomatedBackupsReplication.DbInstanceAutomatedBackupsReplication(
    this,
    "default_4",
    {
      kmsKeyId: awsKmsKeyDefault.arn,
      provider: "aws.replica",
      sourceDbInstanceArn: awsDbInstanceDefault.arn,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsDbInstanceAutomatedBackupsReplicationDefault.overrideLogicalId("default");

Argument Reference

The following arguments are supported:

  • kmsKeyId - (Optional, Forces new resource) The AWS KMS key identifier for encryption of the replicated automated backups. The KMS key ID is the Amazon Resource Name (ARN) for the KMS encryption key in the destination AWS Region, for example, arn:aws:kms:usEast1:123456789012:key/akiaiosfodnn7Example.
  • preSignedUrl - (Optional, Forces new resource) A URL that contains a Signature Version 4 signed request for the startDbInstanceAutomatedBackupsReplication action to be called in the AWS Region of the source DB instance.
  • retentionPeriod - (Optional, Forces new resource) The retention period for the replicated automated backups, defaults to 7.
  • sourceDbInstanceArn - (Required, Forces new resource) The Amazon Resource Name (ARN) of the source DB instance for the replicated automated backups, for example, arn:aws:rds:usWest2:123456789012:db:mydatabase.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - The Amazon Resource Name (ARN) of the replicated automated backups.

Timeouts

Configuration options:

  • create - (Default 75M)
  • delete - (Default 75M)

Import

RDS instance automated backups replication can be imported using the arn, e.g.,

$ terraform import aws_db_instance_automated_backups_replication.default arn:aws:rds:us-east-1:123456789012:auto-backup:ab-faaa2mgdj1vmp4xflr7yhsrmtbtob7ltrzzz2my