Thursday, 15 June 2023

How To Install AWS CLI – Amazon Simple Notification Service (SNS)? '

 Amazon Simple Notification Service (SNS) is used for the Application to Application (A2A) and Application to Person (A2P) communication. It provides developers with a highly scalable, flexible, and cost-effective capability to publish messages from an application and immediately deliver them to subscribers or other applications. Using AWS Console it is easy to publish messages to your endpoint of choice (HTTP, SQS, Lambda, mobile push, email, or SMS) and edit topic policies to control publisher and subscriber access.

Advantages of SNS:

  1. Immediate, push-based delivery
  2. Easy for integration
  3. Flexible message delivery using protocols
  4. It supports FIFO topics

Steps to create AWS SNS Service:

The below Steps are related to AWS E-mail SNS Service.

  • Firstly, open the AWS cloud shell and use the following command for creating the topic. Specify the name of the topic, for example, gfg-topic:
$ aws sns create-topic 
--name gfg-topic

 

 

  • Subscribe to the Topic:
$ aws sns subscribe --topic-arn arn:aws:sns:us-west
-2:123456789012:gfg-topic --protocol email 
--notification-endpoint example@example.com
  • Here you can choose your protocol to send your message through which protocol. i.e., HTTP, SQS, Lambda, mobile push, email, or SMS. After running the command you will get the email, to confirm your subscription by clicking on the given link.

 

 

  • Publish to a topic: After subscribing to the topic publish your topic and send the message to a perspective person or device.
$ aws sns publish --topic-arn 
arn:aws:sns:us-west-2:123456789012:
gfg-topic --message "Hello Geeks"

 

 

                 

  • Unsubscribe the Topic: For stopping receiving messages from the particular application you can unsubscribe using this command:
$ aws sns unsubscribe --subscription-arn
 arn:aws:sns:us-west-2:123456789012:
 gfg-topic:1328f057-de93-4c15-512e-8bb22EXAMPLE

 

  •  Delete the topic: For deleting the topic you can simply use the below command:
$ aws sns delete-topic --topic-arn
 arn:aws:sns:us-west-2:123456789012:gfg-topic

 


Amazon Web Services – Amazon S3 Notifications to SNS

 In this article, we will see how the Amazon S3 bucket publishes notifications to SNS topics on object creation events. An object that creates an event is of four types. They are Put, Post, Copy, Multipart Upload, Remove, Replicate and Restore. Thus, whenever any of the event occur in our S3 bucket, it will publish a notification to a topic and the subscribers to that topic can view those messages.

Approach:

  1. Create an SNS topic, say, GeeksTopic.
  2. Create subscribers under the topic.
  3. Create an S3 bucket, say, geeksforgeeks.
  4. Create event notifications under that bucket and configure them to the created topic.
  5. Upload object in the bucket.
  6. View message received by the subscriber.

The above approach has been implemented below.

  • Creation of SNS topic: SNS topic could be of two types, FIFO (First in First Out) and Standard. We will choose a standard for now and give the name as GeeksTopic. We will keep the encryption of messages disabled. Under access policy, by default only the owner is allowed to publish messages to the topic, not even the AWS services are allowed. Therefore, we select Basic and can opt either Everyone or Only the specified AWS accounts (need to specify the AWS account number). We will go for everyone and keep the rest of the settings as default and create the topic. See the below images:

  • Create Subscriber to Topic: A subscriber can subscribe to the topic in many ways. Some of the ways are Email, SMS, HTTPS, etc. We will select the email in this demo and under the endpoint will specify the email to which we want to receive messages. Leave the rest of the settings as default and create a subscriber. Once the subscriber is created, confirm the subscription to the topic by email received on your email id. See the below images:

  • Create a Bucket: Create a bucket in which when an object creates an event occurs, it should trigger an event and publish a notification to the topic. See the below image:

  • Create Event Configuration: To create events, go to the properties of the bucket and click on create event notifications tab. Specify the event name, say, geekseventtest, select event type as All object create event and under destination, select SNS Topic and choose the topic GeeksTopic. Click save changes. Once the event is created, you will receive an email stating TestEvent, thus confirming your subscription to the topic. See the below images:

  • Upload Object: Upload an object in the bucket to trigger an event. The event type will be of Put type as you are putting the object into the bucket.
  • Confirm event notification – As soon as the object is uploaded, an event is triggered, and it publishes the messages to the topic to which event has been configured. In our case GeeksTopic. To confirm, view the message received in the email. See the below image:

We have successfully configured an event to SNS and are able to view messages through subscribers.

Amazon Web Services – Introduction to Simple Workflow Service

 In this article, we are going to discuss one of the important aspects of Amazon AWS, which is called Amazon SWS or SWF. it stands for Amazon simple workflow services. It’s a part of Amazon Web Services (AWS).  AWS a cloud provider server. Which provides services in areas like computing, storage, administration, and networking, as well as on-demand services. This implies that customers can request a specific set of services. When it comes to hosting and building, one cloud service can help.

AWS has a free tier, which allows customers, who are just getting started with cloud computing to register an account and start utilizing the services for free.

Now let’s talk about the important part of amazon’s web service, Amazon SWF (Amazon Simple workflow services).

Amazon Simple Workflow Services:

Amazon Simple workflow services (Amazon SWF) are task-based Application interfaces, which are programmed to make it easy to coordinate different works across distributed application components. Here tasks represent a logical unit of work that is being performed by the application. It includes management of Inter-task dependencies, creating schedules, and concurrency according to the logical flow of the application.

With its help, you can have full control over task implementation. You can coordinate them without thinking about the underlying complexities. And the worries of tracking and maintaining their states are not a problem anymore. With its use, workers can be implemented to perform the tasks.

Tasks can be created for a long run or small period, or may time out after some time and may require restarts.

Amazon SWF stores the tasks and assigns them to workers when required. It also maintains their state and tracks their progress until their completion.

Amazon SWF supports a variety of application requirements and is suitable for a variety of different ranges of tasks including web application back-ends, analytics pipelines, etc.

How does it function?

The primary function of Amazon SWF is to control the workflow of your application. It serves as a coordination center for your application’s many components. When it comes to its functions, the most important ones are:

  • It maintains the application’s state.
  • It supervises the execution and progress of workflows
  • It includes tasks such as holding and dispatching.
  • It defines which of your application hosts’ responsibilities will be carried out.

Concepts of Amazon SWF:

The primary concept comes first when it comes to concepts. In Amazon SWF, the phrase “workflow” is used. It’s a set of activities with specific goals and logic that are linked to certain tasks. We can better understand it if we use an example: a workflow can take an order and then conduct the steps required to complete it.

Each process is kept within an Amazon Web Services resource called a Domain. It is in charge of determining the scope of the workflow. Many domains can be used in an AWS account, and each one can contain many workflows, but workflows from different domains cannot communicate. You must briefly specify each of the required tasks and register each activity with Amazon when developing an Amazon SWF workflow Activity.

Some of the actions may need to be repeated several times during the process, depending on the requirements. You might, for example, create an activity that handles buy items in the client order sequence. If a consumer buys anything more than once, the activity will have to be repeated.

SWF Actors:

Actors can be workflow initiates, deciders, or activity workers, These actors use Amazon SWF’s API to connect with it. Any computer language may be used to create these characters. The Amazon SWF architecture, including Amazon SWF and its actors, is discussed below.

Workflow Starters:

Any program that may start process executions is referred to as a workflow starter. One workflow starter, for example, may be the website where the consumer puts an order. A mobile application or system used by a customer care agent to make an order on behalf of the client might be another workflow starter.

Deciders:

A decider is a program that performs the coordination logic of a workflow. The flow of activity tasks in a workflow execution is controlled by deciders. Any modification in the workflow, whether it’s the execution or completion of a task, is the responsibility of the deciders. When the decider receives the decision task from Amazon SWF, it examines the workflow execution history to identify the next actions to take. Using decisions, the decider transmits these actions back to Amazon SWF. A decision is an Amazon SWF data type that may be used to express a variety of next steps and decisions.

Activity Workers:

An activity worker is a procedure that completes the activity tasks required by the workflow. One of the tasks that you identified in your application is the activity task. You must first register an activity task in your workflow using the Amazon SWF console or the Registration activity. Each activity worker polls in the Amazon SWF for new tasks that are suited for them to do; some activities are only available to specific activity workers. The activity worker receives a task, processes and completes it, and then communicates the task’s completion to Amazon SWF, along with the results. After that, the activity worker polls for a new assignment.

In such a way, the Amazon SWF service serves as a dependable central hub via which data may be shared between the decider, activity workers, and other important organizations such as the person in charge of the workflow. The condition of each workflow execution is also maintained by Amazon SWF, saving your app from having to maintain the state in a long-term manner.

Execution history:

The events that are saved in the program history are referred to as execution history. The workflow history is a comprehensive, consistent, and accurate record of its activities.

Workflow Execution:

Here we are going to discuss some simple and easy steps to execute a workflow in Amazon SWF.

  1. Create activity workers to carry out the workflow’s processing phases.
  2. Create a decider to execute your workflow’s coordination logic.
  3. Use Amazon SWF to register your actions and process. This step can be completed programmatically or using the AWS Management Console.
  4. Get your activity workers and deciders up and running. these actors can be executed on any. To host a decider or activity worker, you may employ cloud computing instances like Amazon Elastic Compute Cloud (Amazon EC2), servers in your data center, or even a mobile device. Once the decider and activity workers are up and running, they should begin polling Amazon SWF for assignments.

 Here comes the simple Workflow Example that will help you understand the working and execution of Amazon SWF workflow:

Let’s take an example of an E-Commerce Application, here the following figure is showing a simple e-commerce order-processing in a workflow. Here the people and automated processes both are involved in the following example.

Registration and Execution of Workflows starts, When a consumer placed an order, the workflow begins. It consists of four tasks:

  1. Double-check the order.
  2. Charge the customer if the order is legitimate.
  3. Once payment has been received, dispatch the order.
  4. Save the order information if the purchase has been sent.

Order must be validated before a credit card can be charged a credit card must be successfully charged before an order can be dispatched, and order must be shipped before it can be recorded. Nonetheless, These tasks can be carried out in multiple places since Amazon SWF enables distributed operations. If the tasks are programmatic, they can be written in a variety of programming languages or using a variety of tools.

Benefits:

  • Logical Separation: AWS SWF separates the control flow of your backdrop activities from the actual units of workers that hold the specific business logic, and modifies it progressively and rationally. This enables you to manage, maintain, expand, and state your application one by one, starting with the underlying business logic that makes it unique. As your business needs change, you may easily change the application logic without worrying about the underlying state machinery, task dispatch, or flow control.
  • Simple: Amazon SWF is a totally managed new cloud workflow internet service that replaces the quality of traditional workflow solutions and method automation software systems. Amazon Simple Workflow relieves developers with the burden of managing the infrastructural plumbing of method automation, allowing them to concentrate on the unique functionality of their application.
  •  Reliable: Traditional workflow services and process control software systems are being replaced by Amazon SWF, as a fully managed new cloud workflow internet service, it is a completely reliable server that relieves developers with the effort of maintaining method automation’s infrastructure plumbing, enabling them to focus on their application’s unique features.
  • Scalable: Amazon SWF extends with your application’s use in real-time. As you add more cloud processes to your application or improve the quality of your workflows, you won’t need to manage the workflow service manually.
  • Flexible: The user can change the application components with Amazon Simple Workflow. It also alters coordinating logic written in any programming language and runs it in the cloud or on-premises.

 So far, we’ve covered some of the basic and key concepts and features of the Amazon SWF. Finally, we may state that it is really powerful. It’s a simple and adaptable tool that’s beneficial and straightforward to use. It might be extremely beneficial to your business It’s a practical, user-friendly, and adaptable tool.

Amazon Web Services – Introduction to Simple Queue Service(SQS)

 This article will provide you with an introduction to AWS SQS. We will cover the difference between the queues and create our own.

What is SQS?

Amazon Simple Queue Service (SQS) will let you send the messages, store the messages, and receive the messages between various software components at any amount, without losing of  actual messages.  Also, without requiring some other services to should be available. so, basically Amazon SQS is a distributed queue system. SQS enables the  web service applications that helps to quickly and reliably queue the messages. These messages have one component in their application that generates only when to be consumed by another component. Therefore, the queue is a temporary repository for messages and these messages are awaiting processing. So, Once these messages are processed, the messages also gets deleted from the queue. SQS service basically adds the messages in a queue. and then, Users will pick up these messages from the queue.

A queue is a place where you can store your messages until they are extracted from the queue or expired. Queues are used to store textual information so it can be received and used by a consumer later on. 

The consumer is something that is getting a message from a queue. It can be anything that is able to make an API call to SQS (application, microservice, human, etc…). Using this paradigm we implement decoupling. 

The decoupling allows processing incoming requests later on. So when the consumer is overloaded it will just wait before getting another message. This way our applications become more fault-tolerant. 

Amazon Simple Queue Service(SQS) is a fully managed queue service in the AWS cloud. 

Customers Using SQS:-

1. Change HealthCare

2. NASA

3. CapitalOne

4. BMW

Types of Queues:

There are only two types of queues in SQS:

  1. First-in-first-out(FIFO) – in this queue the order of messages is preserved. So if you receive a message from the queue you will get the oldest message. This queue also guarantees that the message will be delivered only once. 
  2. Standart queue – in this queue messages are delivered randomly. Also, a message can be delivered multiple times. So you shouldn’t rely on order and only one-time delivery in this type of queues.

Important points to remember:

1. SQS is not push-based, it is basically on pull-based.
2. The size of messages in SQS are 256 KB.
3. There is default retention period in SQS. The default retention period is of 4 days.

4. Messages in SQS of a queue is kept from 1 minute to 14 days.
5. SQS also guarantees that the messages will only be processed at least once.

Creation of SQS via AWS console:

Follow the below steps to create a SQS using the AWS console:

  • Open AWS console and type “SQS” in the search bar. And select it.

  • Then hit “Create queue”.  You should see the following screen:

Every field has an Info clause. You can click on it and read about it if curious.

  • Let’s give our queue ‘geeky_queue’ name and hit “Create Queue”. For other fields defaults are fine.

Difference Between AWS S3 and AWS EBS

 The AWS S3(simple storage service ) and AWS EBS(elastic block storage) are two different types of storage services provided by Amazon Web Services. This article highlights some major differences between Amazon S3 and Amazon EBS.

AWS Storage Options:

Amazon S3: Amazon S3 is a simple storage service offered by Amazon and it is useful for hosting website images and videos, data analytics, etc. S3 is an object-level data storage that distributes the data objects across several machines and allows the users to access the storage via the internet from any corner of the world.

Amazon EBS: Unlike Amazon S3, Amazon EBS is a block-level data storage offered by Amazon. Block storage stores files in multiple volumes called blocks, which act as separate hard drives, and this storage is not accessible via the internet. Use cases include business continuity, transactional and NO SQL database, software testing, etc.

Comparison based on Characteristics:

1. Storage type

Amazon Simple Storage Service is object storage designed for storing large numbers of user files and backups whereas Elastic block storage is block storage for Amazon EC2 compute instances and it is just similar to hard drives attached to your computers or laptops, but the only difference is that it is used for virtualized instances.

2. Accessibility

The files within an S3 bucket are stored in an unstructured manner and can be retrieved using HTTP protocols and even with BitTorrent but the data stored in EBS is only accessible by the instance to which it is connected to.

3. Availability

Both S3 and EBS gives the availability of 99.99%, but the only difference that occurs is that S3 is accessed via the internet using API’s and EBS is accessed by the single instance attached to EBS.

4. Durability

Amazon S3 provides durability by redundantly storing the data across multiple Availability Zones whereas EBS provides durability by redundantly storing the data in a single Availability Zone.

5. Security, Compliance, and Audit features

Amazon S3 can prevent unauthorized accessing of data using its access management tools and encryption policies but no such feature is present in EBS. In EBS, if any user gets unauthorized access to the instance then he/she can easily access the attached EBS. Also, S3 has got some features that make it easier to comply with regulatory requirements.

6. Size of data

Simple storage service (S3) can store large amounts as compared to EBS. With S3, the standard limit is of100 buckets and each bucket has got an unlimited data capacity whereas EBS has a standard limit of 20 volumes and each volume can hold data up to 1TB. In EBS there occurs an upper limit on the data storage.

7. Usability

One major limitation of EBS(Elastic block storage) is that not all EBS types can be used by multiple instances at a single time. Multi-attach EBS volume option is available only for provisioned IPOPs SSD io1 and io2 volume types whereas S3 can have multiple images of its contents so it can be used by multiple instances at the same time.

8. Pricing

Amazon S3 storage service allows you to follow the utility-based model and prices as per your usage but in Elastic block storage, you need to pay for the provisioned capacity.

Amazon S3 cost parameters are:

  1. Free Tier – 5 GB
  2. First 50 TB/month – $0.023/GB
  3. 450 TB/month – $0.022/GB
  4. Over 500 TB / Month – $0.021 per GB

Amazon EBS cost parameters are:

  1. Free Tier – 30 GB, 1 GB snapshot storage
  2. General Purpose – $0.045/GB(1 month)
  3. Provisioned SSD – $0.125/GB(1 month)

9. Scalability

Amazon S3 offers rapid scalability to its users/clients, resources can be provisioned and de-provisioned in run time but no such scalability feature is present in EBS, here there is manual increasing or decreasing of storage resources.

10. Performance

  • Amazon EBS is faster storage and offers high performance as compared to S3.

11. Latency

  • As EBS storage is attached to the EC2 instance and is only accessible via that instance in the particular AWS region, it offers less latency than S3 which is accessed via the internet. Also, EBS uses SSD volumes which offers reliable I/O performance.

12. Geographic interchangeability

Amazon EBS has an upper hand in geographical interchangeability of data as here the user just requires EBS snapshots and then he/she can place resources and data in multiple locations.

13. Backup and restore

For backup purposes, Amazon S3 uses versioning and cross-region replication whereas the backup feature in EBS is supported by snapshots and automated backup.

14. Security

Both S3 and EBS support data at rest and data in transmission encryption, so both are equally secure and offer a good level of security.

Use cases:,

Amazon S3 use cases are:

  1. Data lake and big data analytics: Amazon S3 works with AWS Lake Formation to create data lakes that are basically used to hold raw data in its native format and then supports big data analytics by using some machine learning tools,query-in-place, etc and gets some useful insights from the raw data.
  2. Backup and restoration: Amazon S3 when combined with other AWS offerings(EBS, EFS, etc) can provide a secure and robust backup solution.
  3. Reliable disaster recovery: S3 service can provide reliable data recovering from any type of disaster such as power cut, system failure, human error, etc.
  4. Other use cases include entertainment, media, content management purposes, etc.

Amazon EBS use cases are:

  1. Software Testing and development: Amazon EBS is connected only to a particular instance, so it is best suited for testing and development purposes.
  2. Business continuity: Amazon EBS provides a good level of business consistency as users can run applications in different AWS regions and all they require is EBS Snapshots and Amazon machine images.
  3. Enterprise-wide applications: EBS provides block-level storage, so it allows users to run a wide variety of applications including Microsoft Exchange, Oracle, etc.
  4. Transactional and NoSQL databases: As EBS provides a low level of latency so it offers an optimum level of performance for transactional and NO SQL databases. It also helps in database management.

Let us see the differences in a tabular form as follows:

AWS S3AWS EBS
The AWS S3 Full form is Amazon Simple Storage ServiceThe AWS EBS full form is Amazon Elastic Block Store
AWS S3 is an object storage service that helps the industry in scalability, data availability, security, etc.It is easy to use.
AWS S3 is used to store and protect any amount of data for a range of use cases.It has high-performance block storage at every scale
AWS S3 can be used to store data lakes, websites, mobile applications, backup and restore big data analytics. , enterprise applications, IoT devices, archive etc.It is scalable.
AWS S3 also provides management features It is also used to run relational or NoSQL databases