Create project build files - Amazon SDK for Kotlin
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Create project build files

After you configure single sign-on access and your development environment, create a Kotlin project using your preferred build tool. In the build file, specify the dependencies for the Amazon Web Services 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.

The following sample build files provide the necessary elements to begin coding a project with seven Amazon Web Services services.

Gradle

The Amazon SDK for Kotlin publishes a Gradle version catalog and bill of materials (BOM) 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 Amazon SDK for Kotlin version catalog. You can navigate to the X.Y.Z link to see the latest version available.

    plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "X.Y.Z" } rootProject.name = "your-project-name" dependencyResolutionManagement { repositories { mavenCentral() } versionCatalogs { create("awssdk") { from("aws.sdk.kotlin:version-catalog:X.Y.Z") } } }
  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 Amazon Web Services services.

    plugins { kotlin("jvm") version "X.Y.Z" application } group = "org.example" version = "1.0-SNAPSHOT" repositories { mavenCentral() } dependencies { implementation(platform(awssdk.bom)) implementation(platform("org.apache.logging.log4j:log4j-bom:X.Y.Z")) 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) implementation("org.apache.logging.log4j:log4j-slf4j2-impl") // Test dependency. testImplementation(kotlin("test")) } tasks.test { useJUnitPlatform() } java { toolchain { languageVersion = JavaLanguageVersion.of(X*) } } application { mainClass = "org.example.AppKt" }

    *Java version, for example 17 or 21.

Maven

The following example pom.xml file has dependencies for seven Amazon Web Services services. You can navigate to the X.Y.Z link to see the latest version available.

<?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>X.Y.Z</aws.sdk.kotlin.version> <kotlin.version>X.Y.Z</kotlin.version> <log4j.version>X.Y.Z</log4j.version> <junit.jupiter.version>X.Y.Z</junit.jupiter.version> <jvm.version>X*</jvm.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>bom</artifactId> <version>${aws.sdk.kotlin.version}</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-bom</artifactId> <version>${log4j.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>s3-jvm</artifactId> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>dynamodb-jvm</artifactId> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>iam-jvm</artifactId> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>cloudwatch-jvm</artifactId> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>cognitoidentityprovider-jvm</artifactId> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>sns-jvm</artifactId> </dependency> <dependency> <groupId>aws.sdk.kotlin</groupId> <artifactId>pinpoint-jvm</artifactId> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j2-impl</artifactId> </dependency> <!-- Test dependencies --> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-test-junit</artifactId> <version>${kotlin.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>${junit.jupiter.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>${jvm.version}</jvmTarget> </configuration> </plugin> </plugins> </build> </project>

*Java version, for example 17 or 21.