Skip to content

Commit bb19e79

Browse files
authored
Merge pull request #82 from civitaspo/develop
0.4.0
2 parents ee61b71 + 433afe5 commit bb19e79

File tree

8 files changed

+53
-19
lines changed

8 files changed

+53
-19
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: https://www.paypal.me/civitaspo

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.4.0 (2019-10-20)
2+
==================
3+
* [Enhancement] Update dependencies: aws-sdk 1.11.587 -> 1.11.653, digdag 0.9.37 -> 0.9.39
4+
* [Fix] Fix README: athena.query> preview option is false by default
5+
* [New feature] Support auth_method: web_identity_token
6+
17
0.3.2 (2019-08-06)
28
==================
39

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _export:
1515
repositories:
1616
- https://jitpack.io
1717
dependencies:
18-
- pro.civitaspo:digdag-operator-athena:0.3.2
18+
- pro.civitaspo:digdag-operator-athena:0.4.0
1919
athena:
2020
auth_method: profile
2121

@@ -26,10 +26,9 @@ _export:
2626
echo>: ${athena.last_query}
2727

2828
+stap3:
29-
athena.ctas>:
30-
select_query: template.sql
29+
athena.ctas>: template.sql
3130
table: hoge
32-
output: s3://mybucket/prefix/
31+
location: s3://mybucket/prefix/
3332
```
3433
3534
See [examples](./example/example.dig) for more cases.
@@ -51,7 +50,10 @@ Define the below options on properties (which is indicated by `-c`, `--config`).
5150
- **athena.allow_auth_method_instance**: Indicates whether users can use **auth_method** `"instance"` (boolean, default: `false`)
5251
- **athena.allow_auth_method_profile**: Indicates whether users can use **auth_method** `"profile"` (boolean, default: `false`)
5352
- **athena.allow_auth_method_properties**: Indicates whether users can use **auth_method** `"properties"` (boolean, default: `false`)
53+
- **athena.allow_auth_method_web_identity_token**: Indicates whether users can use **auth_method** `"web_identity_token"` (boolean, default: `false`)
5454
- **athena.assume_role_timeout_duration**: Maximum duration which server administer allows when users assume **role_arn**. (`DurationParam`, default: `1h`)
55+
- **athena.default_web_identity_token_file**: Path to a web identity token file. (string, optional)
56+
- **athena.default_web_identity_role_arn**: AWS Role when using a web identity token. (string, optional)
5557

5658
### Secrets
5759

@@ -78,6 +80,9 @@ Define the below options on properties (which is indicated by `-c`, `--config`).
7880
- `"properties"`: uses aws.accessKeyId and aws.secretKey Java system properties.
7981
- `"anonymous"`: uses anonymous access. This auth method can access only public files.
8082
- `"session"`: uses temporary-generated access_key_id, secret_access_key and session_token.
83+
- `"web_identity_token"`: uses web identity token.
84+
- **web_identity_token_file**: path to a web identity token file. (string, default: given by **athena.default_web_identity_token_file**)
85+
- **web_identity_role_arn**: aws role arn when using a web identity token. (string, default: given by **athena.default_web_identity_role_arn**)
8186
- **use_http_proxy**: Indicate whether using when accessing AWS via http proxy. (boolean, default: `false`)
8287
- **region**: The AWS region to use for Athena service. (string, optional)
8388
- **endpoint**: The Amazon Athena endpoint address to use. (string, optional)
@@ -171,7 +176,7 @@ Nothing
171176
- **database**: The name of the database. (string, optional)
172177
- **workgroup**: The name of the workgroup in which the query is being started. (string, optional)
173178
- **timeout**: Specify timeout period. (`DurationParam`, default: `"10m"`)
174-
- **preview**: Call `athena.preview>` operator after run `athena.query>`. (boolean, default: `true`)
179+
- **preview**: Call `athena.preview>` operator after run `athena.query>`. (boolean, default: `false`)
175180

176181
### Output Parameters
177182

@@ -218,7 +223,6 @@ Nothing
218223
- **database**: The database name for query execution context. (string, optional)
219224
- **table**: The table name for the new table (string, default: `digdag_athena_ctas_${session_uuid.replaceAll("-", "")}_${random}`)
220225
- **workgroup**: The name of the workgroup in which the query is being started. (string, optional)
221-
- **output**: [**Deprecated**] Use **location** option instead.
222226
- **location**: Output location for data created by CTAS (string, default: `"s3://aws-athena-query-results-${AWS_ACCOUNT_ID}-<AWS_REGION>/Unsaved/${YEAR}/${MONTH}/${DAY}/${athena_query_id}/"`)
223227
- **format**: The data format for the CTAS query results, such as `"orc"`, `"parquet"`, `"avro"`, `"json"`, or `"textfile"`. (string, default: `"parquet"`)
224228
- **compression**: The compression type to use for `"orc"` or `"parquet"`. (string, default: `"snappy"`)

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ plugins {
55
}
66

77
group = 'pro.civitaspo'
8-
version = '0.3.2'
8+
version = '0.4.0'
99

10-
def digdagVersion = '0.9.37'
11-
def awsSdkVersion = "1.11.587"
10+
def digdagVersion = '0.9.39'
11+
def awsSdkVersion = "1.11.653"
1212
def scalaSemanticVersion = "2.13.0"
1313
def depScalaVersion = "2.13"
1414

example/example.dig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ _export:
44
- file://${repos}
55
# - https://jitpack.io
66
dependencies:
7-
- pro.civitaspo:digdag-operator-athena:0.3.2
7+
- pro.civitaspo:digdag-operator-athena:0.4.0
88
athena:
99
auth_method: profile
1010
value: 5

src/main/scala/pro/civitaspo/digdag/plugin/athena/AbstractAthenaOperator.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@ abstract class AbstractAthenaOperator(operatorName: String,
3939
isAllowedAuthMethodInstance = systemConfig.get("athena.allow_auth_method_instance", classOf[Boolean], false),
4040
isAllowedAuthMethodProfile = systemConfig.get("athena.allow_auth_method_profile", classOf[Boolean], false),
4141
isAllowedAuthMethodProperties = systemConfig.get("athena.allow_auth_method_properties", classOf[Boolean], false),
42+
isAllowedAuthMethodWebIdentityToken = systemConfig.get("athena.allow_auth_method_web_identity_token", classOf[Boolean], false),
4243
assumeRoleTimeoutDuration = systemConfig.get("athena.assume_role_timeout_duration", classOf[DurationParam], DurationParam.parse("1h")),
4344
accessKeyId = secrets.getSecretOptional("access_key_id"),
4445
secretAccessKey = secrets.getSecretOptional("secret_access_key"),
4546
sessionToken = secrets.getSecretOptional("session_token"),
4647
roleArn = secrets.getSecretOptional("role_arn"),
4748
roleSessionName = secrets.getSecretOptional("role_session_name").or(s"digdag-athena-$sessionUuid"),
49+
defaultWebIdentityTokenFile = systemConfig.getOptional("athena.default_web_identity_token_file", classOf[String]),
50+
webIdentityTokenFile = params.getOptional("web_identity_token_file", classOf[String]),
51+
defaultWebIdentityRoleArn = systemConfig.getOptional("athena.default_web_identity_role_arn", classOf[String]),
52+
webIdentityRoleArn = params.getOptional("web_identity_role_arn", classOf[String]),
4853
httpProxy = secrets.getSecrets("http_proxy"),
4954
authMethod = params.get("auth_method", classOf[String], "basic"),
5055
profileName = params.get("profile_name", classOf[String], "default"),

src/main/scala/pro/civitaspo/digdag/plugin/athena/aws/Aws.scala

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package pro.civitaspo.digdag.plugin.athena.aws
22

33

44
import com.amazonaws.{ClientConfiguration, Protocol}
5-
import com.amazonaws.auth.{AnonymousAWSCredentials, AWSCredentials, AWSCredentialsProvider, AWSStaticCredentialsProvider, BasicAWSCredentials, BasicSessionCredentials, EC2ContainerCredentialsProviderWrapper, EnvironmentVariableCredentialsProvider, SystemPropertiesCredentialsProvider}
5+
import com.amazonaws.auth.{AnonymousAWSCredentials, AWSCredentials, AWSCredentialsProvider, AWSStaticCredentialsProvider, BasicAWSCredentials, BasicSessionCredentials, EC2ContainerCredentialsProviderWrapper, EnvironmentVariableCredentialsProvider, SystemPropertiesCredentialsProvider, WebIdentityTokenCredentialsProvider}
66
import com.amazonaws.auth.profile.{ProfileCredentialsProvider, ProfilesConfigFile}
77
import com.amazonaws.client.builder.AwsClientBuilder
88
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
@@ -78,14 +78,15 @@ case class Aws(conf: AwsConf)
7878
private def standardCredentialsProvider: AWSCredentialsProvider =
7979
{
8080
conf.authMethod match {
81-
case "basic" => basicAuthMethodAWSCredentialsProvider
82-
case "env" => envAuthMethodAWSCredentialsProvider
83-
case "instance" => instanceAuthMethodAWSCredentialsProvider
84-
case "profile" => profileAuthMethodAWSCredentialsProvider
85-
case "properties" => propertiesAuthMethodAWSCredentialsProvider
86-
case "anonymous" => anonymousAuthMethodAWSCredentialsProvider
87-
case "session" => sessionAuthMethodAWSCredentialsProvider
88-
case _ =>
81+
case "basic" => basicAuthMethodAWSCredentialsProvider
82+
case "env" => envAuthMethodAWSCredentialsProvider
83+
case "instance" => instanceAuthMethodAWSCredentialsProvider
84+
case "profile" => profileAuthMethodAWSCredentialsProvider
85+
case "properties" => propertiesAuthMethodAWSCredentialsProvider
86+
case "anonymous" => anonymousAuthMethodAWSCredentialsProvider
87+
case "session" => sessionAuthMethodAWSCredentialsProvider
88+
case "web_identity_token" => webIdentityTokenAuthMethodAWSCredentialsProvider
89+
case _ =>
8990
throw new ConfigException(
9091
s"""auth_method: "${conf.authMethod}" is not supported. available `auth_method`s are "basic", "env", "instance", "profile", "properties", "anonymous", or "session"."""
9192
)
@@ -151,6 +152,18 @@ case class Aws(conf: AwsConf)
151152
new AWSStaticCredentialsProvider(credentials)
152153
}
153154

155+
private def webIdentityTokenAuthMethodAWSCredentialsProvider: AWSCredentialsProvider =
156+
{
157+
if (!conf.isAllowedAuthMethodWebIdentityToken) throw new ConfigException(s"""auth_method: "${conf.authMethod}" is not allowed.""")
158+
if (!conf.webIdentityTokenFile.or(conf.defaultWebIdentityTokenFile).isPresent) throw new ConfigException(s"""`web_identity_token_file` or `athena.allow_auth_method_web_identity_token` (system) must be set when `auth_method` is "${conf.authMethod}".""")
159+
if (!conf.webIdentityRoleArn.or(conf.defaultWebIdentityRoleArn).isPresent) throw new ConfigException(s"""`web_identity_role_arn` or `athena.allow_auth_method_web_identity_role_arn` (system) must be set when `auth_method` is "${conf.authMethod}".""")
160+
WebIdentityTokenCredentialsProvider.builder()
161+
.webIdentityTokenFile(conf.webIdentityTokenFile.or(conf.defaultWebIdentityTokenFile).get())
162+
.roleArn(conf.webIdentityRoleArn.or(conf.defaultWebIdentityRoleArn).get())
163+
.roleSessionName(conf.roleSessionName)
164+
.build()
165+
}
166+
154167
private def clientConfiguration: ClientConfiguration =
155168
{
156169
if (!conf.useHttpProxy) return new ClientConfiguration()

src/main/scala/pro/civitaspo/digdag/plugin/athena/aws/AwsConf.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ case class AwsConf(
1010
isAllowedAuthMethodInstance: Boolean,
1111
isAllowedAuthMethodProfile: Boolean,
1212
isAllowedAuthMethodProperties: Boolean,
13+
isAllowedAuthMethodWebIdentityToken: Boolean,
1314
assumeRoleTimeoutDuration: DurationParam,
1415
accessKeyId: Optional[String],
1516
secretAccessKey: Optional[String],
@@ -20,6 +21,10 @@ case class AwsConf(
2021
authMethod: String,
2122
profileName: String,
2223
profileFile: Optional[String],
24+
defaultWebIdentityTokenFile: Optional[String],
25+
webIdentityTokenFile: Optional[String],
26+
defaultWebIdentityRoleArn: Optional[String],
27+
webIdentityRoleArn: Optional[String],
2328
useHttpProxy: Boolean,
2429
region: Optional[String],
2530
endpoint: Optional[String]

0 commit comments

Comments
 (0)