Skip to content

Commit

Permalink
Fix issue with secret being not populated for default EnvironmentProp…
Browse files Browse the repository at this point in the history
…erties behavior
  • Loading branch information
ejeffrli committed Nov 14, 2024
1 parent c076ed8 commit 1bde417
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public Map<String, String> createEnvironment() throws RuntimeException
HashMap<String, String> connectionEnvironment = new HashMap<>();
if (StringUtils.isNotBlank(glueConnectionName)) {
Connection connection = getGlueConnection(glueConnectionName);
Map<String, String> connectionProperties = new HashMap<>(connection.connectionPropertiesAsStrings());
connectionProperties.putAll(authenticationConfigurationToMap(connection.authenticationConfiguration()));
Map<String, String> connectionPropertiesWithSecret = new HashMap<>(connection.connectionPropertiesAsStrings());
connectionPropertiesWithSecret.putAll(authenticationConfigurationToMap(connection.authenticationConfiguration()));

connectionEnvironment.putAll(connectionPropertiesToEnvironment(connectionProperties));
connectionEnvironment.putAll(connectionPropertiesToEnvironment(connectionPropertiesWithSecret));
connectionEnvironment.putAll(athenaPropertiesToEnvironment(connection.athenaProperties()));
}

Expand Down Expand Up @@ -96,10 +96,12 @@ private Map<String, String> authenticationConfigurationToMap(AuthenticationConfi
Map<String, String> authMap = new HashMap<>();

if (auth != null && StringUtils.isNotBlank(auth.secretArn())) {
logger.info("SECRET FROM GLUE IS {}", auth.secretArn());
String[] splitArn = auth.secretArn().split(":");
String[] secretNameWithRandom = splitArn[splitArn.length - 1].split("-"); // 6 random characters at end. at least length of 2
String[] secretNameArray = Arrays.copyOfRange(secretNameWithRandom, 0, secretNameWithRandom.length - 1);
String secretName = String.join("-", secretNameArray); // add back the dashes
logger.info("SECRET AFTER PARSING {}", secretName);
authMap.put(SECRET_NAME, secretName);
}
return authMap;
Expand All @@ -120,13 +122,14 @@ public Map<String, String> athenaPropertiesToEnvironment(Map<String, String> ath
}

/**
* Maps glue connection properties to environment properties like 'default' and 'secret_manager_gcp_creds_name'
* Default behavior is to not populate environment with these properties
* Maps glue connection properties and authentication configuration
* to Athena federation environment properties like 'default' and 'secret_manager_gcp_creds_name'
* Default behavior is to not map to Athena federation environment variables
*
* @param connectionProperties contains secret_name and connection properties
*/
public Map<String, String> connectionPropertiesToEnvironment(Map<String, String> connectionProperties)
{
return new HashMap<>();
return connectionProperties;
}
}

0 comments on commit 1bde417

Please sign in to comment.