zalando/spring-cloud-config-aws-kms

getting error Caused by: com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment .

Closed this issue · 0 comments

Hi, I am trying to upgrade the spring boot to 2.6.6 I am trying to use zalando library for aws kms implementation. but it is failing in decryption process. getting error

"Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kms' defined in class path resource [de/zalando/spring/cloud/config/aws/kms/KmsEncryptionConfiguration$KmsConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.amazonaws.services.kms.AWSKMS]: Factory method 'kms' threw exception; nested exception is com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.amazonaws.services.kms.AWSKMS]: Factory method 'kms' threw exception; nested exception is com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
Caused by: com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
"

I have one controller class.

import com.logmein.ucc.Application;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@EnableAutoConfiguration
@RestController
public class DemoController {

// @SuppressWarnings("unused")
// @Autowired
// private TextEncryptor encryptor;

@Value("${not.secret}")
private String notSecret;

@Value("${yes.secret}")
private String yesSecret;

@RequestMapping("/secret")
public String testConfiguration() {
    // values that start with {cipher} are automatically decrypted. Or you
    // can use the injected encryptor to encrypt/decrypt text on the fly.
    //String decrypted = encryptor.decrypt("Another secret");
    return String.format("No Secret = %s<br/>Secret = %s", notSecret, yesSecret);
}

public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
}

I have added secrets in the application.properties

not.secret=Not Secret
yes.secret={cipher}AQECAHgC4i08YQPWUmjDPAmJr78ypSphQy+cO9D/UNvsgKmjNAAAAGgwZgYJKoZIhvcNAQcGoFkwVwIBADBSBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDHWhtF95tvJzwtncNQIBEIAlTrYDV6TI1FwKPMCuUYMt6wsYLEE+f7uQkZ0Kcx6nPMjd57VNEA==

can anyone suggest how to resolve this issue ?