Skip to content

Commit 41f89d1

Browse files
alvaroqueirozedgaomarcosmarxm
authored
Destination S3: use instanceprofile if credentials are not provided (#9399)
* use instanceprofile to auth if id is not provided * restore support for using endpoint * update readme * update changelog * update documentation, add setup guide * Update docs/integrations/destinations/s3.md Co-authored-by: Edward Gao <[email protected]> * minor fixes * add error message * now using RuntimeException * Update airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/S3DestinationConfig.java Co-authored-by: Edward Gao <[email protected]> * bump connector version * update seed file Co-authored-by: Edward Gao <[email protected]> Co-authored-by: Marcos Marx <[email protected]>
1 parent 9cc2560 commit 41f89d1

File tree

8 files changed

+31
-16
lines changed

8 files changed

+31
-16
lines changed

airbyte-config/init/src/main/resources/config/STANDARD_DESTINATION_DEFINITION/4816b78f-1489-44c1-9060-4b19d5fa9362.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"destinationDefinitionId": "4816b78f-1489-44c1-9060-4b19d5fa9362",
33
"name": "S3",
44
"dockerRepository": "airbyte/destination-s3",
5-
"dockerImageTag": "0.2.4",
5+
"dockerImageTag": "0.2.5",
66
"documentationUrl": "https://docs.airbyte.io/integrations/destinations/s3",
77
"icon": "s3.svg"
88
}

airbyte-config/init/src/main/resources/seed/destination_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
- name: S3
168168
destinationDefinitionId: 4816b78f-1489-44c1-9060-4b19d5fa9362
169169
dockerRepository: airbyte/destination-s3
170-
dockerImageTag: 0.2.3
170+
dockerImageTag: 0.2.5
171171
documentationUrl: https://docs.airbyte.io/integrations/destinations/s3
172172
icon: s3.svg
173173
- name: SFTP-JSON

airbyte-config/init/src/main/resources/seed/destination_specs.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,7 +3408,7 @@
34083408
supported_destination_sync_modes:
34093409
- "append"
34103410
- "overwrite"
3411-
- dockerImage: "airbyte/destination-s3:0.2.4"
3411+
- dockerImage: "airbyte/destination-s3:0.2.5"
34123412
spec:
34133413
documentationUrl: "https://docs.airbyte.io/integrations/destinations/s3"
34143414
connectionSpecification:
@@ -3419,8 +3419,6 @@
34193419
- "s3_bucket_name"
34203420
- "s3_bucket_path"
34213421
- "s3_bucket_region"
3422-
- "access_key_id"
3423-
- "secret_access_key"
34243422
- "format"
34253423
additionalProperties: false
34263424
properties:
@@ -3478,14 +3476,16 @@
34783476
access_key_id:
34793477
type: "string"
34803478
description: "The access key id to access the S3 bucket. Airbyte requires\
3481-
\ Read and Write permissions to the given bucket."
3479+
\ Read and Write permissions to the given bucket, if not set, Airbyte\
3480+
\ will rely on Instance Profile."
34823481
title: "S3 Key Id"
34833482
airbyte_secret: true
34843483
examples:
34853484
- "A012345678910EXAMPLE"
34863485
secret_access_key:
34873486
type: "string"
3488-
description: "The corresponding secret to the access key id."
3487+
description: "The corresponding secret to the access key id, if S3 Key Id\
3488+
\ is set, then S3 Access Key must also be provided"
34893489
title: "S3 Access Key"
34903490
airbyte_secret: true
34913491
examples:

airbyte-integrations/connectors/destination-s3/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ ENV APPLICATION destination-s3
1616

1717
COPY --from=build /airbyte /airbyte
1818

19-
LABEL io.airbyte.version=0.2.4
19+
LABEL io.airbyte.version=0.2.5
2020
LABEL io.airbyte.name=airbyte/destination-s3

airbyte-integrations/connectors/destination-s3/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ As a community contributor, you will need access to AWS to run the integration t
88

99
- Create an S3 bucket for testing.
1010
- Get your `access_key_id` and `secret_access_key` that can read and write to the above bucket.
11+
- if you leave `access_key_id` and `secret_access_key` in blank, the authentication will rely on the instance profile authentication
1112
- Paste the bucket and key information into the config files under [`./sample_secrets`](./sample_secrets).
1213
- Rename the directory from `sample_secrets` to `secrets`.
1314
- Feel free to modify the config files with different settings in the acceptance test file (e.g. `S3CsvDestinationAcceptanceTest.java`, method `getFormatConfig`), as long as they follow the schema defined in [spec.json](src/main/resources/spec.json).

airbyte-integrations/connectors/destination-s3/src/main/java/io/airbyte/integrations/destination/s3/S3DestinationConfig.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package io.airbyte.integrations.destination.s3;
66

7+
import com.amazonaws.auth.InstanceProfileCredentialsProvider;
78
import com.amazonaws.ClientConfiguration;
89
import com.amazonaws.auth.AWSCredentials;
910
import com.amazonaws.auth.AWSStaticCredentialsProvider;
@@ -87,8 +88,8 @@ public static S3DestinationConfig getS3DestinationConfig(final JsonNode config)
8788
config.get("s3_bucket_name").asText(),
8889
bucketPath,
8990
config.get("s3_bucket_region").asText(),
90-
config.get("access_key_id").asText(),
91-
config.get("secret_access_key").asText(),
91+
config.get("access_key_id") == null ? "" : config.get("access_key_id").asText(),
92+
config.get("secret_access_key") == null ? "" : config.get("secret_access_key").asText(),
9293
partSize,
9394
format);
9495
}
@@ -128,7 +129,18 @@ public S3FormatConfig getFormatConfig() {
128129
public AmazonS3 getS3Client() {
129130
final AWSCredentials awsCreds = new BasicAWSCredentials(accessKeyId, secretAccessKey);
130131

131-
if (endpoint == null || endpoint.isEmpty()) {
132+
if (accessKeyId.isEmpty() && !secretAccessKey.isEmpty()
133+
|| !accessKeyId.isEmpty() && secretAccessKey.isEmpty()) {
134+
throw new RuntimeException("Either both accessKeyId and secretAccessKey should be provided, or neither");
135+
}
136+
137+
if (accessKeyId.isEmpty() && secretAccessKey.isEmpty()) {
138+
return AmazonS3ClientBuilder.standard()
139+
.withCredentials(new InstanceProfileCredentialsProvider(false))
140+
.build();
141+
}
142+
143+
else if (endpoint == null || endpoint.isEmpty()) {
132144
return AmazonS3ClientBuilder.standard()
133145
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
134146
.withRegion(bucketRegion)

airbyte-integrations/connectors/destination-s3/src/main/resources/spec.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
"s3_bucket_name",
1313
"s3_bucket_path",
1414
"s3_bucket_region",
15-
"access_key_id",
16-
"secret_access_key",
1715
"format"
1816
],
1917
"additionalProperties": false,
@@ -72,14 +70,14 @@
7270
},
7371
"access_key_id": {
7472
"type": "string",
75-
"description": "The access key id to access the S3 bucket. Airbyte requires Read and Write permissions to the given bucket.",
73+
"description": "The access key id to access the S3 bucket. Airbyte requires Read and Write permissions to the given bucket, if not set, Airbyte will rely on Instance Profile.",
7674
"title": "S3 Key Id",
7775
"airbyte_secret": true,
7876
"examples": ["A012345678910EXAMPLE"]
7977
},
8078
"secret_access_key": {
8179
"type": "string",
82-
"description": "The corresponding secret to the access key id.",
80+
"description": "The corresponding secret to the access key id, if S3 Key Id is set, then S3 Access Key must also be provided",
8381
"title": "S3 Access Key",
8482
"airbyte_secret": true,
8583
"examples": ["a012345678910ABCDEFGH/AbCdEfGhEXAMPLEKEY"]

docs/integrations/destinations/s3.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Under the hood, an Airbyte data stream in Json schema is first converted to an A
199199
#### Requirements
200200

201201
1. Allow connections from Airbyte server to your AWS S3/ Minio S3 cluster \(if they exist in separate VPCs\).
202-
2. An S3 bucket with credentials.
202+
2. An S3 bucket with credentials or an instanceprofile with read/write permissions configured for the host (ec2, eks).
203203

204204
#### Setup Guide
205205

@@ -211,18 +211,22 @@ Under the hood, an Airbyte data stream in Json schema is first converted to an A
211211
* **S3 Bucket Region**
212212
* **Access Key Id**
213213
* See [this](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys) on how to generate an access key.
214+
* See [this](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) on how to create a instanceprofile.
214215
* We recommend creating an Airbyte-specific user. This user will require [read and write permissions](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_s3_rw-bucket.html) to objects in the staging bucket.
216+
* If the Access Key and Secret Access Key are not provided, the authentication will rely on the instanceprofile.
215217
* **Secret Access Key**
216218
* Corresponding key to the above key id.
217219
* Make sure your S3 bucket is accessible from the machine running Airbyte.
218220
* This depends on your networking setup.
219221
* You can check AWS S3 documentation with a tutorial on how to properly configure your S3's access [here](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-overview.html).
222+
* If you will use instance profile authentication, make sure the role has permission to read/write on the bucket.
220223
* The easiest way to verify if Airbyte is able to connect to your S3 bucket is via the check connection tool in the UI.
221224

222225
## CHANGELOG
223226

224227
| Version | Date | Pull Request | Subject |
225228
|:--------| :--- | :--- | :--- |
229+
| 0.2.5 | 2022-01-13 | [\#9399](https://github.com/airbytehq/airbyte/pull/9399) | Use instance profile authentication if credentials are not provided |
226230
| 0.2.4 | 2022-01-12 | [\#9415](https://github.com/airbytehq/airbyte/pull/9415) | BigQuery Destination : Fix GCS processing of Facebook data |
227231
| 0.2.3 | 2022-01-11 | [\#9367](https://github.com/airbytehq/airbyte/pull/9367) | Avro & Parquet: support array field with unknown item type; default any improperly typed field to string. |
228232
| 0.2.2 | 2021-12-21 | [\#8574](https://github.com/airbytehq/airbyte/pull/8574) | Added namespace to Avro and Parquet record types |

0 commit comments

Comments
 (0)