'Unable to find a region using the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region

I am using the AWS Java SDK v1 to access a Step Function.

Unfortunately I am getting this error about the region.

In my script file I defined like this.

private AWSStepFunctions client;
this.client = AWSStepFunctionsClientBuilder.defaultClient();

In application.properties I defined like this.

cloud.aws.region.static=eu-central-1
aws.region=eu-central-1


Solution 1:[1]

The code you are using is an old API and no longer considered best practice. Amazon Strongly recommends using V2 over V1.

The way you are creating a service client is outdated too. To programmatically work with AWS Step Functions, consider using the recommended API - which is AWS SDK for Java v2.

To create an AWS Step Functions Service Client and specify the Region, use Java code like this:

 Region region = Region.US_EAST_1;
 SfnClient sfnClient = SfnClient.builder()
           .region(region)
            .build();

See the AWS Step Functions Readme here for more set up instructions for AWS SDK Java V2.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 smac2020