[Yandex Cloud documentation](../../../index.md) > [Yandex MPP Analytics for PostgreSQL](../../index.md) > [Step-by-step guides](../index.md) > Working with PXF > Creating external data sources > S3

# Creating an external S3 data source

In Yandex MPP Analytics for PostgreSQL, you can use [Yandex Object Storage](../../../storage/index.md) as an [external data source](../../concepts/external-tables.md#pxf-data-sources) with the S3 connection type, including by connecting to Yandex Object Storage via [Private Endpoint](../../../storage/operations/buckets/access-via-vpc.md). You can also use other third-party S3 services.

To get started, [create a static access key](../../../iam/operations/authentication/manage-access-keys.md#create-access-key). You will need to specify its data in the source properties.

## Create an external data source

{% list tabs group=instructions %}

- Management console {#console}

    To create an external S3 data source:

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. Open the page of the Yandex MPP Analytics for PostgreSQL cluster in question.
    1. In the left-hand panel, select ![image](../../../_assets/console-icons/arrow-right-arrow-left.svg) **PXF**.
    1. Click **Create data source**.
    1. Select the `S3` connection type.
    1. Enter a source name.
    1. Configure at least one [optional setting](../../concepts/settings-list.md#s3-settings):

        * Specify the static access key ID in the **Access Key** field, and its contents, in the **Secret Key** field.
        
                    
          [Learn more about static access keys](../../../iam/concepts/authorization/access-key.md).
          
        
        * Select **Fast Upload** to enable fast upload of large files to S3 storage.
    
            This option is enabled by default.
               
            When using fast upload, PXF generates files in RAM (if out of RAM, it writes them to disk). If fast upload is disabled, PXF generates files on disk.
        
        * In the **Endpoint** field, enter the S3 storage address.
            
            The default value is `storage.yandexcloud.net` for Object Storage.

    1. Click **Create**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To create an external S3 data source:

    1. View the description of the CLI command for creating a data source:

        ```bash
        yc managed-greenplum pxf-datasource create s3 --help
        ```

    1. Configure the data source:

        ```bash
        yc managed-greenplum pxf-datasource create s3 <external_data_source_name> \
           --cluster-id=<cluster_ID> \
           --access-key=<static_key_ID> \
           --secret-key=<secret_part_of_static_key> \
           --endpoint=<S3_storage_address> \
           --fast-upload=<fast_upload>
        ```

        Where:

        * `cluster-id`: Cluster ID. You can get it with the [list of clusters in the folder](../cluster-list.md#list-cluster).
        * `access-key`, `secret-key`: [ID and contents of the static access key](../../../iam/concepts/authorization/access-key.md).
        * `endpoint`: S3 storage address. The value for Object Storage is `storage.yandexcloud.net`. This is the default value.
        * `fast-upload`: Fast upload of large files to S3 storage. The possible values are:
            * `true`: Default value. PXF generates files in RAM (if out of RAM, it writes them to disk).
            * `false`: PXF generates files on disk.

- REST API {#api}

    1. [Get an IAM token for API authentication](../../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Call the [PXFDatasource.Create](../../api-ref/PXFDatasource/create.md) method, e.g., via the following [cURL](https://curl.se/) request:

        ```bash
        curl \
            --request POST \
            --header "Authorization: Bearer $IAM_TOKEN" \
            --header "Content-Type: application/json" \
            --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>/pxf_datasources' \
            --data '{
                      "datasource": {
                        "name": "<external_data_source_name>",
                        "s3": {
                          "accessKey": "<static_key_ID>",
                          "secretKey": "<secret_part_of_static_key>",
                          "fastUpload": "<fast_upload>",
                          "endpoint": "<S3_storage_address>"
                        }
                      }
                    }'
        ```

        Where:

        * `name`: External data source name.
        * `s3`: External data source settings:

            * `accessKey`, `secretKey`: [ID and contents of the static access key](../../../iam/concepts/authorization/access-key.md).
            * `fastUpload`: Fast upload of large files to S3 storage. The possible values are:
                * `true`: Default value. PXF generates files in RAM (if out of RAM, it writes them to disk).
                * `false`: PXF generates files on disk.

            * `endpoint`: S3 storage address. The value for Object Storage is `storage.yandexcloud.net`. This is the default value.

        You can get the cluster ID with the [list of clusters in the folder](../cluster-list.md#list-clusters).

    1. View the [server response](../../api-ref/PXFDatasource/create.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

    1. [Get an IAM token for API authentication](../../api-ref/authentication.md) and put it into an environment variable:

        ```bash
        export IAM_TOKEN="<IAM_token>"
        ```

    1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
       
       ```bash
       cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
       ```
       
       Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

    1. Call the [PXFDatasourceService.Create](../../api-ref/grpc/PXFDatasource/create.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

        ```bash
        grpcurl \
            -format json \
            -import-path ~/cloudapi/ \
            -import-path ~/cloudapi/third_party/googleapis/ \
            -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/pxf_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d '{
                  "cluster_id": "<cluster_ID>"
                  "datasource": {
                    "name": "<external_data_source_name>",
                    "s3": {
                      "access_key": "<static_key_ID>",
                      "secret_key": "<secret_part_of_static_key>",
                      "fast_upload": <fast_upload>,
                      "endpoint": "<S3_storage_address>"
                    }
                  }
                }' \
            mdb.api.cloud.yandex.net:443 \
            yandex.cloud.mdb.greenplum.v1.PXFDatasourceService.Create
        ```

        Where:

        * `name`: External data source name.
        * `s3`: External data source settings:

            * `access_key`, `secret_key`: [ID and contents of the static access key](../../../iam/concepts/authorization/access-key.md).
            * `fast_upload`: Fast upload of large files to S3 storage. The possible values are:
                * `true`: Default value. PXF generates files in RAM (if out of RAM, it writes them to disk).
                * `false`: PXF generates files on disk.

            * `endpoint`: S3 storage address. The value for Object Storage is `storage.yandexcloud.net`. This is the default value.

        You can get the cluster ID with the [list of clusters in the folder](../cluster-list.md#list-clusters).

    1. Check the [server response](../../api-ref/grpc/PXFDatasource/create.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

After you create an external data source, [create an external table](create-table.md).