|
| 1 | +--- |
| 2 | +meta: |
| 3 | + title: Connecting Queues or Topics and Events to the AWS-CLI |
| 4 | + description: This page explains how to connect Scaleway Queues and/or Topics and Events to the AWS-CLI |
| 5 | +content: |
| 6 | + h1: Connecting Queues or Topics and Events to the AWS-CLI |
| 7 | + paragraph: This page explains how to connect Scaleway Queues and/or Topics and Events to the AWS-CLI |
| 8 | +tags: messaging sns sqs aws-cli cli aws sdk python boto |
| 9 | +categories: |
| 10 | + - messaging |
| 11 | +dates: |
| 12 | + validation: 2024-10-18 |
| 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 Queues or Scaleway Topics and Events. This allows you to create, list and manage your queues and 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 Queues or 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](/messaging/how-to/create-credentials/) for Queues and/or 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 Queues and 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 Queues / 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 Queues (SQS) or Topics and Events (SNS) endpoint URLs can be found in the console on the **Settings** page for the relevant product) |
| 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 | + [profile sqs] |
| 63 | + region = fr-par |
| 64 | + sqs = |
| 65 | + endpoint_url = https://sqs.mnq.fr-par.scaleway.com |
| 66 | + ``` |
| 67 | + |
| 68 | + Optionally, you can also configure additional profiles by adding new blocks under `[sqs]` and `[sns]`. For example, you can add a third profile, `[profile aws]`, to connect to the AWS SQS/SNS service if you want: |
| 69 | + |
| 70 | + ``` |
| 71 | + [plugins] |
| 72 | + endpoint = awscli_plugin_endpoint |
| 73 | + [profile sns] |
| 74 | + region = fr-par |
| 75 | + sns = |
| 76 | + endpoint_url = https://sns.mnq.fr-par.scaleway.com |
| 77 | + [profile sqs] |
| 78 | + region = fr-par |
| 79 | + sqs = |
| 80 | + endpoint_url = https://sqs.mnq.fr-par.scaleway.com |
| 81 | + [profile aws] |
| 82 | + region=eu-west-3 |
| 83 | + output=json |
| 84 | + ``` |
| 85 | + |
| 86 | + <Message type="important"> |
| 87 | + 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. |
| 88 | + </Message> |
| 89 | + |
| 90 | + <Message type="tip"> |
| 91 | + If you are using aws 1.29.0 or 2.13.0 without the plugin, your configuration file should be as follows: |
| 92 | + ``` |
| 93 | + [profile sns] |
| 94 | + region = fr-par |
| 95 | + endpoint_url = https://sns.mnq.fr-par.scaleway.com |
| 96 | + [profile sqs] |
| 97 | + region = fr-par |
| 98 | + endpoint_url = https://sqs.mnq.fr-par.scaleway.com |
| 99 | + ``` |
| 100 | + </Message> |
| 101 | + |
| 102 | + |
| 103 | +3. Generate a credentials file using the following command: |
| 104 | + ``` |
| 105 | + aws configure |
| 106 | + ``` |
| 107 | +** |
| 108 | +4. Open the `~/.aws/credentials` file you just created, and for each product (out of **Queues** and **Topics and Events**) you want to use, add the access key and secret key you saved when you generated your [credentials](/messaging/how-to/create-credentials/): |
| 109 | + ``` |
| 110 | + [topics_events] |
| 111 | + aws_access_key_id=<ACCESS_KEY_FOR_SNS> |
| 112 | + aws_secret_access_key=<SECRET_KEY_FOR_SNS> |
| 113 | +
|
| 114 | + [queues] |
| 115 | + aws_access_key_id=<ACCESS_KEY_FOR_SQS> |
| 116 | + aws_secret_access_key=<SECRET_KEY_FOR_SQS> |
| 117 | + ``` |
| 118 | + |
| 119 | + If you have other profiles, you can add a block to indicate their credentials too: |
| 120 | + ``` |
| 121 | + [aws] |
| 122 | + aws_access_key_id=<ACCESS_KEY> |
| 123 | + aws_secret_access_key=<SECRET_KEY> |
| 124 | + ``` |
| 125 | + |
| 126 | +6. Test that everything is set up correctly with the following command: |
| 127 | + ``` |
| 128 | + aws queues list-queues |
| 129 | + ``` |
| 130 | + |
| 131 | + Use the `--profile` option if you want to test it using a different profile. |
| 132 | + |
| 133 | +<Message type="tip"> |
| 134 | + Check out our dedicated documentation to find more common commands for getting started with the AWS CLI: |
| 135 | + - The [Queues guide](/messaging/api-cli/sqs-sns-aws-cli/#getting-started-with-scaleway-queues) walks you through creating and listing queues, sending messages to queues, and more. |
| 136 | + - The [Topics and Events guide](/messaging/api-cli/sqs-sns-aws-cli/#getting-started-with-topics-and-events) shows you how to create and list topics and subscriptions, send messages to topics, and more. |
| 137 | +</Message> |
0 commit comments