Skip to content

Commit

Permalink
Add AWS Postgres Iam Auth jar to GMS (#6371)
Browse files Browse the repository at this point in the history
* Add AWS Postgres Iam Auth jar to GMS

* Added IAM support for Postgres

* Setting IAM support for Postgres as false by default

* format fix

Co-authored-by: syed.javed <[email protected]>
  • Loading branch information
syedzoherer and syed.javed authored Dec 5, 2022
1 parent fdcb731 commit ffea930
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ project.ext.externalDependency = [
'awsGlueSchemaRegistrySerde': 'software.amazon.glue:schema-registry-serde:1.1.10',
'awsMskIamAuth': 'software.amazon.msk:aws-msk-iam-auth:1.1.1',
'awsSecretsManagerJdbc': 'com.amazonaws.secretsmanager:aws-secretsmanager-jdbc:1.0.8',
'awsPostgresIamAuth': 'software.amazon.jdbc:aws-advanced-jdbc-wrapper:1.0.0',
'awsRds':'software.amazon.awssdk:rds:2.18.24',
'cacheApi' : 'javax.cache:cache-api:1.1.0',
'commonsCli': 'commons-cli:commons-cli:1.5.0',
'commonsIo': 'commons-io:commons-io:2.4',
Expand Down
3 changes: 3 additions & 0 deletions docker/datahub-gms/env/docker.postgres.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ EBEAN_DATASOURCE_PASSWORD=datahub
EBEAN_DATASOURCE_HOST=postgres:5432
EBEAN_DATASOURCE_URL=jdbc:postgresql://postgres:5432/datahub
EBEAN_DATASOURCE_DRIVER=org.postgresql.Driver
# Uncomment EBEAN_POSTGRES_USE_AWS_IAM_AUTH below to add support for IAM authentication for Postgres.
# Password is not required when accessing Postgres using IAM auth. It can be replaced by dummy password
# EBEAN_POSTGRES_USE_AWS_IAM_AUTH=true
KAFKA_BOOTSTRAP_SERVER=broker:29092
KAFKA_SCHEMAREGISTRY_URL=http://schema-registry:8081
ELASTICSEARCH_HOST=elasticsearch
Expand Down
3 changes: 2 additions & 1 deletion metadata-service/factories/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ dependencies {
compile externalDependency.springKafka
compile externalDependency.springWeb
compile project(':metadata-service:auth-ranger-impl')

implementation externalDependency.awsPostgresIamAuth
implementation externalDependency.awsRds
annotationProcessor externalDependency.lombok

compile spec.product.pegasus.restliSpringBridge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import io.ebean.datasource.DataSourceConfig;
import io.ebean.datasource.DataSourcePoolListener;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -51,6 +53,9 @@ public class LocalEbeanServerConfigFactory {
@Value("${ebean.autoCreateDdl:false}")
private Boolean ebeanAutoCreate;

@Value("${ebean.postgresUseIamAuth:false}")
private Boolean postgresUseIamAuth;

private DataSourcePoolListener getListenerToTrackCounts(String metricName) {
final String counterName = "ebeans_connection_pool_size_" + metricName;
return new DataSourcePoolListener() {
Expand Down Expand Up @@ -79,6 +84,12 @@ private DataSourceConfig buildDataSourceConfig(String dataSourceUrl, String data
dataSourceConfig.setLeakTimeMinutes(ebeanLeakTimeMinutes);
dataSourceConfig.setWaitTimeoutMillis(ebeanWaitTimeoutMillis);
dataSourceConfig.setListener(getListenerToTrackCounts(dataSourceType));
// Adding IAM auth access for AWS Postgres
if (postgresUseIamAuth) {
Map<String, String> custom = new HashMap<>();
custom.put("wrapperPlugins", "iam");
dataSourceConfig.setCustomProperties(custom);
}
return dataSourceConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ebean:
leakTimeMinutes: ${EBEAN_LEAK_TIME_MINUTES:15}
waitTimeoutMillis: ${EBEAN_WAIT_TIMEOUT_MILLIS:1000}
autoCreateDdl: ${EBEAN_AUTOCREATE:false}
postgresUseIamAuth: ${EBEAN_POSTGRES_USE_AWS_IAM_AUTH:false}

# Only required if entityService.impl is cassandra
cassandra:
Expand Down

0 comments on commit ffea930

Please sign in to comment.