I have a Spring Cloud Stream application where I'm using the AWS Kinesis Binder. I have the following configuration in the application.yml file:
cloud:
stream:
bindings:
customerEvents-out-0:
binder: kinesis
destination: 'customers-service-stream-name'
content-type: application/json
functionRouter-in-0:
destination: 'another-service-stream-name'
content-type: application/json
default:
group: customers-service-group
kinesis:
binder:
checkpoint:
table: 'SpringIntegrationMetadataStore'
locks:
table: 'SpringIntegrationLockRegistry'
headers:
- spring.cloud.function.definition
The application starts without errors.
The moment I add function.routing.enabled=true, the application won't start.
Configuration which stops the app from starting
cloud:
stream:
function:
routing:
enabled: true
bindings:
customerEvents-out-0:
binder: kinesis
destination: 'customers-service-stream-name'
content-type: application/json
functionRouter-in-0:
destination: 'another-service-stream-name'
content-type: application/json
default:
group: customers-service-group
kinesis:
binder:
checkpoint:
table: 'SpringIntegrationMetadataStore'
locks:
table: 'SpringIntegrationLockRegistry'
headers:
- spring.cloud.function.definition
This is part of the logs I see:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'kinesisBinderHealthIndicator' defined in org.springframework.cloud.stream.binder.kinesis.config.KinesisBinderConfiguration$KinesisBinderHealthIndicatorConfiguration: Unsatisfied dependency expressed through method 'kinesisBinderHealthIndicator' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'kinesisMessageChannelBinder' defined in org.springframework.cloud.stream.binder.kinesis.config.KinesisBinderConfiguration: Unsatisfied dependency expressed through method 'kinesisMessageChannelBinder' parameter 3; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kinesisCheckpointStore' defined in org.springframework.cloud.stream.binder.kinesis.config.KinesisBinderConfiguration: Invocation of init method failed; nested exception is com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The security token included in the request is invalid. (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: UnrecognizedClientException; Request ID: BDMVHHRUG4F7DD4GOH9POQGUKBVV4KQNSO5AEMVJF66Q9ASUAAJG; Proxy: null)
Caused by: com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The security token included in the request is invalid. (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: UnrecognizedClientException
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kinesisCheckpointStore'
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'kinesisMessageChannelBinder'
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'kinesisBinderHealthIndicator'
org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle'
In order to make the application start, I have to create the following 2 beans:
@Bean
AmazonKinesisAsync amazonKinesis(AWSCredentialsProvider awsCredentialsProvider) {
return AmazonKinesisAsyncClientBuilder
.standard()
.withCredentials(awsCredentialsProvider)
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpointUrl, region))
.build();
}
@Bean
@Primary
AmazonDynamoDBAsync amazonDynamoDBAsync(AWSCredentialsProvider awsCredentialsProvider) {
return AmazonDynamoDBAsyncClientBuilder.standard()
.withCredentials(awsCredentialsProvider)
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpointUrl, region))
.build();
}
However, these are beans that I add for local development with localstack, I shouldn't add these beans for prod.
Any ideas?