Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNS MVP for Swift SDK #7227

Open
7 of 11 tasks
shepazon opened this issue Feb 4, 2025 · 0 comments
Open
7 of 11 tasks

SNS MVP for Swift SDK #7227

shepazon opened this issue Feb 4, 2025 · 0 comments
Assignees
Labels
Swift This issue relates to the AWS SDK for Swift Task A general update to the code base for language clarification, missing actions, tests, etc.

Comments

@shepazon
Copy link
Contributor

shepazon commented Feb 4, 2025

SNS documentation references:

SQS documentation references:

Reference implementation of scenario and actions in C++: #4767

Service actions

Service actions can either be pulled out as individual functions or can be incorporated into the scenario, but each service action must be included as an excerpt in the SOS output.

SNS Actions

  • CreateTopic
  • Subscribe
  • Publish
  • Unsubscribe
  • DeleteTopic

SQS Actions

  • CreateQueue
  • GetQueueAttributes
  • SetQueueAttributes
  • ReceiveMessage
  • DeleteMessageBatch
  • DeleteQueue

Hello Service

The Hello Service example should demonstrate how to set up the client and make an example call using the SDK.

General info for Hello Service example snippets:
This section of the MVP should be a streamlined, simple example with enough detail to be as close to “copy/paste” runnable as possible. This example may include namespaces and other setup in order to focus on getting the user up and running with the new service.
Sample output:

Hello Amazon SNS! You have 1 topic in your account.
Here are your topics ARNs.
  * arn:aws:sns:us-east-1:123456789012:good_news.fifo

Hello SNS

Initialize the client and call ListTopics to list the event topics. List topics is a paginated response.

Hello SQS

Initialize the client and call ListQueues to list the SQS queues. List queues is a paginated response.

Scenario

README

This is a workflow scenario. As such, the READMEs should be standardized.
This is the C++ reference README

Implementation

A scenario runs at a command prompt and prints output to the user on the result of each service action. Because of the choices in this workflow scenario, it must be run interactively.

Publish and subscribe with topics and queues.

  1. There are 3 options for topic configuration. Allow the user to select from these 3 options.

    1. Non-FIFO topic.
    2. FIFO topic with content-based deduplication.
    3. FIFO topic without deduplication
  2. Create a topic. (CreateTopic)

    1. Append “.fifo” to the name, if FIFO topics were selected.
    2. If it is a FIFO topic, set the ""FifoTopic" attribute to "true".
    3. if the content-based deduplication was selected set the "ContentBasedDeduplication" attribute to "true".
  3. Create an SQS queue. (CreateQueue)

    1. Append “.fifo” to the name, if FIFO topics were selected.
    2. If FIFO was selected, set the "FifoQueue" to true.
  4. Get the SQS queue ARN attribute using GetQueueAttributes.

  5. Attach an IAM policy to the queue using SetQueueAttributes.

    {
    "Statement": [
    {
    "Effect": "Allow",
    "Principal": {
    "Service": "sns.amazonaws.com"
    },
    "Action": "sqs:SendMessage",
    "Resource": "arn:aws:sqs:us-east-1:111111111:",
    "Condition": {
    "ArnEquals": {
    "aws:SourceArn": "arn:aws:sns:us-east-1:111111111:"
    }
    }
    }
    ]
    }

  6. Subscribe the SQS queue to the SNS topic using SNS Subscribe

    1. Set the topic ARN in the request.
    2. Set the protocol to “sqs”.
    3. Set the queue ARN to the ARN of the queue just created.
    4. If this is a FIFO topic, give the option to apply a filter.

In the C++ reference application, the filter is an attribute filter. Set with the “FilterPolicy” attribute.
Here is an example filter JSON.

{ "tone": ["cheerful","serious"] }
  1. Repeat steps 3 - 6 for the second queue.

  2. Publish a message to the topic. (Publish)

    1. Ask the user for a message body.
    2. If this is a FIFO topic, set the message Group ID (user input optional, but giving a user the choice allows them to explore behavior, although I think it is hard to show an effect it this case).
    3. If this is a FIFO topic and content-based deduplication is not enabled, a deduplication ID must be entered, (giving the user the choice does allow them to see the impact of shared deduplication IDs).
    4. If this is a FIFO topic and any of the subscriptions are filtered, ask the user if they would like to add an attribute for filtering.
  3. Repeat publish a message (step 11) until the user says no.

  4. Display the messages in both queues using SQS ReceiveMessage.

The message output should include at least the body and the attributes. For C++, the attributes were included in the body method.
  1. Delete the received message using SQS DeleteMessageBatch

  2. Delete the unsubscribe and delete the queues. (Unsubscribe) (DeleteQueue)

  3. Delete the topic. (DeleteTopic)

See the attached sample output from the C++ MVP.

Metadata

In sns_metadata.yaml:

sns_Hello
sns_CreateTopic
sns_Subscribe_Queue
sns_Subscribe_Filtered
sns_Publish
sns_Publish_WithAttribute
sns_Unsubscribe
sns_DeleteTopic

In sqs_metadata.yaml:

sqs_Hello
sqs_CreateQueue
sqs_GetQueueAttributes
sqs_SetQueueAttributes
sqs_ReceiveMessage
sqs_DeleteMessageBatch
sqs_DeleteQueue

@shepazon shepazon self-assigned this Feb 4, 2025
@shepazon shepazon added Swift This issue relates to the AWS SDK for Swift Task A general update to the code base for language clarification, missing actions, tests, etc. labels Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Swift This issue relates to the AWS SDK for Swift Task A general update to the code base for language clarification, missing actions, tests, etc.
Projects
None yet
Development

No branches or pull requests

1 participant