Create a project file - AWS SDK for Kotlin

Create a project file

After you configure single sign-on access and your development environment, create a Kotlin project using your preferred build tool. Add dependencies for the AWS services that your application needs to access.

To see the list of all possible Maven artifact names, consult the API reference documentation. To find the latest version of the SDK, check the latest release on GitHub.

Gradle (literal notation)

The following example build.gradle.kts file has dependencies for seven AWS services.

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.9.10" application } group = "com.example" version = "1.0-SNAPSHOT" repositories { mavenCentral() } dependencies { implementation("aws.sdk.kotlin:s3:1.0.0") implementation("aws.sdk.kotlin:dynamodb:1.0.0") implementation("aws.sdk.kotlin:iam:1.0.0") implementation("aws.sdk.kotlin:cloudwatch:1.0.0") implementation("aws.sdk.kotlin:cognitoidentityprovider:1.0.0") implementation("aws.sdk.kotlin:sns:1.0.0") implementation("aws.sdk.kotlin:pinpoint:1.0.0") // test dependency testImplementation(kotlin("test")) } tasks.withType<Test> { useJUnitPlatform() } tasks.withType<KotlinCompile>() { kotlinOptions.jvmTarget = "17" }
Gradle (version catalog)

The AWS SDK for Kotlin publishes a Gradle version catalog that can help you discover the names of dependencies and keep version numbers synchronized across multiple artifacts.

Note that version catalogs are a preview feature of Gradle before version 8. Depending on the version of Gradle that you use, you may need to opt-in via the Feature Preview API.

To use a Gradle version catalog
  1. In your settings.gradle.kts file, add a versionCatalogs block inside the dependencyResolutionManagement block.

    The following example file configures the AWS SDK for Kotlin version catalog for version 1.0.0 . Replace 1.0.0 with the latest version or the version you want to use.

    dependencyResolutionManagement { repositories { mavenCentral() } versionCatalogs { create("awssdk") { from("aws.sdk.kotlin:version-catalog:1.0.0") } } }
  2. Declare dependencies in build.gradle.kts by using the type-safe identifiers made available by the version catalog.

    The following example file declares dependencies for seven AWS services.

    import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.9.10" application } group = "com.example" version = "1.0-SNAPSHOT" repositories { mavenCentral() } dependencies { implementation(awssdk.services.s3) implementation(awssdk.services.dynamodb) implementation(awssdk.services.iam) implementation(awssdk.services.cloudwatch) implementation(awssdk.services.cognitoidentityprovider) implementation(awssdk.services.sns) implementation(awssdk.services.pinpoint) // test dependency testImplementation(kotlin("test")) } tasks.withType<Test> { useJUnitPlatform() } tasks.withType<KotlinCompile>() { kotlinOptions.jvmTarget = "17" }
Maven

The following example pom.xml file has dependencies for seven AWS services.

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>setup</artifactId> <version>1.0-SNAPSHOT</version> <properties> <aws.sdk.kotlin.version>1.0.0</aws.sdk.kotlin.version> <kotlin.version>1.9.10</kotlin.version> <junit.version>4.13.2</junit.version> </properties> <dependencies> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>s3-jvm</artifactId> <version>${aws.sdk.kotlin.version}</version> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>dynamodb-jvm</artifactId> <version>${aws.sdk.kotlin.version}</version> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>iam-jvm</artifactId> <version>${aws.sdk.kotlin.version}</version> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>cloudwatch-jvm</artifactId> <version>${aws.sdk.kotlin.version}</version> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>cognitoidentityprovider-jvm</artifactId> <version>${aws.sdk.kotlin.version}</version> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>sns-jvm</artifactId> <version>${aws.sdk.kotlin.version}</version> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>pinpoint-jvm</artifactId> <version>${aws.sdk.kotlin.version}</version> </dependency> <!-- Test dependencies --> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-test-junit</artifactId> <version>${kotlin.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-test</artifactId> <version>${kotlin.version}</version> <scope>test</scope> </dependency> </dependencies> <build> <sourceDirectory>src/main/kotlin</sourceDirectory> <testSourceDirectory>src/test/kotlin</testSourceDirectory> <plugins> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <version>${kotlin.version}</version> <executions> <execution> <id>compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>test-compile</id> <phase>test-compile</phase> <goals> <goal>test-compile</goal> </goals> </execution> </executions> <configuration> <jvmTarget>17</jvmTarget> </configuration> </plugin> </plugins> </build> </project>