embulk-output-redshift 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +77 -6
- data/build.gradle +1 -0
- data/classpath/embulk-core-0.8.9.jar +0 -0
- data/classpath/{embulk-output-jdbc-0.7.1.jar → embulk-output-jdbc-0.7.2.jar} +0 -0
- data/classpath/{embulk-output-postgresql-0.7.1.jar → embulk-output-postgresql-0.7.2.jar} +0 -0
- data/classpath/embulk-output-redshift-0.7.2.jar +0 -0
- data/classpath/embulk-util-aws-credentials-0.2.8.jar +0 -0
- data/classpath/jcl-over-slf4j-1.7.12.jar +0 -0
- data/classpath/msgpack-core-0.8.7.jar +0 -0
- data/src/main/java/org/embulk/output/RedshiftOutputPlugin.java +23 -18
- data/src/main/java/org/embulk/output/redshift/RedshiftCopyBatchInsert.java +4 -0
- metadata +9 -5
- data/classpath/embulk-output-redshift-0.7.1.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: f328186471e1367510fec732ad9747551820ac5a
|
4
|
+
data.tar.gz: 7627fe90dd396daf16b047f85f5d2084a5a91944
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c8671c622847596ce3b703b32a6e4c0a1a5d28c8f6de3c941293cbcd9a4f2faba199f2a320cc3f6110b86b9651d0c6524d5eae5c7f03accc49db3d4ed89360f
|
7
|
+
data.tar.gz: bb2d580607179e5ab0cdc402af4fc1e1ba11d463a905bf11bf61253de1d2d224e79029fda08fc0609773a3dfc3eaceb3b2a8f000f788bea2cd4c3f7fcae82499
|
data/README.md
CHANGED
@@ -18,8 +18,47 @@ Redshift output plugin for Embulk loads records to Redshift.
|
|
18
18
|
- **database**: destination database name (string, required)
|
19
19
|
- **schema**: destination schema name (string, default: "public")
|
20
20
|
- **table**: destination table name (string, required)
|
21
|
-
- **access_key_id**:
|
22
|
-
- **secret_access_key**:
|
21
|
+
- **access_key_id**: deprecated. `aws_access_key_id` should be used (see "basic" in `aws_auth_method`).
|
22
|
+
- **secret_access_key**: deprecated. `aws_secret_access_key` should be used (see "basic" in `aws_auth_method`).
|
23
|
+
- **aws_auth_method**: name of mechanism to authenticate requests ("basic", "env", "instance", "profile", "properties", "anonymous", or "session". default: "basic")
|
24
|
+
|
25
|
+
- "basic": uses `access_key_id` and `secret_access_key` to authenticate.
|
26
|
+
|
27
|
+
- **aws_access_key_id**: AWS access key ID (string, required)
|
28
|
+
|
29
|
+
- **aws_secret_access_key**: AWS secret access key (string, required)
|
30
|
+
|
31
|
+
- "env": uses `AWS_ACCESS_KEY_ID` (or `AWS_ACCESS_KEY`) and `AWS_SECRET_KEY` (or `AWS_SECRET_ACCESS_KEY`) environment variables.
|
32
|
+
|
33
|
+
- "instance": uses EC2 instance profile.
|
34
|
+
|
35
|
+
- "profile": uses credentials written in a file. Format of the file is as following, where `[...]` is a name of profile.
|
36
|
+
|
37
|
+
- **aws_profile_file**: path to a profiles file. (string, default: given by `AWS_CREDENTIAL_PROFILES_FILE` environment varialbe, or ~/.aws/credentials).
|
38
|
+
|
39
|
+
- **aws_profile_name**: name of a profile. (string, default: `"default"`)
|
40
|
+
|
41
|
+
```
|
42
|
+
[default]
|
43
|
+
aws_access_key_id=YOUR_ACCESS_KEY_ID
|
44
|
+
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
|
45
|
+
|
46
|
+
[profile2]
|
47
|
+
...
|
48
|
+
```
|
49
|
+
|
50
|
+
- "properties": uses `aws.accessKeyId` and `aws.secretKey` Java system properties.
|
51
|
+
|
52
|
+
- "anonymous": uses anonymous access. This authentication method can access only public files.
|
53
|
+
|
54
|
+
- "session": uses temporary-generated `access_key_id`, `secret_access_key` and `session_token`.
|
55
|
+
|
56
|
+
- **aws_access_key_id**: AWS access key ID (string, required)
|
57
|
+
|
58
|
+
- **aws_secret_access_key**: AWS secret access key (string, required)
|
59
|
+
|
60
|
+
- **aws_session_token**: session token (string, required)
|
61
|
+
|
23
62
|
- **iam_user_name**: IAM user name for uploading temporary files to S3. The user should have permissions of `s3:GetObject`, `s3:PutObject`, `s3:DeleteObject`, `s3:ListBucket` and `sts:GetFederationToken`. And furthermore, the user should have permission of `s3:GetBucketLocation` if Redshift region and S3 bucket region are different. (string, default: "", but we strongly recommend that you use IAM user for security reasons. see below.)
|
24
63
|
- **s3_bucket**: S3 bucket name for temporary files
|
25
64
|
- **s3_key_prefix**: S3 key prefix for temporary files (string, default:"")
|
@@ -89,8 +128,8 @@ out:
|
|
89
128
|
password: ""
|
90
129
|
database: my_database
|
91
130
|
table: my_table
|
92
|
-
|
93
|
-
|
131
|
+
aws_access_key_id: ABCXYZ123ABCXYZ123
|
132
|
+
aws_secret_access_key: AbCxYz123aBcXyZ123
|
94
133
|
iam_user_name: my-s3-read-only
|
95
134
|
s3_bucket: my-redshift-transfer-bucket
|
96
135
|
s3_key_prefix: temp/redshift
|
@@ -108,8 +147,8 @@ out:
|
|
108
147
|
password: ""
|
109
148
|
database: my_database
|
110
149
|
table: my_table
|
111
|
-
|
112
|
-
|
150
|
+
aws_access_key_id: ABCXYZ123ABCXYZ123
|
151
|
+
aws_secret_access_key: AbCxYz123aBcXyZ123
|
113
152
|
iam_user_name: my-s3-read-only
|
114
153
|
s3_bucket: my-redshift-transfer-bucket
|
115
154
|
s3_key_prefix: temp/redshift
|
@@ -122,6 +161,38 @@ out:
|
|
122
161
|
my_col_5: {type: 'DECIMAL(18,9)', value_type: pass}
|
123
162
|
```
|
124
163
|
|
164
|
+
To use IAM Role:
|
165
|
+
|
166
|
+
```yaml
|
167
|
+
out:
|
168
|
+
type: redshift
|
169
|
+
host: myinstance.us-west-2.redshift.amazonaws.com
|
170
|
+
user: pg
|
171
|
+
password: ""
|
172
|
+
database: my_database
|
173
|
+
table: my_table
|
174
|
+
s3_bucket: my-redshift-transfer-bucket
|
175
|
+
s3_key_prefix: temp/redshift
|
176
|
+
mode: insert
|
177
|
+
aws_auth_method: instance
|
178
|
+
```
|
179
|
+
|
180
|
+
To use AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables:
|
181
|
+
|
182
|
+
```yaml
|
183
|
+
out:
|
184
|
+
type: redshift
|
185
|
+
host: myinstance.us-west-2.redshift.amazonaws.com
|
186
|
+
user: pg
|
187
|
+
password: ""
|
188
|
+
database: my_database
|
189
|
+
table: my_table
|
190
|
+
s3_bucket: my-redshift-transfer-bucket
|
191
|
+
s3_key_prefix: temp/redshift
|
192
|
+
mode: insert
|
193
|
+
aws_auth_method: env
|
194
|
+
```
|
195
|
+
|
125
196
|
### Build
|
126
197
|
|
127
198
|
```
|
data/build.gradle
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,6 +1,5 @@
|
|
1
1
|
package org.embulk.output;
|
2
2
|
|
3
|
-
import java.util.List;
|
4
3
|
import java.util.Properties;
|
5
4
|
import java.io.IOException;
|
6
5
|
import java.sql.SQLException;
|
@@ -9,10 +8,10 @@ import org.embulk.output.jdbc.MergeConfig;
|
|
9
8
|
import org.slf4j.Logger;
|
10
9
|
import com.google.common.base.Optional;
|
11
10
|
import com.google.common.collect.ImmutableSet;
|
12
|
-
import com.amazonaws.auth.AWSCredentials;
|
13
11
|
import com.amazonaws.auth.AWSCredentialsProvider;
|
14
|
-
import com.amazonaws.auth.BasicAWSCredentials;
|
15
12
|
import org.embulk.spi.Exec;
|
13
|
+
import org.embulk.util.aws.credentials.AwsCredentials;
|
14
|
+
import org.embulk.util.aws.credentials.AwsCredentialsTaskWithPrefix;
|
16
15
|
import org.embulk.config.Config;
|
17
16
|
import org.embulk.config.ConfigDefault;
|
18
17
|
import org.embulk.output.jdbc.AbstractJdbcOutputPlugin;
|
@@ -26,7 +25,7 @@ public class RedshiftOutputPlugin
|
|
26
25
|
{
|
27
26
|
private final Logger logger = Exec.getLogger(RedshiftOutputPlugin.class);
|
28
27
|
|
29
|
-
public interface RedshiftPluginTask extends PluginTask
|
28
|
+
public interface RedshiftPluginTask extends AwsCredentialsTaskWithPrefix, PluginTask
|
30
29
|
{
|
31
30
|
@Config("host")
|
32
31
|
public String getHost();
|
@@ -49,11 +48,15 @@ public class RedshiftOutputPlugin
|
|
49
48
|
@ConfigDefault("\"public\"")
|
50
49
|
public String getSchema();
|
51
50
|
|
51
|
+
// for backward compatibility
|
52
52
|
@Config("access_key_id")
|
53
|
-
|
53
|
+
@ConfigDefault("null")
|
54
|
+
Optional<String> getOldAccessKeyId();
|
54
55
|
|
56
|
+
// for backward compatibility
|
55
57
|
@Config("secret_access_key")
|
56
|
-
|
58
|
+
@ConfigDefault("null")
|
59
|
+
Optional<String> getOldSecretAccessKey();
|
57
60
|
|
58
61
|
@Config("iam_user_name")
|
59
62
|
@ConfigDefault("\"\"")
|
@@ -132,20 +135,21 @@ public class RedshiftOutputPlugin
|
|
132
135
|
|
133
136
|
private static AWSCredentialsProvider getAWSCredentialsProvider(RedshiftPluginTask task)
|
134
137
|
{
|
135
|
-
|
136
|
-
|
137
|
-
return new AWSCredentialsProvider() {
|
138
|
-
@Override
|
139
|
-
public AWSCredentials getCredentials()
|
140
|
-
{
|
141
|
-
return creds;
|
142
|
-
}
|
138
|
+
return AwsCredentials.getAWSCredentialsProvider(task);
|
139
|
+
}
|
143
140
|
|
144
|
-
|
145
|
-
|
146
|
-
|
141
|
+
private void setAWSCredentialsBackwardCompatibility(RedshiftPluginTask t)
|
142
|
+
{
|
143
|
+
if ("basic".equals(t.getAuthMethod())) {
|
144
|
+
if (t.getOldAccessKeyId().isPresent() && !t.getAccessKeyId().isPresent()) {
|
145
|
+
logger.warn("'access_key_id' is deprecated. Please use 'aws_access_key_id'.");
|
146
|
+
t.setAccessKeyId(t.getOldAccessKeyId());
|
147
147
|
}
|
148
|
-
|
148
|
+
if (t.getOldSecretAccessKey().isPresent() && !t.getSecretAccessKey().isPresent()) {
|
149
|
+
logger.warn("'secret_access_key' is deprecated. Please use 'aws_secret_access_key'.");
|
150
|
+
t.setSecretAccessKey(t.getOldSecretAccessKey());
|
151
|
+
}
|
152
|
+
}
|
149
153
|
}
|
150
154
|
|
151
155
|
@Override
|
@@ -155,6 +159,7 @@ public class RedshiftOutputPlugin
|
|
155
159
|
throw new UnsupportedOperationException("Redshift output plugin doesn't support 'merge_direct' mode. Use 'merge' mode instead.");
|
156
160
|
}
|
157
161
|
RedshiftPluginTask t = (RedshiftPluginTask) task;
|
162
|
+
setAWSCredentialsBackwardCompatibility(t);
|
158
163
|
return new RedshiftCopyBatchInsert(getConnector(task, true),
|
159
164
|
getAWSCredentialsProvider(t), t.getS3Bucket(), t.getS3KeyPrefix(), t.getIamUserName());
|
160
165
|
}
|
@@ -194,6 +194,10 @@ public class RedshiftCopyBatchInsert
|
|
194
194
|
c.getSecretAccessKey(),
|
195
195
|
c.getSessionToken());
|
196
196
|
} else {
|
197
|
+
if (credentialsProvider.getCredentials() instanceof BasicSessionCredentials) {
|
198
|
+
BasicSessionCredentials credentials = (BasicSessionCredentials) credentialsProvider.getCredentials();
|
199
|
+
return credentials;
|
200
|
+
}
|
197
201
|
return new BasicSessionCredentials(credentialsProvider.getCredentials().getAWSAccessKeyId(),
|
198
202
|
credentialsProvider.getCredentials().getAWSSecretKey(), null);
|
199
203
|
}
|
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.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -25,11 +25,15 @@ files:
|
|
25
25
|
- classpath/aws-java-sdk-sts-1.10.33.jar
|
26
26
|
- classpath/commons-codec-1.6.jar
|
27
27
|
- classpath/commons-logging-1.1.3.jar
|
28
|
-
- classpath/embulk-
|
29
|
-
- classpath/embulk-output-
|
30
|
-
- classpath/embulk-output-
|
28
|
+
- classpath/embulk-core-0.8.9.jar
|
29
|
+
- classpath/embulk-output-jdbc-0.7.2.jar
|
30
|
+
- classpath/embulk-output-postgresql-0.7.2.jar
|
31
|
+
- classpath/embulk-output-redshift-0.7.2.jar
|
32
|
+
- classpath/embulk-util-aws-credentials-0.2.8.jar
|
31
33
|
- classpath/httpclient-4.3.6.jar
|
32
34
|
- classpath/httpcore-4.3.3.jar
|
35
|
+
- classpath/jcl-over-slf4j-1.7.12.jar
|
36
|
+
- classpath/msgpack-core-0.8.7.jar
|
33
37
|
- classpath/postgresql-9.4-1205-jdbc41.jar
|
34
38
|
- lib/embulk/output/redshift.rb
|
35
39
|
- src/main/java/org/embulk/output/RedshiftOutputPlugin.java
|
Binary file
|