AWS Contact Center
Creating a secure IVR solution with Amazon Connect
Creating a secure IVR solution with Amazon Connect
The contact flows in Amazon Connect can be used to create dynamic Interactive Voice Response (IVR) solutions. With Amazon Connect, organizations can gather appropriate personal information to customize the customer experience when they interact with their IVR. The personal information can include social security numbers, credit card information, and addresses. Because of compliance reasons, sensitive personal information must be encrypted in motion and when stored. Always encrypt personal information.
This blog post shows you how customers can use the Store customer input block in Amazon Connect to gather sensitive personal information, and automatically encrypt the data by using the customer’s own supplied encryption keys. This feature allows the customer to comply with encryption requirements.
To achieve this, Amazon Connect uses the AWS Encryption Software Development KIT (SDK) to encrypt customer provided data. The SDK uses an envelope encryption approach. This protects both the raw data and the data keys used to encrypt them. For more information about how the AWS Encryption SDK works, see Envelope Encryption.
This post shows the steps required to:
- Configure Amazon Connect to collect a credit card number. See Create an Amazon Connect instance if you need to create an instance.
- Encrypt the credit card digits.
- Send it to our backend AWS Lambda for decryption, using the customer supplied decryption key.
We will use the Amazon Connect contact flow shown in the following illustration:
Implementing the secure IVR
To implement our secure IVR, we must:
- Create new encryption and decryption keys, or import existing ones.
- Upload our public key to Amazon Connect to encrypt collected credit card digits.
- Securely store the decryption key and master key id into AWS parameter store
- Create an AWS Lambda function to decrypt the collected digits
- Create the contact flow described in the previous section.
To implement the secure IVR, make sure that AWS Command Line Interface (AWS CLI) is installed, configured and pointed to the same region as your Amazon Connect instance. To verify that you can run “aws configure” from your Terminal window and verify that your default region name parameter has the correct value.
The Amazon Connect customer input encryption feature is designed to use the organization’s supplied public key to encrypt data. This allows the organization to use its private key to decrypt the data for further processing. Using a private key known only to the organization helps preserve the privacy that an organization requires. An organization can use either an existing key pair or create a new one. When the key information is available, the process remains the same.
If you are using your existing keys for this exercise, skip to step 2 of this section.
Step 1: Create the encryption and decryption keys
We will be leveraging OpenSSL for this step. If you are using a macOS computer, OpenSSL should already be installed. For information about installing OpenSSL, see this OpenSSL site.
Let’s use Terminal and the OpenSSL command line encryption utility to generate a self-signed certificate and private key. We create the private key and certificate in a single step. As a result, two files are generated:
- A private key file: blog.connect.private.key
- A certificate file: blog.connect.certificate.pem
When you run the following command, you are providing the usual necessary certificate request information; such as, country/region name, organization name, etc.
Notice that we created a certificate valid for 2 years (730 days). It is important to remember that the certificate’s expiration date monitoring remains the responsibility of the organization.
Next, we extract the public key from the certificate file using the OpenSSL utility. The next command generates a file named blog.connect.public.key, which contains the encryption key that we need to upload to Amazon Connect.
We now have three files to use for the next steps.
Step 2: Upload our public key to Amazon Connect.
In this step, we upload our encryption key, so Amazon Connect knows to use it when we want to encrypt customer input.
- Login to the AWS Management Console and choose Amazon Connect.
- Open your instance, and in the left pane, choose Contact Flows.
- Choose Add Key, and paste the content of your public key file blog.connect.public.key. You can use any text editor to open the file and copy its content.
- Choose Add Key to save the public key, as shown in the following example. You now have a key ID generated for your public key. Copy it and save it for later.
Step 3: Securely store the decryption private key and the key id into the AWS Parameter Store
This step helps to make sure that our decryption is stored securely. Moreover, the decryption is stored with traceability and access rights management using the power of IAM. By using this approach, we can manage the access to our private key by selectively granting access to processes and users. Also, it lets the system log every access of the private key for audit purposes.
To run the following commands, you must be an AWS user with access to AWS Systems Manager and the permissions to create parameters. Work with your AWS SysOps team to verify proper access.
The first command securely uploads our private key to AWS Systems Manager Parameter Store. This saves the key to a parameter named CONNECT_INPUT_DECRYPTION_KEY.
The second command uploads our key id to AWS Systems Manager Parameter Store. This saves the key to a parameter named CONNECT_INPUT_KEY_ID. Replace YOUR_KEY_ID with your actual value. This was saved in the previous step.
$ aws ssm put-parameter --type SecureString --name CONNECT_INPUT_KEY_ID --description "Key Id for decryption of Amazon Connect collected data" --value YOUR_KEY_ID
To run the previous command, you must be an AWS user with access to AWS Systems Manager and the permissions to create parameters. Work with your AWS SysOps team to verify proper access.
The command uses the default key alias/aws/ssm to encrypt your private key. If you prefer to use a different AWS KMS key for this, you could do so by adding the –key-id option to this command.
After you complete this step, you can then go to the Parameter Store in the AWS Systems Manager console. There, you should see the newly created parameters as shown in the following screenshot. If you do not see them, it is most like a permissions issue which can be fixed by reviewing the output on your terminal window.
Step 4: Use AWS CloudFormation to create the Lambda function for decryption
In this step, we use AWS CloudFormation to automatically create the IAM role and the AWS Lambda function. The function is used to perform the decryption of the credit card number.
Very Important Note: For the needs of this blog, this “Launch Stack” button below will only work in the us-west-2 AWS region. If you are running this in a different region, please download the template and modify it to work in a different region.
To create the Lambda function for decryption using the “Launch Stack” button, follow these steps:
- Login to your AWS console.
- Confirm that the AWS Region selected has the Amazon Connect service available.
- Click on the button below “Launch Stack”
- On the AWS CloudFormation page, modify the stack name if you prefer a different one.
- In the Parameters section, select the LambdaLanguage to use. The template supports Node.js and Python.
- Check the “I acknowledge that AWS CloudFormation might create IAM resources” since this template will create an IAM role.
- You can keep the other options as default.
- Create stack and wait for it to complete.
Now let’s make sure that our Amazon Connect instance has access to this newly created AWS Lambda Function
- In the Amazon Connect console, choose Contact Flows and scroll to the bottom of the page in the AWS Lambda section.
- On the Function drop-down menu, select the DecryptCustomerInputV2 function and click on “+Add Lambda Function”, as shown in the following screenshot:
Step 5: Create a contact flow to collect digits and encrypt them.
In this step, download the contact flow we will use from this location. Save it to a file. In the following steps, you will import your saved file and modify it so that Amazon Connect knows which key we use to encrypt the credit card number.
- Open the Amazon Connect console.
- Click on Overview, then choose Login as administrator.
- On the Routing menu on the left side, choose Contact Flows to show the list of contact flows.
- Click on Create Contact flow.
- From the drop-down menu next to the Save button on the right side, as shown in the following screenshot, choose Import flow. This loads the flow that was downloaded at the beginning of this step.
- After the import completes, choose the Store customer input block and enter the key ID that you created in step 2, and the content of your blog.connect.certificate.pem file, as shown in the following example:
- Next, let’s point our contact flow’s Invoke AWS Lambda function block to our DecryptCustomerInputV2 function.
- Save and publish the contact flow, as we are done with all changes.
- Attach the contact flow to your test phone number, as shown in the following example. For more information about setting up a phone number, see Claiming Phone Numbers.
- Dial the test phone number to go through the flow. After the call is completed, check the Amazon CloudWatch Logs to confirm the digits that we entered are encrypted and passed to our AWS Lambda function for decryption.
To confirm that the decryption works as expected, we also log the deciphered text. However, avoid doing this in a production environment to ensure that sensitive data is not leaked through the log files.
The following extracts show the information that is stored in both the Contact Flow logs and the AWS Lambda function logs.
Contact flow logs
AWS Lambda invocation
AWS Lambda Logs
In this case, the entered digits were 4444444444444444.
In this post we covered how you can use Amazon Connect’s Encryption feature to collect digits from a caller and encrypt them using your own supplied key pair. We have also covered how you can use AWS Systems Managers to securely store your decryption key and key id.
With this, you can now build a secured IVR using Amazon Connect.
Please let us know what you built with this.