Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AWS Postgres Iam Auth jar to GMS #6371

Merged
merged 9 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,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