Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override AWS SDK internal objectMapper with Micronaut ObjectMapper instance #2141

Open
dniel opened this issue Jun 10, 2024 · 1 comment
Open

Comments

@dniel
Copy link

dniel commented Jun 10, 2024

Issue description

I see that the AWS SDK has its own internal objectMapper with its own configuration, instead of the one micronaut provided.

We have a custom deserializer to handle dynamodb streams events to our lambda, and its working when we test it in unit tests and Micronaut but unfortunately its not used by AWS SDK, with its own object mapper without that configured.

Do you know if its possible to override the AWS SDK internal instance to be the Micronaut objectmapper?

@thaugrud
Copy link

We have implemented a custom deserializer for the software.amazon.awssdk.services.dynamodb.model.Record class from the AWS SDK that works as expected when read by the injected Objectmapper as shown below:

val record = objectMapper.readValue(serializedRecordString, Record::class.java)

Then we have implemented a Lambda using the class as an input parameter:

@SerdeImport(Record::class)
class Handler : MicronautRequestHandler<List<Record>, Boolean>() {
    private val logger = KotlinLogging.logger {}
    
    @Inject
    private lateinit var objectMapper: ObjectMapper

    override fun execute(records: List<Record>):  {
        logger.info { "Received event" }
        logger.info { "Records: $records" }
        
        return true
    }
}

Here we are expecting the Lambda runtime to have access to the custom Serde deserializer and deserialize the incoming data into the expected Record-class. However the application errors during parsing when attempting to parse the incoming data from JSON as it does not appear to use the Micronaut objectMapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants