Module aws.sns

ballerinax/aws.sns Ballerina library

3.0.0

Overview

The ballerinax/aws.sns package offers APIs to connect and interact with AWS SNS API endpoints.

Setup guide

Step 1: Create an AWS account

  • If you don't already have an AWS account, you need to create one. Go to the AWS Management Console, click on "Create a new AWS Account," and follow the instructions.

Step 2: Get the access key ID and the secret access key

Once you log in to your AWS account, you need to create a user group and a user with the necessary permissions to access SNS. To do this, follow the steps below:

  1. Create an AWS user group
  • Navigate to the Identity and Access Management (IAM) service. Click on "Groups" and then "Create New Group."

    Create user group
  • Enter a group name and attach the necessary policies to the group. For example, you can attach the "AmazonSNSFullAccess" policy to provide full access to SNS.

    Attach policy
  1. Create an IAM user
  • In the IAM console, navigate to "Users" and click on "Add user."

    Add user
  • Enter a username, tick the "Provide user access to the AWS Management Console - optional" checkbox, and click "I want to create an IAM user". This will enable programmatic access through access keys.

    Create IAM user
  • Click through the permission setup, and add the user to the user group we previously created.

    Attach user group
  • Review the details and click "Create user."

    Review user
  1. Generate access key ID and secret access key
  • Once the user is created, you will see a success message. Navigate to the "Users" tab, and select the user you created.

    View User
  • Click on the "Create access key" button to generate the access key ID and secret access key.

    Create access key
  • Follow the steps and download the CSV file containing the credentials.

    Download credentials

Quickstart

To use the aws.sns connector in your Ballerina project, modify the .bal file as follows:

Step 1: Import the connector

Import the ballerinax/aws.sns package into your Ballerina project.

Copy
import ballerinax/aws.sns;

Step 2: Instantiate a new connector

Instantiate a new sns client using the access key ID, secret access key, and region.

Copy
sns:Client sns = check new({
    credentials: {
        accessKeyId,
        secretAccessKey
    },
    region
});

Step 3: Invoke the connector operation

Now, utilize the available connector operations.

Copy
string topicArn = check sns->createTopic("FirstTopic");

Step 4: Run the Ballerina application

Use the following command to compile and run the Ballerina program.

Copy
bal run

Examples

The sns connector provides practical examples illustrating usage in various scenarios. Explore these examples.

  1. Football scores This example shows how to use SNS to implement an application to subscribe to receive football game scores.

  2. Weather alert service This example shows how to use SNS to send weather alerts for multiple cities. Users can subscribe to different cities to receive alerts for their city only.

Import

import ballerinax/aws.sns;Copy

Metadata

Released date: 8 months ago

Version: 3.0.0

License: Apache-2.0


Compatibility

Platform: java17

Ballerina version: 2201.8.5

GraalVM compatible: Yes


Pull count

Total: 943

Current verison: 842


Weekly downloads


Source repository


Keywords

Communication/Notifications

Cost/Freemium

Vendor/Amazon


Contributors

Other versions

See more...