AWS SDK for Java 2.0 Developer Guide And what I'm trying to use this time.
pom.xml
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<aws.java.sdk.version>2.11.12</aws.java.sdk.version>
</properties>
<!--Omission-->
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>${aws.java.sdk.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ecs</artifactId>
<version>${aws.java.sdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssm</artifactId>
<version>${aws.java.sdk.version}</version>
</dependency>
</dependencies>
Install the AWS CLI. Installing the AWS CLI version 2 on Windows
Configuration and Credential File Settings Make sure the files are under C: \ Users \ (username) \ .aws.
~/.aws/credentials
[default]
aws_access_key_id=(Own access_key_id)
aws_secret_access_key=(Own secret_access_key)
~/.aws/config
[default]
region=ap-northeast-1
output=json
Set up MFA in Assign MFA Device. After setting MFA, you can check and operate various services on the console only after logging out-> re-login. Check the authority to see information such as EC2 on the console.
How do I use MFA tokens to authenticate access to AWS resources through the AWS CLI? ](Https://aws.amazon.com/jp/premiumsupport/knowledge-center/authenticate-mfa-cli/)
The ARN in AWS for an SMS device, such as arn:aws:iam::123456789012:sms-mfa/username
The ARN in AWS for a virtual device, such as arn:aws:iam::123456789012:mfa/username
This means the following.
C:\Users\works>aws sts get-session-token --serial-number arn:aws:iam::123456123456:mfa/[email protected] --token-code (6-digit MFA number)
{
"Credentials": {
"AccessKeyId": "ASIA************",
"SecretAccessKey": "p8j****************************",
"SessionToken": "**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************",
"Expiration": "2020-06-17T19:08:08+00:00"
}
}
In this way you can get Credentials.
How to switch AWS CLI settings and the difference between AWS_DEFAULT_PROFILE and AWS_PROFILE was easy to understand.
ʻAws configure --profile As the profile name says, try creating a test profile ʻeclipse
.
C:\Users\works>aws configure --profile eclipse
AWS Access Key ID [None]: (Credential Access Key ID)
AWS Secret Access Key [None]: (Credential Secret Access Key)
Default region name [None]: ap-northeast-1
Default output format [None]: json
with this
~/.aws/credentials
~/.aws/config
Make sure that is updated.
This time, in this state, in the runtime environment variable of Eclipse ʻSet AWS_PROFILE = eclipse`.
The Java program worked locally safely. Related: Detailed notes such as coexistence of AWS SDKs 1 and 2
Recommended Posts