HomeServerlessMessaging and QueuingAPI/CLI
Connecting your SNS/SQS namespace to the AWS-CLI
Jump toUpdate content

Connecting your SQS/SNS namespace to the AWS-CLI

Reviewed on 04 January 2023 • Published on 04 January 2023

The AWS-CLI is an open-source tool built on top of the AWS SDK for Python (Boto) that provides commands for interacting with AWS services. With minimal configuration, you can start using the AWS-CLI with your Scaleway Messaging and Queuing SQS/SNS namespace. This allows you to create, list and manage your queues and topics, send messages and much more, all from your command line.

This guide shows you how to install the AWS-CLI and configure it for connection to your Scaleway Messaging and Queuing SQS/SNS namespace.

Security & Identity (IAM):

You may need certain IAM permissions to carry out some actions described on this page. This means:

  • you are the Owner of the Scaleway Organization in which the actions will be carried out, or
  • you are an IAM user of the Organization, with a policy granting you the necessary permission sets
Requirements:
Note:

This page assumes you will use the AWS-CLI v1. For v2, see the relevant AWS-CLI documentation page.

How to install the AWS-CLI

To interact with Scaleway Messaging and Queuing, both aws-cli and awscli-plugin-endpoint need to be installed. The awscli-plugin-endpoint is a useful plugin to help people more easily access third-party providers such as Scaleway.

Install both aws-cli and awscli-plugin using pip.

pip3 install awscli
pip3 install awscli-plugin-endpoint

How to configure the AWS-CLI

Now you have installed the AWS-CLI, you need to configure it for use with your Scaleway Messaging and Queuing SQS/SNS namespace.

  1. Create a file named ~/.aws/config by running the following command:

    aws configure set plugins.endpoint awscli_plugin_endpoint
  2. Open the ~/.aws/config file you just created in a text editor and edit it as follows (the SNS or SQS URL for your namespace can be found in the console on the list of your Messaging and Queuing namespaces

    [plugins]
    endpoint = awscli_plugin_endpoint
    [default]
    sns =
    endpoint_url = https://sqs-sns.mnq.fr-par.scw.cloud
    sqs =
    endpoint_url = https://sqs-sns.mnq.fr-par.scw.cloud

    Optionally, you can also configure additional profiles by adding new blocks under [default]. For example, you can add a second profile, [profile aws], to connect to the AWS SQS/SNS service if you want:

    [plugins]
    endpoint = awscli_plugin_endpoint
    [default]
    sns =
    endpoint_url = https://sqs-sns.mnq.fr-par.scw.cloud
    sqs =
    endpoint_url = https://sqs-sns.mnq.fr-par.scw.cloud
    [profile aws]
    region=eu-west-3
    output=json
    Important:

    If you are using the AWS-CLI v2, you must include the path to the plugin in your configuration file. Add cli_legacy_plugin_path = <path-to-plugin> to the [plugins] section, replacing <path-to-plugin> with the corresponding path.

  3. Generate a credentials file using the following command:

    aws configure
  4. Open the ~/.aws/credentials file you just created, and add the access key and secret key you saved when you generated your SQS/SNS namespace’s credentials as follows:

    [default]
    aws_access_key_id=<ACCESS_KEY>
    aws_secret_access_key=<SECRET_KEY>

    If you have other profiles, you can add a block to indicate their credentials too:

    [aws]
    aws_access_key_id=<ACCESS_KEY>
    aws_secret_access_key=<SECRET_KEY>
  5. Test that everything is set up correctly with the following command:

    aws sqs list-queues

    Use the --profile option if you want to test it using a different profile.

Tip:

Check out our dedicated documentation to find more common commands for getting started with the AWS CLI:

  • The SQS guide walks you through creating and listing queues, sending messages to queues, and more.
  • The SNS guide shows you how to create and list topics and subscriptions, send messages to topics, and more.