Skip to content

Resource: awsRdsExportTask

Terraform resource for managing an AWS RDS (Relational Database) Export Task.

Example Usage

Basic 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.rdsExportTask.RdsExportTask(this, "example", {
  exportTaskIdentifier: "example",
  iamRoleArn: "${aws_iam_role.example.arn}",
  kmsKeyId: "${aws_kms_key.example.arn}",
  s3BucketName: "${aws_s3_bucket.example.id}",
  sourceArn: "${aws_db_snapshot.example.db_snapshot_arn}",
});

Complete 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";
const awsDbInstanceExample = new aws.dbInstance.DbInstance(this, "example", {
  allocatedStorage: 10,
  dbName: "test",
  engine: "mysql",
  engineVersion: "5.7",
  identifier: "example",
  instanceClass: "db.t3.micro",
  parameterGroupName: "default.mysql5.7",
  password: "foobarbaz",
  skipFinalSnapshot: true,
  username: "foo",
});
const awsDbSnapshotExample = new aws.dbSnapshot.DbSnapshot(this, "example_1", {
  dbInstanceIdentifier: awsDbInstanceExample.id,
  dbSnapshotIdentifier: "example",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsDbSnapshotExample.overrideLogicalId("example");
const awsIamRoleExample = new aws.iamRole.IamRole(this, "example_2", {
  assumeRolePolicy:
    '${jsonencode({\n    Version = "2012-10-17"\n    Statement = [\n      {\n        Action = "sts:AssumeRole"\n        Effect = "Allow"\n        Sid    = ""\n        Principal = {\n          Service = "export.rds.amazonaws.com"\n        }\n      },\n    ]\n  })}',
  name: "example",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsIamRoleExample.overrideLogicalId("example");
const awsKmsKeyExample = new aws.kmsKey.KmsKey(this, "example_3", {
  deletionWindowInDays: 10,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsKmsKeyExample.overrideLogicalId("example");
const awsS3BucketExample = new aws.s3Bucket.S3Bucket(this, "example_4", {
  bucket: "example",
  forceDestroy: true,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsS3BucketExample.overrideLogicalId("example");
const awsS3BucketAclExample = new aws.s3BucketAcl.S3BucketAcl(
  this,
  "example_5",
  {
    acl: "private",
    bucket: awsS3BucketExample.id,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsS3BucketAclExample.overrideLogicalId("example");
const dataAwsIamPolicyDocumentExample =
  new aws.dataAwsIamPolicyDocument.DataAwsIamPolicyDocument(this, "example_6", {
    statement: [
      {
        actions: ["s3:ListAllMyBuckets"],
        resources: ["*"],
      },
      {
        actions: ["s3:GetBucketLocation", "s3:ListBucket"],
        resources: [awsS3BucketExample.arn],
      },
      {
        actions: ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
        resources: [`\${${awsS3BucketExample.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.*/
dataAwsIamPolicyDocumentExample.overrideLogicalId("example");
const awsIamPolicyExample = new aws.iamPolicy.IamPolicy(this, "example_7", {
  name: "example",
  policy: dataAwsIamPolicyDocumentExample.json,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsIamPolicyExample.overrideLogicalId("example");
const awsIamRolePolicyAttachmentExample =
  new aws.iamRolePolicyAttachment.IamRolePolicyAttachment(this, "example_8", {
    policyArn: awsIamPolicyExample.arn,
    role: awsIamRoleExample.name,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsIamRolePolicyAttachmentExample.overrideLogicalId("example");
const awsRdsExportTaskExample = new aws.rdsExportTask.RdsExportTask(
  this,
  "example_9",
  {
    exportOnly: ["database"],
    exportTaskIdentifier: "example",
    iamRoleArn: awsIamRoleExample.arn,
    kmsKeyId: awsKmsKeyExample.arn,
    s3BucketName: awsS3BucketExample.id,
    s3Prefix: "my_prefix/example",
    sourceArn: awsDbSnapshotExample.dbSnapshotArn,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsRdsExportTaskExample.overrideLogicalId("example");

Argument Reference

The following arguments are required:

  • exportTaskIdentifier - (Required) Unique identifier for the snapshot export task.
  • iamRoleArn - (Required) ARN of the IAM role to use for writing to the Amazon S3 bucket.
  • kmsKeyId - (Required) ID of the Amazon Web Services KMS key to use to encrypt the snapshot.
  • s3BucketName - (Required) Name of the Amazon S3 bucket to export the snapshot to.
  • sourceArn - (Required) Amazon Resource Name (ARN) of the snapshot to export.

The following arguments are optional:

  • exportOnly - (Optional) Data to be exported from the snapshot. If this parameter is not provided, all the snapshot data is exported. Valid values are documented in the AWS StartExportTask API documentation.
  • s3Prefix - (Optional) Amazon S3 bucket prefix to use as the file name and path of the exported snapshot.

Attributes Reference

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

  • failureCause - Reason the export failed, if it failed.
  • id - Unique identifier for the snapshot export task (same value as exportTaskIdentifier).
  • percentProgress - Progress of the snapshot export task as a percentage.
  • snapshotTime - Time that the snapshot was created.
  • sourceType - Type of source for the export.
  • status - Status of the export task.
  • taskEndTime - Time that the snapshot export task completed.
  • taskStartTime - Time that the snapshot export task started.
  • warningMessage - Warning about the snapshot export task, if any.

Import

A RDS (Relational Database) Export Task can be imported using the exportTaskIdentifier, e.g.,

$ terraform import aws_rds_export_task.example example