> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect AWS CLI, S3cmd, and AWS JavaScript SDK

AWS CLI, S3cmd, and the AWS JavaScript SDK all use the same credentials to connect to Gcore Object Storage: an access key, a secret key, and an [endpoint URL](/storage/manage-object-storage/s3-service-urls-and-default-region-names). The setup format differs by tool — select a tab for the specific steps.

<Tabs>
  <Tab title="AWS CLI">
    AWS CLI integrates with Gcore Object Storage for bucket management using commands from the [Amazon documentation](https://docs.aws.amazon.com/cli/latest/reference).

    ### Installation

    <Steps>
      <Step title="Install AWS CLI">
        Follow the [installation guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) to install the latest version.
      </Step>

      <Step title="Verify installation">
        Run the following command to confirm the installation succeeded:

        ```sh theme={null}
        aws --version
        ```

        The output shows the installed version and operating system:

        ```sh theme={null}
        aws-cli/2.7.24 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
        ```

        If the terminal cannot find the `aws` command, consult the [troubleshooting guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-troubleshooting.html).
      </Step>
    </Steps>

    ### Configuration

    <Steps>
      <Step title="Launch the configuration wizard">
        Run `aws configure`.
      </Step>

      <Step title="Enter storage credentials">
        Provide the following values:

        * **Access Key**: the access key from the storage Details dialog.
        * **Secret Key**: the secret key from the storage Details dialog.
        * **Default region name**: the [region name](/storage/manage-object-storage/s3-service-urls-and-default-region-names) for the storage location — `s-ed1` for Luxembourg-2.
        * Leave all other parameters at their default values.
      </Step>

      <Step title="Verify the connection">
        Run the following command, replacing the endpoint with the actual value from the [service URLs](/storage/manage-object-storage/s3-service-urls-and-default-region-names) reference:

        ```sh theme={null}
        aws s3 ls --endpoint-url=https://s-ed1.cloud.gcore.lu
        ```

        Correct credentials produce no errors and list any existing buckets. An empty output with exit code 0 is expected for new storage with no buckets.
      </Step>
    </Steps>
  </Tab>

  <Tab title="S3cmd">
    S3cmd is a free command-line tool for uploading, retrieving, and managing objects in S3-compatible storage. The full command reference is in the [S3cmd documentation](https://s3tools.org/usage).

    ### Installation

    <Steps>
      <Step title="Download S3cmd">
        Go to the [Download](https://s3tools.org/download) page in the S3cmd documentation.
      </Step>

      <Step title="Install the package">
        Download and install the package for the operating system.
      </Step>
    </Steps>

    ### Configuration

    Two methods are available: the interactive wizard and direct command-line input for automated environments.

    <Accordion title="With wizard">
      <Steps>
        <Step title="Launch the wizard">
          Run the following command:

          ```sh theme={null}
          s3cmd --configure
          ```
        </Step>

        <Step title="Enter storage credentials">
          Provide the following values:

          * **Access Key**: the access key from the storage Details dialog.
          * **Secret Key**: the secret key from the storage Details dialog.
          * **S3 Endpoint**: the [storage endpoint](/storage/manage-object-storage/s3-service-urls-and-default-region-names) — `s-ed1.cloud.gcore.lu` for Luxembourg-2.
          * **DNS-style bucket+hostname**: the same endpoint — `s-ed1.cloud.gcore.lu`. Optionally append the port: `s-ed1.cloud.gcore.lu:80`.
          * Leave all other parameters at their default values.
        </Step>
      </Steps>

      S3cmd verifies the credentials and reports a success message:

      ```sh theme={null}
      Success. Your access key and secret key worked fine :-)
      ```

      The configuration is saved to `~/.s3cfg`:

      ```toml theme={null}
      [default]
      access_key = 123ABC456DEF...
      secret_key = EXAMPLE...
      host_base = s-ed1.cloud.gcore.lu
      host_bucket = s-ed1.cloud.gcore.lu
      ```
    </Accordion>

    <Accordion title="Without wizard">
      For scripted or automated environments that cannot accept interactive input, write the configuration directly to `~/.s3cfg`:

      ```sh theme={null}
      s3cmd --access_key 12*****6DEF --secret_key EX***** --host s-ed1.cloud.gcore.lu --host-bucket s-ed1.cloud.gcore.lu
      ```

      Where:

      * `12*****6DEF` is the access key from the storage Details dialog.
      * `EX*****` is the secret key from the storage Details dialog.
      * `s-ed1.cloud.gcore.lu` is the [storage endpoint](/storage/manage-object-storage/s3-service-urls-and-default-region-names).
    </Accordion>
  </Tab>

  <Tab title="AWS JavaScript SDK">
    <Note>The code examples use AWS SDK for JavaScript v2 (`aws-sdk`), which is in maintenance mode but remains functional. The [migration guide](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/migrating-to-v3.html) covers the path to SDK v3 (`@aws-sdk/client-s3`), which AWS recommends for new projects.</Note>

    ### SDK setup

    Add the AWS SDK script to the HTML page:

    ```html theme={null}
    <html>
        <head>
            <script src="https://sdk.amazonaws.com/js/aws-sdk-2.742.0.min.js"></script>
            <script src="./js/index2.js"></script>
        </head>
        <body>
            <h1>List of files</h1>
            <ul id="list">
            </ul>
        </body>
    </html>
    ```

    ### Storage operations

    #### Credentials and bucket name

    Open the configuration file (`./js/index2.js`) and specify the storage credentials and bucket name:

    ```js theme={null}
    var s3BucketName = "test";
    var host = "https://s-ed1.cloud.gcore.lu";
    var access_key = "1234";
    var secret_key = "5678";

    AWS.config.accessKeyId = access_key;
    AWS.config.secretAccessKey = secret_key;
    AWS.config.endpoint = host;

    var s3 = new AWS.S3({
        sslEnabled: true
    });
    ```

    Where:

    * `test` is the bucket name.
    * `https://s-ed1.cloud.gcore.lu` is the [storage endpoint](/storage/manage-object-storage/s3-service-urls-and-default-region-names).
    * `1234` is the access key from the Customer Portal.
    * `5678` is the secret key from the Customer Portal.

    #### CORS policy

    A wildcard CORS policy allows cross-origin GET, HEAD, PUT, POST, and DELETE requests from all sources:

    <Note>This configuration is permissive and may be insecure for production environments.</Note>

    ```xml theme={null}
    <CORSConfiguration>
    <CORSRule>
        <ID>Allow everything</ID>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedMethod>HEAD</AllowedMethod>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <AllowedHeader>*</AllowedHeader>
        <MaxAgeSeconds>30</MaxAgeSeconds>
    </CORSRule>
    </CORSConfiguration>
    ```

    Apply the policy to the bucket:

    ```sh theme={null}
    s3cmd setcors cors.xml s3://<bucket_name>
    ```

    #### Add objects to a bucket

    The following example adds two objects (`test_file1` and `test_file2`) to the `s3test` bucket:

    ```js theme={null}
    var params1 = {
       Bucket: "s3test", Key: "test_file1",
       Body: "test"
    };
    var params2 = {
       Bucket: "s3test", Key: "test_file2",
       Body: "test"
    };
    var request = s3.putObject(params1);
    request.send(function (err, data) {
       if (err) console.log("Error:", err.code, err.message);
       else console.log(data);
    });
    var request = s3.putObject(params2);
    request.send(function (err, data) {
       if (err) console.log("Error:", err.code, err.message);
       else console.log(data);
    });
    ```

    #### List objects in a bucket

    The following example retrieves all objects in the `test_2` bucket:

    ```js theme={null}
    params = {
        Bucket: "test_2"
    };
    s3.listObjects(params, function(err, data) {
        if (err) return;
        data.Contents.map(function(info) {
            var ul = document.getElementById("list");
            var li = document.createElement("li");
            li.innerText = info.Key + " " + info.LastModified;
            ul.append(li);
        });
    });
    ```
  </Tab>
</Tabs>
