Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c024ec6
refresh db pwd
himanshug Feb 29, 2020
5cef48e
aws iam token password provider
himanshug Mar 3, 2020
85932c0
fix analyze-dependencies build
himanshug Mar 14, 2020
2314fa4
fix doc build
himanshug Mar 14, 2020
955b62f
add ut for BasicDataSourceExt
himanshug Mar 14, 2020
553f622
more doc updates
himanshug Mar 14, 2020
ede86cc
more doc update
himanshug Mar 14, 2020
162e522
Merge remote-tracking branch 'apache/master' into aws_pwd_provider
himanshug Mar 26, 2020
f908756
moving aws token password provider to new extension
himanshug Mar 26, 2020
35a0527
remove duplicate changes
himanshug Mar 26, 2020
52ff609
make all config inline
himanshug Mar 26, 2020
52efefc
extension docs
himanshug Mar 26, 2020
6969403
refresh db password in SQL Firehose code path as well
himanshug Mar 26, 2020
27f5652
add ut
himanshug Mar 27, 2020
ee98fc8
fix build
himanshug Mar 27, 2020
46e2264
add new extension to distribution
himanshug Mar 27, 2020
ca82501
rds lib is not provided
himanshug Mar 27, 2020
1a7726c
fix license build
himanshug Mar 27, 2020
f5214e0
add version to license
himanshug Mar 28, 2020
22a35aa
Merge remote-tracking branch 'apache/master' into aws_pwd_provider
himanshug Apr 5, 2020
d65edc0
change parent version to 0.19.0-snapshot
himanshug Apr 5, 2020
ff1f02a
Merge remote-tracking branch 'apache/master' into aws_pwd_provider
himanshug May 30, 2020
6ef6341
Merge remote-tracking branch 'origin/master' into aws_pwd_provider
himanshug Jan 5, 2021
6ab5687
address review comments
himanshug Jan 5, 2021
f04c23a
fix core/ code coverage
himanshug Jan 5, 2021
254de29
Update server/src/main/java/org/apache/druid/metadata/BasicDataSource…
himanshug Jan 6, 2021
fe2ab6a
address review comments
himanshug Jan 6, 2021
71c452b
fix spellchecker
himanshug Jan 6, 2021
3cee6fc
remove inadvertant website file change
himanshug Jan 6, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@
<argument>-c</argument>
<argument>org.apache.druid.extensions:druid-s3-extensions</argument>
<argument>-c</argument>
<argument>org.apache.druid.extensions:druid-aws-rds-extensions</argument>
<argument>-c</argument>
<argument>org.apache.druid.extensions:druid-ec2-extensions</argument>
<argument>-c</argument>
<argument>org.apache.druid.extensions:druid-google-extensions</argument>
Expand Down
38 changes: 38 additions & 0 deletions docs/development/extensions-core/druid-aws-rds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
id: druid-aws-rds
title: "Druid AWS RDS Module"
---

<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

[AWS RDS](https://aws.amazon.com/rds/) is a managed service to operate relation databases such as PostgreSQL, Mysql etc. These databases could be accessed using static db password mechanism or via [AWS IAM](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html) temporary tokens. This module provides AWS RDS token [password provider](../../operations/password-provider.md) implementation to be used with [mysql-metadata-store](mysql.md) or [postgresql-metadata-store](postgresql.md) when mysql/postgresql is operated using AWS RDS.

```json
{ "type": "aws-rds-token", "user": "USER", "host": "HOST", "port": PORT, "region": "AWS_REGION" }
```

Before using this password provider, please make sure that you have connected all dots for db user to connect using token.
See [AWS Guide](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.IAMDBAuth.html).

To use this extension, make sure you [include](../../development/extensions.md#loading-extensions) it in your config file along with other extensions e.g.

```
druid.extensions.loadList=["druid-aws-rds-extensions", "postgresql-metadata-storage", ...]
```
1 change: 1 addition & 0 deletions docs/development/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Core extensions are maintained by Druid committers.
|druid-ranger-security|Support for access control through Apache Ranger.|[link](../development/extensions-core/druid-ranger-security.md)|
|druid-s3-extensions|Interfacing with data in AWS S3, and using S3 as deep storage.|[link](../development/extensions-core/s3.md)|
|druid-ec2-extensions|Interfacing with AWS EC2 for autoscaling middle managers|UNDOCUMENTED|
|druid-aws-rds-extensions|Support for AWS token based access to AWS RDS DB Cluster.|[link](../development/extensions-core/druid-aws-rds.md)|
|druid-stats|Statistics related module including variance and standard deviation.|[link](../development/extensions-core/stats.md)|
|mysql-metadata-storage|MySQL metadata store.|[link](../development/extensions-core/mysql.md)|
|postgresql-metadata-storage|PostgreSQL metadata store.|[link](../development/extensions-core/postgresql.md)|
Expand Down
80 changes: 80 additions & 0 deletions extensions-core/druid-aws-rds-extensions/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.druid.extensions</groupId>
<artifactId>druid-aws-rds-extensions</artifactId>
<name>druid-aws-rds-extensions</name>
<description>druid-aws-rds-extensions</description>

<parent>
<groupId>org.apache.druid</groupId>
<artifactId>druid</artifactId>
<version>0.21.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<dependencies>
<dependency>
<groupId>org.apache.druid</groupId>
<artifactId>druid-core</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-rds</artifactId>
<version>${aws.sdk.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.druid.aws.rds;

import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.jsontype.NamedType;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.google.common.collect.ImmutableList;
import com.google.inject.Binder;
import org.apache.druid.initialization.DruidModule;

import java.util.List;

public class AWSRDSModule implements DruidModule
{
@Override
public List<? extends Module> getJacksonModules()
{
return ImmutableList.of(
new SimpleModule("DruidAwsRdsExtentionsModule").registerSubtypes(
new NamedType(AWSRDSTokenPasswordProvider.class, "aws-rds-token")
)
);
}

@Override
public void configure(Binder binder)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.druid.aws.rds;

import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.services.rds.auth.GetIamAuthTokenRequest;
import com.amazonaws.services.rds.auth.RdsIamAuthTokenGenerator;
import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
import org.apache.druid.java.util.common.RE;
import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.metadata.PasswordProvider;

/**
* Generates the AWS token same as aws cli
* aws rds generate-db-auth-token --hostname HOST --port PORT --region REGION --username USER
* and returns that as password.
*
* Before using this, please make sure that you have connected all dots for db user to connect using token.
* See https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/UsingWithRDS.IAMDBAuth.html
*/
public class AWSRDSTokenPasswordProvider implements PasswordProvider
{
private static final Logger LOGGER = new Logger(AWSRDSTokenPasswordProvider.class);
private final String user;
private final String host;
private final int port;
private final String region;

private final AWSCredentialsProvider awsCredentialsProvider;

@JsonCreator
public AWSRDSTokenPasswordProvider(
@JsonProperty("user") String user,
@JsonProperty("host") String host,
@JsonProperty("port") int port,
@JsonProperty("region") String region,
@JacksonInject AWSCredentialsProvider awsCredentialsProvider
)
{
this.user = Preconditions.checkNotNull(user, "null metadataStorage user");
this.host = Preconditions.checkNotNull(host, "null metadataStorage host");
Preconditions.checkArgument(port > 0, "must provide port");
this.port = port;

this.region = Preconditions.checkNotNull(region, "null region");

LOGGER.info("AWS RDS Config user[%s], host[%s], port[%d], region[%s]", this.user, this.host, port, this.region);
this.awsCredentialsProvider = Preconditions.checkNotNull(awsCredentialsProvider, "null AWSCredentialsProvider");
}

@JsonProperty
public String getUser()
{
return user;
}

@JsonProperty
public String getHost()
{
return host;
}

@JsonProperty
public int getPort()
{
return port;
}

@JsonProperty
public String getRegion()
{
return region;
}

@JsonIgnore
@Override
public String getPassword()
{
try {
RdsIamAuthTokenGenerator generator = RdsIamAuthTokenGenerator
.builder()
.credentials(awsCredentialsProvider)
.region(region)
.build();

String authToken = generator.getAuthToken(
GetIamAuthTokenRequest
.builder()
.hostname(host)
.port(port)
.userName(user)
.build()
);

return authToken;
}
catch (Exception ex) {
LOGGER.error(ex, "Couldn't generate AWS token.");
throw new RE(ex, "Couldn't generate AWS token.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

org.apache.druid.aws.rds.AWSRDSModule
Loading