Text-To-Speech Converter App— Challenge1 — Terraform code

Mariem SOUSSI
3 min readMar 20, 2024

--

This work is inspired by the Text-To-Speech converter solution presented in “Text-to-speech converter using AWS Lambda, Polly, and API Gateway” by Lucas Ludicsa. It’s a simple serverless application designed to transform text into speech using AWS services. I will use this app as a foundation for various articles that I will share with you, each presenting a unique challenge to improve it.

Lucas Ludicsa provides a highly detailed explanation of the different steps to create the solution using the AWS console. The first challenge involves writing Terraform code to automate the deployment and streamline the enhancement of the solution.

In the following sections, I will provide more details about the Text-To-Speech Converter (TTS Converter) app, describe the different AWS services involved in the app, and present the solution for the first challenge.

The TTS Converter App: A brief overview of its services

TTS Converter app

1.AWS API Gateway is an AWS service that serves as a front door for your backend services, which can include workloads in EC2, Lambda functions, or any web app. There are several types of AWS API Gateways available: WebSocket API, REST API Private, HTTP API, and REST API.

WebSocket API is ideal for real-time two-way communication apps. REST API Private is accessible only from within a VPC. For TTS Converter app, the choice is between HTTP API and REST API, both compatible with Lambda functions.

HTTP APIs are cheaper and faster than REST API Gateways, while REST APIs offer more features. For the TTS Converter app, an HTTP API Gateway is the preferred choice, as the additional features of the REST API are unnecessary. In the TTS Converter app, the HTTP API is used to efficiently handles incoming requests and triggers the Lambda function responsible for text-to-audio transformation.

2.AWS Lambda is an AWS serverless compute service that provides you with an execution environment to run your code without managing servers.

In the TTS Converter app, the Lambda function is written in Python. It is triggered by the API Gateway and authorized to invoke Polly for text transformation. Additionally, it sends logs to CloudWatch for monitoring and debugging purposes.

3.Amazon Polly is an AWS text-to-speech service that utilizes advanced deep learning technologies to convert text into lifelike speech. With Amazon Polly, you have access to a wide variety of languages and a diverse selection of natural-sounding male and female voices. Its fluid pronunciation of text enables you to deliver high-quality voice output tailored for a global audience.

4.Amazon CloudWatch is an AWS monitoring service that collects logs and metrics from both your applications and AWS services. It also allows you to set up alarms based on specific conditions.

In the TTS Converter, CloudWatch receives logs from both the Lambda function and the API Gateway, with each component’s logs stored in separate CloudWatch log groups.

5.IAM is a fundamental service in AWS. All actions performed by AWS users, AWS services, or other entities within your AWS environment are governed by assigned IAM policies.

Challenge

While the AWS console is a great way to implement simple AWS solutions, test services, and experiment with features, when you require a professional solution, utilizing an Infrastructure as Code (IAC) tool like terraform becomes essential. Having your infrastructure defined as code facilitates updates, improvements, and deletions.

The challenge is to the write Terraform code according to the described solution. Take your time to complete it on your own 😉.

Don’t hesitate to dive in and explore the possibilities.

Good Luck 💪!

Solution

You’ll find the solution in my GitHub repository. Take your time to explore and understand the code. Don’t hesitate to experiment with it and make improvements. Feel free to reach out if you have any questions or need further assistance. Keep up the great work!

Stay tuned for the next challenge as we continue to optimize and explore further improvements 😉

For More details

Difference between REST Api and http API

AWS AI Service Demos (Polly, Transcribe, ..)

--

--