![]() Here we specify the “sqs” protocol and we’ll also set the –topic-arn value to the TopicArn value we recorded earlier as well as set the –notification-endpoint to the previously recorded SQS QueueArn. Now we are ready to create the SNS subscription via the CLI. “QueueArn”: “arn:aws:sqs:us-east-1::pub-sub-test-consumer” Record the QueueArn value for later configuration. If successful, the command will return with a response like the following. $ aws sqs get-queue-attributes ––queue-url ––attribute-names QueueArn In order to do so, we use the following command. First, we need to obtain the ARN of the queue that we just created, using the previously recorded QueueUrl. With the Amazon SNS topic and Amazon SQS queue in place, we now need to configure Simple Notification Service to route messages from the SNS topic, to the SQS queue, by creating an SNS subscription. Record the QueueUrl value for later configuration. $ aws sqs create-queue ––queue-name pub-sub-test-consumer ––attributes file://sqs-attributes.json With that file in place we are now ready to create the SQS queue, referencing the file we just created. Notice, the bolded text is the actual policy document. Note: remember to replace the place holder with your AWS account number. You can see what the file looks like below and you can download it here. We’ll call that file sqs-attributes.json. The way this is done using the AWS CLI is to put the policy document within another JSON structure, in a separate file. However, in order for Amazon SNS to route a message to the Amazon SQS queue we create, we need to set up the appropriate access policy. “TopicArn”: “arn:aws:sns:us-east-1::pub-sub-test”įor this exercise, we will use an Amazon SQS queue to consume the messages from the SNS topic. ![]() Record the TopicArn value for later configuration. $ aws sns create-topic ––name pub-sub-test Now that the AWS CLI is downloaded and your environment configured, we need to run the following command at the CLI to create our SNS topic. Warning: some AWS services may have fees associated with them. In addition, you will need to create an AWS IAM user with programmatic access with the appropriate permissions for Amazon SNS and Amazon SQS. To complete this solution, you will need to download the AWS CLI and configure your environment for the CLI. These items should not be skipped for proper solutions. We don’t include logging, input validation, exception handling, etc., and we embed the configuration data within classes instead of using environment variables, configuration files, key/value stores and the like. NET, we focus on the code that exemplifies the problem we are trying to solve. Remember, for any example solution from AWS with. Note, we will interchangeably use SNS to refer to Simple Notification Service and SQS to refer to Simple Queue Service as a way to become familiar with the AWS vernacular. In this tutorial, we’ll take you through setting up an Amazon Simple Notification Service topic, as well as a Simple Queue Service queue and then subscribe the SQS queue to the SNS topic. This exercise could also be carried out in the AWS console as well as one of the AWS SDKs and if you are proficient in an AWS SDK or the console, feel free to use one of those tools to view the changes being made while we move through this solution. All the while, we will exclusively use the AWS CLI to accomplish the task. Here we will look at creating both a Simple Notification Service topic as well as a Simple Queue Service queue and then creating an SNS subscription “linking” the two. AWS gives engineers many ways to accomplish many tasks. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |