Using RDS IAM authentication with DBeaver Community Edition (CE)

1 minute read

While DBeaver Professional has IAM authentication support out of the box. This post describes how you can accompish the same thing while using DBeaver CE.

MySQL

You need to install the AWS JDBC Driver for MySQL and the AWS SDK for Java (RDS) by doing the following:

  • Open Driver Manager -> New and use the following settings:

    • Driver Name: AWS JDBC Driver for MySQL
    • Class Name: software.aws.rds.jdbc.mysql.Driver
    • URL Template: jdbc:mysql:aws://{host}:{port}
    • Default Port: 3306

    MySQL-Driver-Settings

  • Click on the Libraries tab -> Add Artifact and paste in the following:

    <!-- replacing LATEST with specific version as required -->
    
    <dependencies>
        <dependency>
            <groupId>software.aws.rds</groupId>
            <artifactId>aws-mysql-jdbc</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>rds</artifactId>
            <version>LATEST</version>
        </dependency>
    </dependencies>
    
  • Click OK and Close the Driver Manager
  • Continue below

PostgreSQL

You need to install the AWS JDBC Driver, the AWS SDK for Java (RDS) and the PostgreSQL JDBC Driver by doing the following:

  • Open Driver Manager -> New and use the following settings:

    • Driver Name: AWS JDBC Driver for PostgreSQL
    • Class Name: software.amazon.jdbc.Driver
    • URL Template: jdbc:aws-wrapper:postgresql://{host}:{port}/{database}
    • Default Port: 5432

    PostgreSQL-Driver-Settings

  • Click on the Libraries tab -> Add Artifact and paste in the following:

    <!-- replacing LATEST with specific version as required -->
    
    <dependencies>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>rds</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.jdbc</groupId>
            <artifactId>aws-advanced-jdbc-wrapper</artifactId>
            <version>LATEST</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>LATEST</version>
        </dependency>
    </dependencies>
    
  • Click OK and Close the Driver Manager
  • Continue below

Using the driver

  • Completely exit DBeaver and re-open it from your terminal window. This is needed so it loads your AWS_PROFILE environment variable. You will need to remember to open DBeaver this way going forward to use the IAM credentials or find another way to load the environment variable on startup. On macOS, I open the terminal and type the following to open DBeaver. Set the profile name to be whatever your AWS profile is called, that has RDS IAM access.

    AWS_PROFILE="my profile" open /Applications/DBeaver.app
    
  • Add a New Database Connection and use AWS JDBC Driver for MySQL or AWS JDBC Driver for PostgreSQL as the driver
  • For MySQL: Click on the Driver properties tab, scroll down to useAwsIam and set it to true

    MySQL-Driver-Properties

  • For PostgreSQL: Click on the Driver properties tab, set wrapperPlugins to iam

    PostgreSQL-Driver-Properties

  • Enter your DB connection details in the Main tab
  • Click Test Connection and it should connect and authenticate to your RDS database

Comments