Skip to content

Commit ccb1879

Browse files
committed
Support role based access for DynamoDb source connector
1 parent 92af730 commit ccb1879

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

airbyte-integrations/connectors/source-dynamodb/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ data:
55
connectorSubtype: api
66
connectorType: source
77
definitionId: 50401137-8871-4c5a-abb7-1f5fda35545a
8-
dockerImageTag: 0.2.3
8+
dockerImageTag: 0.3.0
99
dockerRepository: airbyte/source-dynamodb
1010
documentationUrl: https://docs.airbyte.com/integrations/sources/dynamodb
1111
githubIssueLabel: source-dynamodb

airbyte-integrations/connectors/source-dynamodb/src/main/java/io/airbyte/integrations/source/dynamodb/DynamodbConfig.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ public record DynamodbConfig(
2525
) {
2626

2727
public static DynamodbConfig createDynamodbConfig(JsonNode jsonNode) {
28+
JsonNode access_key_id = jsonNode.get("access_key_id");
29+
JsonNode secret_access_key = jsonNode.get("secret_access_key");
2830
JsonNode endpoint = jsonNode.get("endpoint");
2931
JsonNode region = jsonNode.get("region");
3032
JsonNode attributeNames = jsonNode.get("reserved_attribute_names");
3133
return new DynamodbConfig(
3234
endpoint != null && !endpoint.asText().isBlank() ? URI.create(endpoint.asText()) : null,
3335
region != null && !region.asText().isBlank() ? Region.of(region.asText()) : null,
34-
jsonNode.get("access_key_id").asText(),
35-
jsonNode.get("secret_access_key").asText(),
36+
access_key_id != null && !access_key_id.asText().isBlank() ? access_key_id.asText() : null,
37+
secret_access_key != null && !secret_access_key.asText().isBlank() ? secret_access_key.asText() : null,
3638
attributeNames != null ? Arrays.asList(attributeNames.asText().split("\\s*,\\s*")) : List.of());
3739
}
3840

airbyte-integrations/connectors/source-dynamodb/src/main/java/io/airbyte/integrations/source/dynamodb/DynamodbUtils.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515
import java.time.Instant;
1616
import java.util.List;
1717
import java.util.Optional;
18+
1819
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
20+
import software.amazon.awssdk.auth.credentials.AwsCredentials;
21+
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
22+
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
1923
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
2024
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
25+
import org.apache.commons.lang3.StringUtils;
2126

2227
public class DynamodbUtils {
2328

@@ -27,10 +32,16 @@ private DynamodbUtils() {
2732

2833
public static DynamoDbClient createDynamoDbClient(final DynamodbConfig dynamodbConfig) {
2934
final var dynamoDbClientBuilder = DynamoDbClient.builder();
35+
AwsCredentialsProvider awsCredentialsProvider;
36+
if (!StringUtils.isBlank(dynamodbConfig.accessKey()) && !StringUtils.isBlank(dynamodbConfig.secretKey())) {
37+
AwsCredentials awsCreds = AwsBasicCredentials.create(dynamodbConfig.accessKey(), dynamodbConfig.secretKey());
38+
awsCredentialsProvider = StaticCredentialsProvider.create(awsCreds);
39+
} else {
40+
awsCredentialsProvider = DefaultCredentialsProvider.create();
41+
}
3042

3143
// configure access credentials
32-
dynamoDbClientBuilder.credentialsProvider(StaticCredentialsProvider.create(
33-
AwsBasicCredentials.create(dynamodbConfig.accessKey(), dynamodbConfig.secretKey())));
44+
dynamoDbClientBuilder.credentialsProvider(awsCredentialsProvider);
3445

3546
if (dynamodbConfig.region() != null) {
3647
dynamoDbClientBuilder.region(dynamodbConfig.region());

airbyte-integrations/connectors/source-dynamodb/src/main/resources/spec.json

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"$schema": "http://json-schema.org/draft-07/schema#",
55
"title": "Dynamodb Source Spec",
66
"type": "object",
7-
"required": ["access_key_id", "secret_access_key"],
87
"additionalProperties": false,
98
"properties": {
109
"endpoint": {

docs/integrations/sources/dynamodb.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ This guide describes in details how you can configure the connector to connect w
6767

6868
## Changelog
6969

70-
| Version | Date | Pull Request | Subject |
71-
|:--------| :--------- | :-------------------------------------------------------- |:---------------------------------------------------------------------|
72-
| 0.2.3 | 2024-02-13 | [35232](https://github.com/airbytehq/airbyte/pull/35232) | Adopt CDK 0.20.4 |
73-
| 0.2.2 | 2024-01-24 | [34453](https://github.com/airbytehq/airbyte/pull/34453) | bump CDK version |
74-
| 0.2.1 | 2024-01-03 | [#33924](https://github.com/airbytehq/airbyte/pull/33924) | Add new ap-southeast-3 AWS region |
75-
| 0.2.0 | 18-12-2023 | https://github.com/airbytehq/airbyte/pull/33485 | Remove LEGACY state |
76-
| 0.1.2 | 01-19-2023 | https://github.com/airbytehq/airbyte/pull/20172 | Fix reserved words in projection expression & make them configurable |
77-
| 0.1.1 | 02-09-2023 | https://github.com/airbytehq/airbyte/pull/22682 | Fix build |
78-
| 0.1.0 | 11-14-2022 | https://github.com/airbytehq/airbyte/pull/18750 | Initial version |
70+
| Version | Date | Pull Request | Subject |
71+
|:--------| :--------- | :-------------------------------------------------------- |:-----------------------------------------------------------------------|
72+
| 0.3.0 | 2024-04-24 | [37530](https://github.com/airbytehq/airbyte/pull/37530) | Allow role based access |
73+
| 0.2.3 | 2024-02-13 | [35232](https://github.com/airbytehq/airbyte/pull/35232) | Adopt CDK 0.20.4 |
74+
| 0.2.2 | 2024-01-24 | [34453](https://github.com/airbytehq/airbyte/pull/34453) | bump CDK version |
75+
| 0.2.1 | 2024-01-03 | [#33924](https://github.com/airbytehq/airbyte/pull/33924) | Add new ap-southeast-3 AWS region |
76+
| 0.2.0 | 18-12-2023 | https://github.com/airbytehq/airbyte/pull/33485 | Remove LEGACY state |
77+
| 0.1.2 | 01-19-2023 | https://github.com/airbytehq/airbyte/pull/20172 | Fix reserved words in projection expression & make them configurable |
78+
| 0.1.1 | 02-09-2023 | https://github.com/airbytehq/airbyte/pull/22682 | Fix build |
79+
| 0.1.0 | 11-14-2022 | https://github.com/airbytehq/airbyte/pull/18750 | Initial version |

0 commit comments

Comments
 (0)