embulk-output-redshift 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/classpath/{embulk-output-jdbc-0.8.5.jar → embulk-output-jdbc-0.8.6.jar} +0 -0
- data/classpath/{embulk-output-postgresql-0.8.5.jar → embulk-output-postgresql-0.8.6.jar} +0 -0
- data/classpath/embulk-output-redshift-0.8.6.jar +0 -0
- data/src/main/java/org/embulk/output/RedshiftOutputPlugin.java +9 -1
- data/src/main/java/org/embulk/output/redshift/RedshiftCopyBatchInsert.java +30 -8
- metadata +5 -5
- data/classpath/embulk-output-redshift-0.8.5.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b6636ae2a50de2f8889c15227a842a2712261f8
|
4
|
+
data.tar.gz: bb5ce05600900bea03ad46e00825aa7cdf088390
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1056dc021dd92ab4486ed4d065607e910fdb551b9a10e018cb14cd65f3b56ea84e246aeeee7fd5d58eec7474a9f61762f785da51a40e7f1c2c70b35b01e70661
|
7
|
+
data.tar.gz: e13333d0458a8021a92248bb4fad097f1e5c391061fad94c9d0beb4df2b3d88c15468562f2e8e07988b38fb48be5cc4d76571b5d8f932c38b424bd3266e9f1f8
|
data/README.md
CHANGED
@@ -74,6 +74,8 @@ Redshift output plugin for Embulk loads records to Redshift.
|
|
74
74
|
- **s3_bucket**: S3 bucket name for temporary files
|
75
75
|
- **s3_key_prefix**: S3 key prefix for temporary files (string, default: "")
|
76
76
|
- **delete_s3_temp_file**: whether to delete temporary files uploaded on S3 (boolean, default: true)
|
77
|
+
- **copy_iam_role_name**: IAM Role for COPY credential(https://docs.aws.amazon.com/redshift/latest/dg/copy-usage_notes-access-permissions.html), if this is set, IAM Role is used instead of aws access key and aws secret access key(string, optional)
|
78
|
+
- **copy_aws_account_id**: IAM Role's account ID for multi account COPY. If this is set, the ID is used instead of authenticated user's account ID. This is enabled only if copy_iam_role_name is set.(string, optional)
|
77
79
|
- **options**: extra connection properties (hash, default: {})
|
78
80
|
- **retry_limit**: max retry count for database operations (integer, default: 12). When intermediate table to create already created by another process, this plugin will retry with another table name to avoid collision.
|
79
81
|
- **retry_wait**: initial retry wait time in milliseconds (integer, default: 1000 (1 second))
|
Binary file
|
Binary file
|
Binary file
|
@@ -83,6 +83,14 @@ public class RedshiftOutputPlugin
|
|
83
83
|
@Config("ssl")
|
84
84
|
@ConfigDefault("\"disable\"")
|
85
85
|
public Ssl getSsl();
|
86
|
+
|
87
|
+
@Config("copy_iam_role_name")
|
88
|
+
@ConfigDefault("null")
|
89
|
+
public Optional<String> getCopyIamRoleName();
|
90
|
+
|
91
|
+
@Config("copy_aws_account_id")
|
92
|
+
@ConfigDefault("null")
|
93
|
+
public Optional<String> getCopyAwsAccountId();
|
86
94
|
}
|
87
95
|
|
88
96
|
@Override
|
@@ -193,6 +201,6 @@ public class RedshiftOutputPlugin
|
|
193
201
|
RedshiftPluginTask t = (RedshiftPluginTask) task;
|
194
202
|
setAWSCredentialsBackwardCompatibility(t);
|
195
203
|
return new RedshiftCopyBatchInsert(getConnector(task, true),
|
196
|
-
getAWSCredentialsProvider(t), t.getS3Bucket(), t.getS3KeyPrefix(), t.getIamUserName(), t.getDeleteS3TempFile());
|
204
|
+
getAWSCredentialsProvider(t), t.getS3Bucket(), t.getS3KeyPrefix(), t.getIamUserName(), t.getDeleteS3TempFile(), t.getCopyIamRoleName().orNull(), t.getCopyAwsAccountId().orNull());
|
197
205
|
}
|
198
206
|
}
|
@@ -36,6 +36,8 @@ import com.amazonaws.services.s3.AmazonS3Client;
|
|
36
36
|
import com.amazonaws.services.s3.model.Region;
|
37
37
|
import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient;
|
38
38
|
import com.amazonaws.services.securitytoken.model.Credentials;
|
39
|
+
import com.amazonaws.services.securitytoken.model.GetCallerIdentityRequest;
|
40
|
+
import com.amazonaws.services.securitytoken.model.GetCallerIdentityResult;
|
39
41
|
import com.amazonaws.services.securitytoken.model.GetFederationTokenRequest;
|
40
42
|
import com.amazonaws.services.securitytoken.model.GetFederationTokenResult;
|
41
43
|
|
@@ -53,6 +55,7 @@ public class RedshiftCopyBatchInsert
|
|
53
55
|
private final String s3RegionName;
|
54
56
|
private final AWSSecurityTokenServiceClient sts;
|
55
57
|
private final ExecutorService executorService;
|
58
|
+
private final String copyIamRoleARN;
|
56
59
|
|
57
60
|
private RedshiftOutputConnection connection = null;
|
58
61
|
private String copySqlBeforeFrom = null;
|
@@ -64,7 +67,7 @@ public class RedshiftCopyBatchInsert
|
|
64
67
|
|
65
68
|
public RedshiftCopyBatchInsert(JdbcOutputConnector connector,
|
66
69
|
AWSCredentialsProvider credentialsProvider, String s3BucketName, String s3KeyPrefix,
|
67
|
-
String iamReaderUserName, boolean deleteS3TempFile) throws IOException, SQLException
|
70
|
+
String iamReaderUserName, boolean deleteS3TempFile, String copyIamRoleName, String copyAwsAccountId) throws IOException, SQLException
|
68
71
|
{
|
69
72
|
super();
|
70
73
|
this.connector = connector;
|
@@ -94,6 +97,20 @@ public class RedshiftCopyBatchInsert
|
|
94
97
|
+ " IAM user needs \"s3:GetBucketLocation\" permission if Redshift region and S3 region are different.");
|
95
98
|
}
|
96
99
|
this.s3RegionName = s3RegionName;
|
100
|
+
|
101
|
+
if (copyIamRoleName != null) {
|
102
|
+
String accountId = null;
|
103
|
+
if (copyAwsAccountId != null) {
|
104
|
+
accountId = copyAwsAccountId;
|
105
|
+
} else {
|
106
|
+
GetCallerIdentityRequest request = new GetCallerIdentityRequest();
|
107
|
+
GetCallerIdentityResult response = this.sts.getCallerIdentity(request);
|
108
|
+
accountId = response.getAccount();
|
109
|
+
}
|
110
|
+
this.copyIamRoleARN = "arn:aws:iam::" + accountId + ":role/" + copyIamRoleName;
|
111
|
+
} else {
|
112
|
+
this.copyIamRoleARN = null;
|
113
|
+
}
|
97
114
|
}
|
98
115
|
|
99
116
|
@Override
|
@@ -305,13 +322,18 @@ public class RedshiftCopyBatchInsert
|
|
305
322
|
sb.append("/");
|
306
323
|
sb.append(s3KeyName);
|
307
324
|
sb.append("' CREDENTIALS '");
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
sb.append(
|
314
|
-
sb.append(
|
325
|
+
if (copyIamRoleARN != null) {
|
326
|
+
sb.append("aws_iam_role=");
|
327
|
+
sb.append(copyIamRoleARN);
|
328
|
+
} else {
|
329
|
+
sb.append("aws_access_key_id=");
|
330
|
+
sb.append(creds.getAWSAccessKeyId());
|
331
|
+
sb.append(";aws_secret_access_key=");
|
332
|
+
sb.append(creds.getAWSSecretKey());
|
333
|
+
if (creds.getSessionToken() != null) {
|
334
|
+
sb.append(";token=");
|
335
|
+
sb.append(creds.getSessionToken());
|
336
|
+
}
|
315
337
|
}
|
316
338
|
sb.append("' ");
|
317
339
|
if (s3RegionName != null) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-redshift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -25,9 +25,9 @@ files:
|
|
25
25
|
- classpath/aws-java-sdk-sts-1.11.523.jar
|
26
26
|
- classpath/commons-codec-1.10.jar
|
27
27
|
- classpath/commons-logging-1.2.jar
|
28
|
-
- classpath/embulk-output-jdbc-0.8.
|
29
|
-
- classpath/embulk-output-postgresql-0.8.
|
30
|
-
- classpath/embulk-output-redshift-0.8.
|
28
|
+
- classpath/embulk-output-jdbc-0.8.6.jar
|
29
|
+
- classpath/embulk-output-postgresql-0.8.6.jar
|
30
|
+
- classpath/embulk-output-redshift-0.8.6.jar
|
31
31
|
- classpath/embulk-util-aws-credentials-0.2.21.jar
|
32
32
|
- classpath/httpclient-4.5.5.jar
|
33
33
|
- classpath/httpcore-4.4.9.jar
|
Binary file
|