Home>

For Java applications that run on AWS Fargate, implement the function to access AWS resources using the SDK.
Although IAM user credential information was used for access privileges, I am planning to shift to control by the task role set in the Fargate task.

After reading the official documentation, it was about using the ContainerCredentialsProvider class. Can you tell me how to use it?

Applicable source code
AmazonSimpleEmailService sesClient = AmazonSimpleEmailServiceClientBuilder.standard ()
                .withCredentials (new ContainerCredentialsProvider ())
                .withRegion (Regions.US_EAST_1)
                .build ();

As mentioned above, an instance of ContainerCredentialsProvider was specified in the withCredentials method, but according to the documentation, it is desirable to specify CredentailsEndpointProvider as an argument for the constructor of this class.
I am asking how to write CredentailsEndpointProvider.

Supplemental information (FW/tool version etc.)

-SDK version "1.11.479" is used.
・ We coded with reference to the official document.

I would like to point out if there is an error in the best description method or implementation method.

Sorry for the rudimentary question, thank you.

  • Answer # 1

    Where is it written in the document?

    I don't know if it's an answer, but if you don't specify.withCredentials, it will behave like going to get authentication information according to the default CredentialsProviderChain, so specify anything Would n’t it be better if you did n’t?

    Please refer to the official documentation for the credential provider chain

    Quote below

      

    Reading authentication information
      After configuring the credentials, you can load them using the default credentials provider chain.
      To do so, instantiate an AWS service client without explicitly specifying credentials in the builder:

    AmazonS3 s3Client = AmazonS3ClientBuilder.standard ()
                           .withRegion (Regions.US_WEST_2)
                           .build ();

Trends