Today, the use of cloud services is necessary, since it is the logical path to the evolution of IT systems. Each cloud provider offers a series of services and we, as developers, have to know how to use/integrate these services.
Using different services from different cloud providers, we can provide a complete solution to business without any limitations.
This blog post explains a proof of concept that how to use AWS SNS in SAPUI5 application.
What is AWS SNS?
Amazon Simple Notification Service (SNS) is a flexible, fully managed pub/sub messaging and mobile notifications service for coordinating the delivery of messages to subscribing endpoints and clients. With SNS you can fan-out messages to a large number of subscribers, including distributed systems and services, and mobile devices.
We need a little knowledge of other AWS services:
- API Gateway: Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. You can create an API that acts as a “front door” for applications to access data, business logic, functionality from your back-end services, code running on AWS Lambda, or any web application.
- Lambda: AWS Lambda lets you run code without provisioning or managing servers. With Lambda, you can run code for virtually any type of application or backend service – all with zero administration. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.
Our application will call API Gateway to start the notification process in AWS. API Gateway will execute Lambda function. Lambda will invoke AWS SNS and AWS SNS will publish message in the selected topic.
We created in AWS Console a new topic in AWS SNS:
Fill necessary fields:
When you have topic created, you need to create a subscription in your topic:
In this PoC, I choose a SMS protocol but you have different interesting options:
Now, we need a lambda function to call AWS SNS.
We create a new lambda function:
Note: the role assigned needs AWS SNS permission to execute the SNS service. You can create a new policy with necessary SNS policies and attach it to a role.
When function is created, you can write the code to execute SNS service:
At last in AWS, a new api was created to call lambda service:
After API creation, you need to create a new resource (in this case was notify) and a new method (in this case was POST):
Note: For this PoC, I didn’t use Authorization and API Key. For a real project, please, use it:
Now you can configure your API to consume lambda function:
When you finish your configuration, you can test the API (and complete process) clicking on Test button:
Fill message test and click test:
Note: First, you need deploy API to a stage to use it.
Now, we will use SNS service in our SAPUI5 application. I created a SAPUI5 application with empty view.
I drew a simple layout:
And I wrote a simple function associated to “Send Notification” button:
Note: Yes… We must never use urls in our code… But for this PoC, it’s ok
With these steps, you can send notifications from you SAPUI5 app using AWS services!
- SAPUI5 app:
- My mobile device:
As you can read in the blog post, SAPUI5 gives us the opportunity to use SAP Cloud Platform services and cloud services from other providers (in our case AWS).
Compared with the old ABAP applications development, SAPUI5 gives us the opportunity to develop really interesting applications with a high possibility in the services consumption. This allows us to create applications, which were previously almost impossible to create.
Now, we have to play with different services and programming languages, which it makes … the applications development really fun!
Let’s all play!
Thanks to read this blog post!