The new AWS SDK for Kotlin with Coroutines support
The new AWS SDK for Kotlin was announced at AWS re:Invent in December 2021. Using the SDK, you can build Kotlin applications that work with Amazon S3, Amazon EC2, DynamoDB, and more. The SDK is currently in preview and is expected to become stable soon.
The SDK was designed from the ground up to support the Kotlin language and its best practices, providing Kotlin developers with a familiar and idiomatic experience for interacting with AWS. The SDK leverages Kotlin coroutines for asynchronous implementation, and there are plans to make it compatible with Kotlin multiplatform projects.
To start using the new SDK in your Kotlin programs, you’ll need to add a corresponding dependency to your project. For instance, if we would like to communicate with DynamoDB, then the
aws.sdk.kotlin:dynamodb module is required:
You can find the complete list of supported modules in the documentation for the AWS SDK.
After downloading the dependencies we can start using the API:
The program simply retrieves the list of tables and prints the table names into the standard output. In the example above,
listTables is a suspending function, so the code is wrapped into a
How about a slightly more complex example that demonstrates downloading every S3 object in a bucket to a local temporary directory, featuring paginated access, concurrent flows, and byte-streaming responses?
In the example above, you can see again the use of the suspending functions in the SDK: the
writeToFile functions are all marked with the
In the official documentation for the new AWS SDK for Kotlin, you can find detailed step-by-step instructions on how to get started. Also, you can find a number of interesting examples that demonstrate the API with a number of AWS services such as Amazon DynamoDB, S3, Rekognition, Amazon Simple Notification Service, and AWS Key Management Service.
The new AWS SDK for Kotlin is in active development and you can check out what features are planned in the roadmap. Try it now and let us know what you think!
Subscribe to Blog updates
Advent of Code in Kotlin: Celebrating Our Participants and Their Solutions
A big thank you goes out to everyone who joined us for Advent of Code in Kotlin this year! From December 1 through 12, we shared daily livestreams of puzzle solutions. If you missed any of the action, you can watch the recordings on our YouTube playlist.
Kotlin/Wasm in Alpha, a KMP Project Migration Tutorial by Philipp Lackner, and Other Kotlin News
The first Kotlin Digest of 2024 is out! Catch up on the Kotlin ecosystem highlights in December and January!
Results of Google Summer of Code With Kotlin
2023 marked Kotlin's first-ever participation in Google Summer of Code (GSoC), a global online program focused on bringing new contributors into open-source development. Contributors worked on 12-week programming projects with the Kotlin Foundation under the guidance of mentors from JetBrains, Google, and Gradle, and gained experience on real-world projects. We would like to share the results achieved during GSoC 2023.