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.63
random >= 2.2

Providers

Name Version
aws >= 3.63
random >= 2.2

Modules

Name Source Version
aurora ../../ n/a
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_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
additional_cluster_endpoints A map of additional cluster endpoints and their attributes
cluster_arn Amazon Resource Name (ARN) of cluster
cluster_database_name Name for an automatically created database on cluster creation
cluster_endpoint Writer endpoint for the cluster
cluster_engine_version_actual The running version of the cluster database
cluster_hosted_zone_id The Route53 Hosted Zone ID of the endpoint
cluster_id The RDS Cluster Identifier
cluster_instances A map of cluster instances and their attributes
cluster_master_password The database master password
cluster_master_username The database master username
cluster_members List of RDS Instances that are a part of this cluster
cluster_port The database port
cluster_reader_endpoint A read-only endpoint for the cluster, automatically load-balanced across replicas
cluster_resource_id The RDS Cluster Resource ID
cluster_role_associations A map of IAM roles associated with the cluster and their attributes
db_subnet_group_name The db subnet group name
enhanced_monitoring_iam_role_arn The Amazon Resource Name (ARN) specifying the enhanced monitoring role
enhanced_monitoring_iam_role_name The name of the enhanced monitoring role
enhanced_monitoring_iam_role_unique_id Stable and unique string identifying the enhanced monitoring role
security_group_id The security group ID of the cluster