Skip to main content

Create Your Own Wake-up Call Service with AWS Pinpoint, Lambda and CDK

Create Your Own Wake-Up Call Service With AWS Pinpoint, Lambda and CDK

Create Your Own Wake-Up Call Service With AWS Pinpoint, Lambda and CDK

Wake-up call service is exactly what you would imagine, someone will call you to wake you up and make sure that you are awake. It is still…

Create Your Own Wake-Up Call Service With AWS Pinpoint, Lambda and CDK

Wake-up call service is exactly what you would imagine, someone will call you to wake you up and make sure that you are awake. It is still a common practice in hotels where hotel employees will wake you up via phone call. In this tutorial, we are going to build our own version using AWS Pinpoint, Lambda and CDK.

If you haven’t heard the term CDK, it means Cloud Development Kit. It is a modern Infrastructure as a Code tool from AWS, it allows us to use common programming languages to provision cloud resources. We will be using AWS Pinpoint to make outbound phone calls, Lambda function to execute Pinpoint API call to initiate an outbound call and Cloudwatch Events to schedule our Lambda function to run once daily.

For this tutorial, you will need NodeJS, npm and previously set up AWS profile. Requesting a long code(phone number) will cost you 1$ if you choose US based phone number, the costs might vary for different countries.

We will be deploying two different CDK stacks separately. The reasoning behind is that we need to create a Pinpoint project first and then we need to manually request for a long code. A long code is a standard telephone number that our message is sent from. At the time writing this post, Pinpoint does not allow any API calls to request for a long code, so we have to do it manually.

Here, we are creating a basic Pinpoint project.

Next, we will be creating the main logic, a Lambda Function and the Cloudwatch scheduler. We will be passing necessary information via environment variables.

In order to deploy these stacks and provide the necessary information, we are going to use a few Javascript libraries to accomplish our goal.

Here is the deploy script.

Don’t forget to provide necessary values via .env file inside the root folder

To deploy our service, we need to install dependencies and run the deploy.js script.

# Install dependencies at the project root folder
npm install
# Run the deploy script
node deploy.js

After the Pinpoint stack creation, we will be prompted to enter a long code.

To get a long code, head over to Pinpoint Console, select the newly created Pinpoint Project and go to Settings/Sms and Voice and click Request long codes.

Next, choose the target country and leave the default selection for the call type(Transactional) and click Request long codes.

You should see a phone number after a successful request.

Using the proper format, enter the long code.

After that, the CallService Stack will be deployed. Once both stacks are deployed, head over to the Lambda console and give our new call service a try.

By now, you should receive a phone call from the number we’ve created earlier. Cloudwatch Events will invoke the same lambda function once daily (or schedule that we would set using .env file).

We also need a way to destroy the stacks once we are done with our call service.


Popular posts from this blog

Concurrency With Boto3

Concurrency with Boto3 Concurrency with Boto3 Asyncio provides set of tools for concurrent programming in Python. In a very simple sense it does this by having an event loop execute a… Concurrency in Boto3 Asyncio provides a set of tools for concurrent programming in Python . In a very simple sense, it does this by having an event loop execute a collection of tasks, with a key difference being that each task chooses when to yield control back to the event loop. Asyncio is a good fit for IO-bound and high-level structured network code. Boto3 (AWS Python SDK) falls into this category. A lot of existing libraries are not ready to be used with asyncio out of the box. They may block, or depend on concurrency features not available through the module. It’s still possible to use those libraries in an application based on asyncio by using an executor from concurrent.futures to run the code either in a separate thread or a separate process. The run_in_executor() method of the event...

Manage MongoDB Atlas Deployments with AWS CDK

Manage MongoDB Atlas Deployments with AWS CDK Manage MongoDB Atlas Deployments with AWS CDK MongoDB Atlas is a fully-managed cloud-based database service offered by MongoDB. It offers a variety of features such as automatic… Manage MongoDB Atlas Deployments with AWS CDK MongoDB Atlas is a fully-managed cloud-based database service offered by MongoDB. It offers a variety of features such as automatic backups, automatic scaling, and easy integration with other cloud services. AWS Cloud Development Kit(CDK) is a tool provided by Amazon Web Services (AWS) that allows you to define infrastructure as code using familiar programming languages such as TypeScript, JavaScript, Python, and others. MongoDB recently announced general availability for Atlas Integrations for AWS CloudFormation and CDK. In this article, we will go through the process of deploying MongoDB Atlas with AWS CDK. Prerequisites Before we start, you will need the following: An AWS account AWS CDK installed on your lo...

AWS Lambda Function URLs

AWS Lambda Function URLs AWS Lambda Function URLs AWS Lambda is a Serverless computing service offered by Amazon Web Services (AWS) that allows developers to run code without provisioning… AWS Lambda Function URLs AWS Lambda AWS Lambda is a Serverless computing service offered by Amazon Web Services ( AWS ) that allows developers to run code without provisioning or managing servers. In this tutorial, we will explore AWS Lambda Function URLs , which are the endpoints that allow you to invoke your Lambda functions. AWS Lambda Function URLs are unique HTTP endpoints that you can create using AWS Console, SDK or any other IaC tool. These URLs are used to trigger your Lambda function, and they can be integrated with a variety of workloads. Function URLs are dual stack-enabled, supporting IPv4 and IPv6. After you configure a function URL for your function, you can invoke your function through its HTTP(S) endpoint via a web browser, curl, Postman, or any HTTP client. Once you create ...