

# Install the extension

Before you install the extension, check that the following prerequisites are met:
+ Use DuckDB 2.0.1 and an extension build for that client version.
+ Use one of the supported platforms in the following table. Linux requires glibc 2.34 or later; Amazon Linux 2 does not meet this requirement.
+ Use a workgroup running DuckDB in a supported Region. See [Regions and availability](duckdb-availability.md) and [Step 1: Create a DuckDB workgroup](duckdb-getting-started-console.md#athena-duckdb-getting-started-console-create-workgroup).
+ Configure usable credentials for the default credential chain. To use a named profile, select it with `PROFILE` on the secret as described in [Use a named profile](connect-with-duckdb-extension-authentication.md#connect-with-duckdb-extension-authentication-profile).
+ Grant the query and data permissions in [Security and permissions](duckdb-permissions.md) and the extension API permissions in [Athena API permissions](connect-with-duckdb-extension-authentication.md#connect-with-duckdb-extension-authentication-iam).
+ Allow HTTPS access to `aws.amazon.com` and `downloads.aws.com` for repository registration and extension installation. If the core `httpfs` and `aws` extensions are not already installed, also allow download access to your configured DuckDB core-extension repository. Queries also need access to the service endpoints used by your configuration.


**Supported platforms**  

| Operating system and architecture | Platform | 
| --- | --- | 
| Linux, x86-64 | linux\_amd64 | 
| Linux, ARM64 | linux\_arm64 | 
| macOS, Apple silicon | osx\_arm64 | 
| Windows, x86-64 | windows\_amd64 | 

## Step 1: Install the extension
<a name="connect-with-duckdb-extension-install"></a>

Register the repository and install the signed extension with the following commands. Repository registration is saved on your machine. Install the extension for each DuckDB client version you use; after upgrading the client, install a compatible build again. Installation from this repository is an explicit step.

```sql
CREATE EXTENSION REPOSITORY aws.amazon.com;
INSTALL athena FROM aws.amazon.com;
```

With extension autoloading and auto-installation enabled, DuckDB installs and loads `httpfs` as needed for the repository commands. If the repository already exists, registering it again returns a catalog error. To avoid the error, use `CREATE OR REPLACE EXTENSION REPOSITORY aws.amazon.com` or `CREATE EXTENSION REPOSITORY IF NOT EXISTS aws.amazon.com`.

## Step 2: Load and attach
<a name="connect-with-duckdb-extension-start-session"></a>

In each session, run the following commands to load the extension and attach your workgroup. The example uses credentials from the default credential chain. Replace {{us-west-2}} with your Region and {{my-duckdb-workgroup}} with your workgroup name.

```sql
LOAD athena FROM aws.amazon.com;
INSTALL AND LOAD aws;
ATTACH 'arn:aws:athena' AS ath
    (TYPE athena, Region '{{us-west-2}}',
     WorkGroup '{{my-duckdb-workgroup}}');
```

`ath`  
The optional local catalog alias created by `ATTACH`. Keep it when following the later query examples.

`TYPE athena`  
Selects the Athena extension for the attached catalog.

To use a named profile or refreshable temporary credentials, create a DuckDB secret as described in [Credentials and required permissions](connect-with-duckdb-extension-authentication.md).

For the DuckDB workgroup used in this procedure, leave `EngineVersion` and `athena_engine_version` unset. A workgroup that enforces engine version 3 is refused. For an unenforced engine version 3 workgroup, the extension requests DuckDB; the service must allow that selection. Use a DuckDB workgroup for this setup.

## Check the installed extension
<a name="connect-with-duckdb-extension-installed-version"></a>

To inspect the installed extension version and whether it is loaded, run the following query. This query inspects the client's extension installation; it does not list extensions offered by the repository.

```sql
SELECT extension_name, extension_version, installed, loaded, installed_from
FROM duckdb_extensions()
WHERE extension_name = 'athena';
```

## Update the installed extension
<a name="connect-with-duckdb-extension-update"></a>

To download and install available updates from the registered repositories, run the following command.

```sql
UPDATE EXTENSIONS;
```

An update does not replace an extension already loaded in a running database instance. Close that instance and start a new one to load the updated binary. For the command-line client, exit and restart DuckDB.