Skip to content

Latest commit

 

History

History
 
 

s3_import

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

MySQL S3 Import Example

Configuration in this directory creates set of RDS resources including DB instance, DB subnet group and DB parameter group where the database itself is imported from a MySQL Percona Xtrabackup stored in S3.

Usage

To run this example you need to execute:

$ terraform init
$ terraform plan
$ terraform apply

Testing

In order to test this example, you will need a database backup in order to upload to S3 and import into the module. A backup has been provided under backup/, but in the case that a new backup needs to be created, the steps outlined below should suffice for creating a backup that can be used for the sake of testing and verifying module functionality/changes.

  1. Create database container
$ docker run -d --name percona-server-mysql-5.7.12 -e MYSQL_ROOT_PASSWORD=root percona/percona-server:5.7.12
$ docker exec -it percona-server-mysql-5.7.12 bash
$ mysql -u root -p # password is also root
  1. Once logged into container and database, create database and user used by RDS
CREATE DATABASE s3Import;
CREATE USER 's3_import_user'@'localhost' IDENTIFIED BY 'YourPwdShouldBeLongAndSecure!';
GRANT ALL PRIVILEGES ON * . * TO 's3_import_user'@'localhost';
FLUSH PRIVILEGES;
  1. Use Percona Xtrabackup container to dump database and upload to S3
$ mkdir -p /tmp/backup
$ docker run --name percona-xtrabackup-2.4 --mount type=bind,src=/tmp/backup,dst=/backup --volumes-from percona-server-mysql-5.7.12 percona/percona-xtrabackup:2.4 xtrabackup --backup --data-dir=/var/lib/mysql --target-dir=/backup --user=root --password=root
$ mv /tmp/backup ./backup

Note that this example may create resources which cost money. Run terraform destroy when you don't need these resources.

Requirements

Name Version
terraform >= 0.13
aws >= 3.8
random >= 2.2

Providers

Name Version
aws >= 3.8
random >= 2.2

Modules

Name Source Version
aurora ../../
import_s3_bucket terraform-aws-modules/s3-bucket/aws ~> 2.0
vpc terraform-aws-modules/vpc/aws ~> 3.0

Resources

Name Type
aws_db_parameter_group.example resource
aws_iam_role.s3_import resource
aws_iam_role_policy.s3_import resource
aws_rds_cluster_parameter_group.example resource
random_password.master resource
random_pet.this resource
aws_iam_policy_document.s3_import data source
aws_iam_policy_document.s3_import_assume data source

Inputs

No inputs.

Outputs

Name Description
rds_cluster_database_name Name for an automatically created database on cluster creation
rds_cluster_endpoint The cluster endpoint
rds_cluster_id The ID of the cluster
rds_cluster_instance_endpoints A list of all cluster instance endpoints
rds_cluster_instance_ids A list of all cluster instance ids
rds_cluster_master_password The master password
rds_cluster_master_username The master username
rds_cluster_port The port
rds_cluster_reader_endpoint The cluster reader endpoint
rds_cluster_resource_id The Resource ID of the cluster
security_group_id The security group ID of the cluster