1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */

15
16 package software.amazon.awssdk.core;
17
18 import software.amazon.awssdk.annotations.SdkProtectedApi;
19 import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
20 import software.amazon.awssdk.core.retry.RetryMode;
21 import software.amazon.awssdk.core.retry.RetryPolicy;
22 import software.amazon.awssdk.utils.SystemSetting;
23
24 /**
25  * System properties to configure the SDK runtime.
26  */

27 @SdkProtectedApi
28 public enum SdkSystemSetting implements SystemSetting {
29     /**
30      * Configure the AWS access key ID.
31      *
32      * This value will not be ignored if the {@link #AWS_SECRET_ACCESS_KEY} is not specified.
33      */

34     AWS_ACCESS_KEY_ID("aws.accessKeyId"null),
35
36     /**
37      * Configure the AWS secret access key.
38      *
39      * This value will not be ignored if the {@link #AWS_ACCESS_KEY_ID} is not specified.
40      */

41     AWS_SECRET_ACCESS_KEY("aws.secretAccessKey"null),
42
43     /**
44      * Configure the AWS session token.
45      */

46     AWS_SESSION_TOKEN("aws.sessionToken"null),
47
48     /**
49      * Configure the AWS web identity token file path.
50      */

51     AWS_WEB_IDENTITY_TOKEN_FILE("aws.webIdentityTokenFile"null),
52
53     /**
54      * Configure the AWS role arn.
55      */

56     AWS_ROLE_ARN("aws.roleArn"null),
57
58     /**
59      * Configure the session name for a role.
60      */

61     AWS_ROLE_SESSION_NAME("aws.roleSessionName"null),
62
63     /**
64      * Configure the default region.
65      */

66     AWS_REGION("aws.region"null),
67
68     /**
69      * Whether to load information such as credentials, regions from EC2 Metadata instance service.
70      */

71     AWS_EC2_METADATA_DISABLED("aws.disableEc2Metadata""false"),
72
73     /**
74      * The EC2 instance metadata service endpoint.
75      *
76      * This allows a service running in EC2 to automatically load its credentials and region without needing to configure them
77      * in the SdkClientBuilder.
78      */

79     AWS_EC2_METADATA_SERVICE_ENDPOINT("aws.ec2MetadataServiceEndpoint""http://169.254.169.254"),
80
81     /**
82      * The elastic container metadata service endpoint that should be called by the ContainerCredentialsProvider
83      * when loading data from the container metadata service.
84      *
85      * This allows a service running in an elastic container to automatically load its credentials without needing to configure
86      * them in the SdkClientBuilder.
87      *
88      * This is not used if the {@link #AWS_CONTAINER_CREDENTIALS_RELATIVE_URI} is not specified.
89      */

90     AWS_CONTAINER_SERVICE_ENDPOINT("aws.containerServiceEndpoint""http://169.254.170.2"),
91
92     /**
93      * The elastic container metadata service path that should be called by the ContainerCredentialsProvider when
94      * loading credentials form the container metadata service. If this is not specified, credentials will not be automatically
95      * loaded from the container metadata service.
96      *
97      * @see #AWS_CONTAINER_SERVICE_ENDPOINT
98      */

99     AWS_CONTAINER_CREDENTIALS_RELATIVE_URI("aws.containerCredentialsPath"null),
100
101     /**
102      * The full URI path to a localhost metadata service to be used.
103      */

104     AWS_CONTAINER_CREDENTIALS_FULL_URI("aws.containerCredentialsFullUri"null),
105
106     /**
107      * An authorization token to pass to a container metadata service, only used when {@link #AWS_CONTAINER_CREDENTIALS_FULL_URI}
108      * is specified.
109      *
110      * @see #AWS_CONTAINER_CREDENTIALS_FULL_URI
111      */

112     AWS_CONTAINER_AUTHORIZATION_TOKEN("aws.containerAuthorizationToken"null),
113
114     /**
115      * Explicitly identify the default synchronous HTTP implementation the SDK will use. Useful
116      * when there are multiple implementations on the classpath or as a performance optimization
117      * since implementation discovery requires classpath scanning.
118      */

119     SYNC_HTTP_SERVICE_IMPL("software.amazon.awssdk.http.service.impl"null),
120
121     /**
122      * Explicitly identify the default Async HTTP implementation the SDK will use. Useful
123      * when there are multiple implementations on the classpath or as a performance optimization
124      * since implementation discovery requires classpath scanning.
125      */

126     ASYNC_HTTP_SERVICE_IMPL("software.amazon.awssdk.http.async.service.impl"null),
127
128     /**
129      * Whether CBOR optimization should automatically be used if its support is found on the classpath and the service supports
130      * CBOR-formatted JSON.
131      */

132     CBOR_ENABLED("aws.cborEnabled""true"),
133
134     /**
135      * Whether binary ION representation optimization should automatically be used if the service supports ION.
136      */

137     BINARY_ION_ENABLED("aws.binaryIonEnabled""true"),
138
139     /**
140      * The execution environment of the SDK user. This is automatically set in certain environments by the underlying AWS service.
141      * For example, AWS Lambda will automatically specify a runtime indicating that the SDK is being used within Lambda.
142      */

143     AWS_EXECUTION_ENV("aws.executionEnvironment"null),
144
145     /**
146      * Whether endpoint discovery should be enabled.
147      */

148     AWS_ENDPOINT_DISCOVERY_ENABLED("aws.endpointDiscoveryEnabled"null),
149
150     /**
151      * The S3 regional endpoint setting for the {@code us-east-1} region. Setting the value to {@code regional} causes
152      * the SDK to use the {@code s3.us-east-1.amazonaws.com} endpoint when using the {@code US_EAST_1} region instead of
153      * the global {@code s3.amazonaws.com}. Using the regional endpoint is disabled by default.
154      */

155     AWS_S3_US_EAST_1_REGIONAL_ENDPOINT("aws.s3UseUsEast1RegionalEndpoint"null),
156
157     /**
158      * Which {@link RetryMode} to use for the default {@link RetryPolicy}, when one is not specified at the client level.
159      */

160     AWS_RETRY_MODE("aws.retryMode"null),
161
162     /**
163      * Defines the default value for {@link RetryPolicy.Builder#numRetries(Integer)}, if the retry count is not overridden in the
164      * retry policy configured via {@link ClientOverrideConfiguration.Builder#retryPolicy(RetryPolicy)}. This is one more than
165      * the number of retries, so aws.maxAttempts = 1 is 0 retries.
166      */

167     AWS_MAX_ATTEMPTS("aws.maxAttempts"null),
168
169     ;
170
171     private final String systemProperty;
172     private final String defaultValue;
173
174     SdkSystemSetting(String systemProperty, String defaultValue) {
175         this.systemProperty = systemProperty;
176         this.defaultValue = defaultValue;
177     }
178
179     @Override
180     public String property() {
181         return systemProperty;
182     }
183
184     @Override
185     public String environmentVariable() {
186         return name();
187     }
188
189     @Override
190     public String defaultValue() {
191         return defaultValue;
192     }
193 }
194