|
| 1 | +--- |
| 2 | +meta: |
| 3 | + title: Connecting Topics and Events to the AWS-CLI |
| 4 | + description: This page explains how to connect Scaleway Topics and Events to the AWS-CLI |
| 5 | +content: |
| 6 | + h1: Connecting Topics and Events to the AWS-CLI |
| 7 | + paragraph: This page explains how to connect Scaleway Topics and Events to the AWS-CLI |
| 8 | +tags: messaging sns aws-cli cli aws sdk python boto |
| 9 | +categories: |
| 10 | + - messaging |
| 11 | +dates: |
| 12 | + validation: 2025-04-10 |
| 13 | + posted: 2023-01-04 |
| 14 | +--- |
| 15 | + |
| 16 | +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 Scaleway Topics and Events. This allows you to create, list and manage your topics, send messages and much more, all from your command line. |
| 17 | + |
| 18 | +This guide shows you how to install the AWS-CLI and configure it to connect to Scaleway Topics and Events. |
| 19 | + |
| 20 | +<Macro id="requirements" /> |
| 21 | + |
| 22 | +- A Scaleway account logged into the [console](https://console.scaleway.com) |
| 23 | +- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization |
| 24 | +- Valid [credentials](/topics-and-events/how-to/create-credentials/) for Topics and Events |
| 25 | + |
| 26 | +<Message type="note"> |
| 27 | + This page assumes you will use the AWS-CLI v1. |
| 28 | +</Message> |
| 29 | + |
| 30 | +## How to install the AWS-CLI |
| 31 | + |
| 32 | +To interact with Scaleway Topics and Events, 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. |
| 33 | + |
| 34 | +Install both `aws-cli` and `awscli-plugin` using `pip`. |
| 35 | + |
| 36 | +``` |
| 37 | +pip3 install awscli |
| 38 | +pip3 install awscli-plugin-endpoint |
| 39 | +``` |
| 40 | + |
| 41 | +## How to configure the AWS-CLI |
| 42 | + |
| 43 | +Now you have installed the AWS-CLI, you need to configure it for use with Scaleway Topics and Events. |
| 44 | + |
| 45 | +1. Create a file named `~/.aws/config` by running the following command: |
| 46 | + ``` |
| 47 | + aws configure set plugins.endpoint awscli_plugin_endpoint |
| 48 | + ``` |
| 49 | + |
| 50 | + <Message type="tip"> |
| 51 | + With the most recent versions of awscli (1.29.0 or 2.13.0), the use of a plugin is not necessary. If you are using one of those versions and wish to skip this step, you can do so. Note that this will also affect your configuration file in the next step. |
| 52 | + </Message> |
| 53 | + |
| 54 | +2. Open the `~/.aws/config` file you just created in a text editor and edit it as follows (the Topics and Events (SNS) endpoint URLs can be found in the console on the **Settings** page for your Topics and Events service). |
| 55 | + ``` |
| 56 | + [plugins] |
| 57 | + endpoint = awscli_plugin_endpoint |
| 58 | + [profile sns] |
| 59 | + region = fr-par |
| 60 | + sns = |
| 61 | + endpoint_url = https://sns.mnq.fr-par.scaleway.com |
| 62 | + ``` |
| 63 | + |
| 64 | + Optionally, you can also configure additional profiles by adding new blocks under `[sns]`. For example, you can add a profile for `[sqs]` if you are also using Scaleway Queues, or another profile, `[profile aws]`, to connect to the AWS SQS/SNS service if you want: |
| 65 | + |
| 66 | + ``` |
| 67 | + [plugins] |
| 68 | + endpoint = awscli_plugin_endpoint |
| 69 | + [profile sns] |
| 70 | + region = fr-par |
| 71 | + sns = |
| 72 | + endpoint_url = https://sns.mnq.fr-par.scaleway.com |
| 73 | + [profile sqs] |
| 74 | + region = fr-par |
| 75 | + sqs = |
| 76 | + endpoint_url = https://sqs.mnq.fr-par.scaleway.com |
| 77 | + [profile aws] |
| 78 | + region=eu-west-3 |
| 79 | + output=json |
| 80 | + ``` |
| 81 | + |
| 82 | + <Message type="important"> |
| 83 | + 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. |
| 84 | + </Message> |
| 85 | + |
| 86 | + <Message type="tip"> |
| 87 | + If you are using aws 1.29.0 or 2.13.0 without the plugin, your configuration file should be as follows: |
| 88 | + ``` |
| 89 | + [profile sns] |
| 90 | + region = fr-par |
| 91 | + endpoint_url = https://sns.mnq.fr-par.scaleway.com |
| 92 | + ``` |
| 93 | + </Message> |
| 94 | + |
| 95 | + |
| 96 | +3. Generate a credentials file using the following command: |
| 97 | + ``` |
| 98 | + aws configure |
| 99 | + ``` |
| 100 | +** |
| 101 | +4. Open the `~/.aws/credentials` file you just created, and add the access key and secret key you saved when you generated your [credentials](/topics-and-events/how-to/create-credentials/): |
| 102 | + ``` |
| 103 | + [topics_events] |
| 104 | + aws_access_key_id=<ACCESS_KEY_FOR_SNS> |
| 105 | + aws_secret_access_key=<SECRET_KEY_FOR_SNS> |
| 106 | + ``` |
| 107 | + |
| 108 | + If you have other profiles, you can add a block to indicate their credentials too: |
| 109 | + ``` |
| 110 | + [queues] |
| 111 | + aws_access_key_id=<ACCESS_KEY_FOR_SQS> |
| 112 | + aws_secret_access_key=<SECRET_KEY_FOR_SQS> |
| 113 | +
|
| 114 | + [aws] |
| 115 | + aws_access_key_id=<ACCESS_KEY> |
| 116 | + aws_secret_access_key=<SECRET_KEY> |
| 117 | + ``` |
| 118 | + |
| 119 | +5. Test that everything is set up correctly with the following command: |
| 120 | + ``` |
| 121 | + aws topics_events list-topics |
| 122 | + ``` |
| 123 | + |
| 124 | + Use the `--profile` option if you want to test it using a different profile. |
| 125 | + |
| 126 | +<Message type="tip"> |
| 127 | + Check out our dedicated documentation to find more common commands for getting started with the AWS CLI. The [Topics and EVents guide](/queues/api-cli/topics-events-aws-cli/) walks you through creating and listing topics, sending messages. |
| 128 | +</Message> |
0 commit comments