generated from kestra-io/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAbstractConnectionInterface.java
91 lines (75 loc) · 4.33 KB
/
AbstractConnectionInterface.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package io.kestra.plugin.aws;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.models.annotations.PluginProperty;
import io.kestra.core.models.property.Property;
import io.kestra.core.runners.RunContext;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.Duration;
public interface AbstractConnectionInterface {
Duration AWS_MIN_STS_ROLE_SESSION_DURATION = Duration.ofSeconds(900);
@Schema(
title = "Access Key Id in order to connect to AWS.",
description = "If no credentials are defined, we will use the [default credentials provider chain](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html) to fetch credentials."
)
Property<String> getAccessKeyId();
@Schema(
title = "Secret Key Id in order to connect to AWS.",
description = "If no credentials are defined, we will use the [default credentials provider chain](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html) to fetch credentials."
)
Property<String> getSecretKeyId();
@Schema(
title = "AWS session token, retrieved from an AWS token service, used for authenticating that this user has received temporary permissions to access a given resource.",
description = "If no credentials are defined, we will use the [default credentials provider chain](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html) to fetch credentials."
)
Property<String> getSessionToken();
@Schema(
title = "AWS STS Role.",
description = "The Amazon Resource Name (ARN) of the role to assume. If set the task will use the `StsAssumeRoleCredentialsProvider`. If no credentials are defined, we will use the [default credentials provider chain](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html) to fetch credentials."
)
Property<String> getStsRoleArn();
@Schema(
title = "AWS STS External Id.",
description = " A unique identifier that might be required when you assume a role in another account. This property is only used when an `stsRoleArn` is defined."
)
Property<String> getStsRoleExternalId();
@Schema(
title = "AWS STS Session name.",
description = "This property is only used when an `stsRoleArn` is defined."
)
Property<String> getStsRoleSessionName();
@Schema(
title = "AWS STS Session duration.",
description = "The duration of the role session (default: 15 minutes, i.e., PT15M). This property is only used when an `stsRoleArn` is defined."
)
Property<Duration> getStsRoleSessionDuration();
@Schema(
title = "The AWS STS endpoint with which the SDKClient should communicate."
)
Property<String> getStsEndpointOverride();
@Schema(
title = "AWS region with which the SDK should communicate."
)
Property<String> getRegion();
@Schema(
title = "The endpoint with which the SDK should communicate.",
description = "This property allows you to use a different S3 compatible storage backend."
)
Property<String> getEndpointOverride();
default Property<Boolean> getCompatibilityMode() {
return Property.of(false);
}
default AbstractConnection.AwsClientConfig awsClientConfig(final RunContext runContext) throws IllegalVariableEvaluationException {
return new AbstractConnection.AwsClientConfig(
runContext.render(this.getAccessKeyId()).as(String.class).orElse(null),
runContext.render(this.getSecretKeyId()).as(String.class).orElse(null),
runContext.render(this.getSessionToken()).as(String.class).orElse(null),
runContext.render(this.getStsRoleArn()).as(String.class).orElse(null),
runContext.render(this.getStsRoleExternalId()).as(String.class).orElse(null),
runContext.render(this.getStsRoleSessionName()).as(String.class).orElse(null),
runContext.render(this.getStsEndpointOverride()).as(String.class).orElse(null),
runContext.render(this.getStsRoleSessionDuration()).as(Duration.class).orElse(null),
runContext.render(this.getRegion()).as(String.class).orElse(null),
runContext.render(this.getEndpointOverride()).as(String.class).orElse(null)
);
}
}