AWS Database Blog
Configuring SSL encryption on Oracle and PostgreSQL endpoints in AWS DMS
AWS Database Migration Service (DMS) helps you migrate databases to AWS securely. It supports homogeneous and heterogeneous migrations between different database platforms, such as Oracle to Amazon Aurora. AWS DMS supports continuous data replication while maintaining high availability and has been widely adopted for database migrations because it is easy to configure. For more information, see What Is AWS Database Migration Service?
This post demonstrates how to encrypt source (Oracle) and target (Aurora) endpoints to use SSL, and implement data in transit encryption. To simulate the customer environments, the post covers steps to configure SSL on Oracle on an Amazon EC2 instance, Oracle on Amazon Relational Database Service (RDS) as the source database, and Amazon Aurora with PostgreSQL as the target.
Solution overview
The solution contains the following steps:
- Configure SSL on the source Oracle instance. This includes the following steps:
a. Configure SSL on the Oracle RDS instance.
b. Configure SSL on the Oracle EC2 instance. - Configure the source Oracle database endpoint with SSL on the AWS DMS console.
- Configure the target PostgreSQL Aurora database endpoint with SSL in AWS DMS.
- Configure data replication.
- Validate the data.
This post uses an Oracle database running on an EC2 instance and an Oracle RDS instance. Additionally, the target PostgreSQL instance is already created and has schemas and its objects’ structure created. You can use AWS SCT to convert your existing source database schema from one database engine to another. For more information, see What Is the AWS Schema Conversion Tool?
Other useful documentation pages are Creating an Amazon Aurora DB Cluster and Security in AWS Database Migration Service.
Configuring SSL on the Amazon RDS for Oracle instance
Amazon RDS for Oracle supports SSL. SSL configuration is done using an option group, which you can share with multiple databases. You can configure an Amazon RDS for Oracle instance to use the SSL option and create a client wallet that contains its signing certificate. Local clients use the wallet to connect to the TCPS listener. The wallet is also uploaded to AWS DMS to allow it to connect to the instance.
If you are using a source Oracle instance running on premises or on Amazon EC2, skip this step.
Creating an option group to support SSL
To create an option group to support SSL, complete the following steps:
- On the Amazon RDS console, under Option groups, choose Create group.
- For Name, enter the name of your option group.
For this post, we enterOracleRDSSSLOptionGrp
. - For Description, enter a description of your group.
- For Engine, choose oracle-ee.
- For Major engine version, choose 1.
- Choose Create.
The following screenshot demonstrates steps 1–6.
- On the Option groups page, choose the newly created option group (
OracleRDSSSLOptionGrp
). - Choose Add option as shown in the following screenshot preview.
- Under Option details, for Option, choose SSL.
- For Port, choose 2484.
- For Security Groups, choose default.
- Leave Option settings at default.
Option settings displays the current SSL parameter value. - Choose Add option.
The following screenshot demonstrates steps 9–13.
Modifying the Oracle RDS instance to use the SSL option group
To modify the Oracle RDS instance, complete the following steps:
- On the Amazon RDS console, choose Database.
- Choose your desired database.
- Choose Modify.
- Under Database options, for Option group, choose your new option group.
The following screenshot demonstrates steps 1–4.
- Scroll down to the bottom of the page and Choose Continue as shown in the screenshot preview below.
To review the changes, complete the following steps:
- For Scheduling of modifications, select Apply immediately.
- Choose Modify DB Instance as shown in the screenshot below.
Creating a wallet
You can create a wallet that contains the Certificate Authority (CA) certificate used to sign RDS SSL certificates by using an Oracle client on any Linux machine. You upload this wallet to AWS DMS. Complete the following steps:
- Set the ORACLE_HOME system variables and create the wallet folder by entering the following code:
- Download rds-ca-2019-root.pem RDS CA certificate.
- To create the Oracle wallet, enter the following commands:
Configuring SSL on the Oracle EC2 instance
Configure the self-signed certificate for the Oracle EC2 instance and create a client wallet that contains its signing certificate. Local clients use the wallet to connect to the TCPS listener, and the wallet is uploaded to AWS DMS to allow it to connect to the instance.
If you are using an Amazon RDS for Oracle instance, skip this step.
Creating a wallet using a self-signed certificate for Oracle SSL on an EC2 Oracle instance
To create this wallet, complete the following steps:
- Log in to your Linux or UNIX machine as an Oracle user with your environment set for the correct database and
ORACLE_HOME
. - Create a directory and root key for the self-signed certificate with the following code:
- Create an Oracle wallet directory and wallet with the following code:
- Add the root certificate in the wallet with the following code:
- Verify that the certificate is added successfully. See the following code:
- Generate the Certificate Signing Request (CSR) with the following code:
- Put “dms” as the common name with the following code:
- Get the encryption signature with the following code:
The signature key for this post is
sha256WithRSAEncryption
.
- Run the following command to generate the certificate (.crt) file:
- Add the certificate to the Oracle wallet with the following code:
- View the wallet; it should have two entries. See the following code:
- Modify the sqlnet.ora file. See the following code:
- Modify the listener.ora file (add wallet location and SSL port with TCPS as protocol). See the following code:
- Modify the tnsnames.ora file to test the local connection using SSL. See the following code:
- Test local connectivity using SQLPLUS and confirm that it is using SSL connections
sqlplus system@orclssl
. See the following code:
- Create the client wallet for AWS DMS with the following code:
- Download the cwallet.sso certificate to your local desktop to import it into the AWS DMS tool.
Configuring the source Oracle database endpoint using the AWS DMS console
In the first steps, you generated a certificate for either for Amazon RDS for Oracle or Oracle running on an EC2 instance. This post uses the Amazon RDS as the source for the Oracle SSL certificate.
To configure the database endpoint, first create a replication instance via the AWS DMS console.
Importing the certificate
To import the certificate, complete the following steps:
- On the AWS DMS console, choose Certificates.
- Choose Import Certificate as shown in the screenshot below.
- For Certificate Identifier, enter
RDSSSLCERT
. - For Import file, choose Browse.
- Locate
cwallet.sso
. - Choose Add new CA certificate as shown below.
When the certificate is imported successfully, you see the certificate listed with the ARN. See the following screenshot.
Configuring the source endpoint
To configure the source endpoint with SSL mode enabled as verify-ca
, complete the following steps:
- On the AWS DMS console, choose Endpoints.
- Choose Create endpoint as shown below.
- For Endpoint type, choose Source.
- Select the Select RDS DB Instance check box.
- For RDS Instance, choose the orcl – oracle-ee.
- For Endpoint Identifier, enter a name.
This post enters the nameorcl-source
. - For Source engine, choose oracle.
- For Server name, enter the Oracle RDS instance endpoint.
- For Port, enter the SSL port
2484
. - For SSL mode, choose verify-ca.
- For CA certificate, choose the imported certificate RDSSSLCERT.
- For User name, enter the Oracle RDS user.
- For Password, enter the user password.
- Choose Run test.
The following screenshot demonstrates steps 3–14.
- After test run is successful, choose Create endpoint.
Confirm that the AWS DMS connections are using SSL
To confirm that the AWS DMS connections are using SSL, complete the following steps:
- On the Amazon RDS console, choose Database.
- Choose your database identifier.
- Under Configuration, under CloudWatch Logs, choose Listener, as shown in the screenshot below.
- Verify the Oracle listener.log to confirm that connections coming from AWS DMS is using TCPS protocol, which indicates that established connection is on SSL.
If you used an SSL certificate of Oracle on EC2 instance as the source, verify the Oracle server listener.log to confirm that the connection coming from AWS DMS is TCPS. The following screenshot shows the listener.log output.
Configuring the target PostgreSQL Aurora database endpoint
To configure the target endpoint, complete the following steps:
- On the AWS DMS console, choose Endpoints.
- Choose Create endpoint as shown in the screenshot below.
- For Endpoint type, select Target.
- Select the Select RDS DB Instance check box.
- For RDS Instance, choose the Aurora PostgreSQL instance identifier auroradb – aurora-postgresql.
- For Endpoint identifier, enter
auroradb-target
. - For Target engine, choose aurora-PostgreSQL.
- For Server name, enter the Aurora PostgreSQL endpoint.
- For Port, enter the SSL port
5432
. - For SSL mode, choose require.
- For User name, enter the Aurora PostgreSQL user.
- For Password, enter the user password.
The following screenshot demonstrates steps 3–12.
- Choose Create endpoint.
On the Endpoints page, choose the target endpoint. - Choose Test connection as shown below.
- Choose Run test as shown below.
Configuring data replication
To configure data replication, complete the following steps:
- Log in to the source Oracle database and gather the table row count before enabling replication. See the following command:
The following screenshot provides a preview of the output.
- Log in to the target Aurora PostgreSQL database and ensure that the table is empty. See the following command:
The following screenshot provides a preview of the output.
- On the AWS DMS console, choose Database migration tasks.
- Choose Create task.
- Under Modify Task, for Task name, enter
repltest
. - Keep all other values at their default.
The following screenshot demonstrates steps 5 and 6.
Your next step is to create the selection rules and transformation rules. - In the JSON editor, enter the following example code (replace
REPLSSLTEST
with your schema name): - Choose Save. The following screenshot demonstrates steps 7 and 8.
- Under Table mappings, choose the Guided
- Review the information and choose Create task as shown in the screenshot below.
- Ensure that the task has started and is running successfully.
The following screenshots show the repltest task status changing from Starting to Running.
Checking the source and target database connections
Check on the source and target database to ensure that the connections are using SSL. Complete the following steps:
- Use SQL*PLUS or the SQL developer tool to connect to the Amazon RDS for Oracle source database, and enter the following SQL query:
The query should list all the connections coming from the AWS DMS replication instance. The following screenshot shows the output.
- Use the psql tool to connect to the Aurora target instance, and enter the following SQL query:
The query should list all the connections coming from DMS replication instance. The following screenshot shows the output.
- On the Amazon RDS console, choose Database.
- Choose your database identifier.
- Under Configuration, under CloudWatch Logs, choose
The listener.log lists the TCPS protocol connections. See the following screenshot.
Validating the data
To validate that the data is replicated from source to target, complete the following steps:
- On the AWS DMS console, choose Database migration tasks.
- Review the AWS DMS task status and ensure that it is completed successfully.
The following screenshot shows the task status.
- Log in to the target Aurora PostgreSQL database.
- Confirm that all rows were loaded into the target database.
The following screenshot shows the output.
Conclusion
This post showed how to configure SSL encryption for AWS DMS. Configuring SSL encryption secures data in transit when your database’s data is transferred from on premises to Amazon RDS. It also ensures better compliance and alignment with your organization’s security policies and guidelines.
Try this approach in your environment, and please feel free to reach out with questions or thoughts in the comments.
About the Author
Bhavesh Rathod is an Oracle Database Cloud Architect with the Professional Services team at Amazon Web Services. He works as database migration specialist to help Amazon customers to move their on-premises database environment to AWS cloud database solutions.
Jeevith Anumalla is an Oracle Database Cloud Architect with the Professional Services team at Amazon Web Services. He works as database migration specialist to help internal and external Amazon customers to move their on-premises database environment to AWS data stores.