spring-cloud-aws
spring-cloud-aws copied to clipboard
Parameter Store property "spring.cloud.aws.parameterstore.endpoint" is not loaded correctly when declared in an "application.properties" of a specifc spring profile
Type: Bug
Component: Parameter Store
Describe the bug The property "spring.cloud.aws.parameterstore.endpoint" is not loaded correctly when specified under a specific application.properties profile
Ex.:
# application.properties
spring.cloud.aws.parameterstore.endpoint=http://ssm.sa-east-1.amazonaws.com
# application-dev.properties
spring.cloud.aws.parameterstore.endpoint=http://localhost:4566
If the application is executed with:
java -jar app.jar --spring.profiles.active=dev
The expected endpoint to be used by Spring Cloud AWS's auto-configured SsmClient would be "http://localhost:4566". But instead, "http://ssm.sa-east-1.amazonaws.com" is used.
Sample
# application-dev.properties
spring.cloud.aws.parameterstore.endpoint=http://localhost:4566
Making a GET request with "dev" profile active to "/teste":
@RestController
public class ControllerParameterStore {
@Value("${foo}")
public String foo;
private final ServiceParameterStore serviceParameterStore;
public ControllerParameterStore(ServiceParameterStore serviceParameterStore) {
this.serviceParameterStore = serviceParameterStore;
}
@GetMapping("/teste")
public String teste() {
return foo;
}
}
Should return "foo from localhost:4566". As stated here:
2023-11-20T17:45:39.054-03:00 INFO 80862 --- [ restartedMain] com.example.demo.DemoApplication : The following 1 profile is active: "dev"
And showed here:
aws ssm get-parameter --name foo --with-decryption --endpoint-url http://localhost:4566
{
"Parameter": {
"Name": "foo",
"Type": "SecureString",
"Value": "foo from localhost:4566",
"Version": 1,
"LastModifiedDate": "2023-11-20T17:40:12.731000-03:00",
"ARN": "arn:aws:ssm:sa-east-1:000000000000:parameter/foo",
"DataType": "text"
}
}
Instead returns this: "foo from amazon sa-east-1 server". From the default aws server (configured automatically I think), as you can see here
aws ssm get-parameter --name foo --with-decryption
{
"Parameter": {
"Name": "foo",
"Type": "SecureString",
"Value": "foo from amazon sa-east-1 server",
"Version": 1,
"LastModifiedDate": "2023-11-20T17:41:51.835000-03:00",
"ARN": "arn:aws:ssm:sa-east-1:0000000000:parameter/foo",
"DataType": "text"
}
Hey @HenriqueDelben , which spring boot version are you using?
Hey, I’m using version 3.1.3
This is blocking my team as well.
Neither spring.cloud.aws.parameterstore.endpoint
nor spring.cloud.aws.endpoint
have any effect.
@HenriqueDelben @miles-po i am not able to reproduce it. Here's the working sample: https://github.com/maciej-scratches/spring-cloud-aws-gh-966
Please provide a sample that reproduces this issue and if the issue really exists, ideally PR with a fix.
I am seeing the same problem, endpoint is not being picked up from my SQS config:
cloud:
aws:
endpoint: http://localhost:4566
region:
auto: false
static: us-east-2
stack:
auto: false
credentials:
accessKey: zalupa
secretKey: zalupa
As a result, I get:
Caused by: com.amazonaws.services.sqs.model.QueueDoesNotExistException: The specified queue does not exist for this wsdl version. (Service: AmazonSQS; Status Code: 400; Error Code: AWS.SimpleQueueService.NonExistentQueue; Request ID: O9SD4TM5SUQ3X03HI0QL9D41RAF1ESHT6YTWWMRB2OQMYSGD736F; Proxy: null)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1879)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleServiceErrorResponse(AmazonHttpClient.java:1418)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1387)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1157)
Running with Spring Boot v2.7.18, Spring v5.3.33, Spring Cloud AWS v2.4.4
If I modify the region value, I can see the endpoint value changing if I inspect in debug mode paramRealSQS
.
Line 110 of AmazonSQSBufferedAsyncClient
:
public AmazonSQSBufferedAsyncClient(AmazonSQSAsync paramRealSQS) {
this(paramRealSQS, new QueueBufferConfig());
}
Hi I'm able to reproduce the issue like below configs. I have 2 config files: application.yml
spring:
config:
import: optional:aws-parameterstore:/gotyme/cico-voucher/feature-flags/
application-local.yml
spring:
cloud:
aws:
endpoint: http://localhost:4566
parameterstore:
endpoint: http://localhost:4566
When I run the application with local profile, other configs from application-local.yml was correctly loaded except the aws.endpoint
.
Workaround solutions: put the spring.config.import
and spring.cloud.aws.endpoint
in the same file, either application.yml or application-local.yml both will work.
- Move the
aws.endpoint
oraws.parameterstore.endpoint
to theapplication.yml
- Move the
spring.config.import
to theapplication-local.yml