File tree Expand file tree Collapse file tree 13 files changed +14
-14
lines changed
src/main/kotlin/com/kotlin/kms Expand file tree Collapse file tree 13 files changed +14
-14
lines changed Original file line number Diff line number Diff line change 11import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22
33plugins {
4- kotlin(" jvm" ) version " 1.9 .0"
4+ kotlin(" jvm" ) version " 2.1 .0"
55 application
66}
77
@@ -27,7 +27,7 @@ repositories {
2727}
2828apply (plugin = " org.jlleitschuh.gradle.ktlint" )
2929dependencies {
30- implementation(platform(" aws.sdk.kotlin:bom:1.3.112 " ))
30+ implementation(platform(" aws.sdk.kotlin:bom:1.4.119 " ))
3131 implementation(" aws.sdk.kotlin:kms" )
3232 implementation(" aws.sdk.kotlin:secretsmanager" )
3333 implementation(" aws.smithy.kotlin:http-client-engine-okhttp" )
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ suspend fun createCustomAlias(
4747 targetKeyId = targetKeyIdVal
4848 }
4949
50- KmsClient { region = " us-west-2" }.use { kmsClient ->
50+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
5151 kmsClient.createAlias(request)
5252 println (" $aliasNameVal was successfully created" )
5353 }
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ suspend fun createKey(keyDesc: String?): String? {
3333 keyUsage = KeyUsageType .fromValue(" ENCRYPT_DECRYPT" )
3434 }
3535
36- KmsClient { region = " us-west-2" }.use { kmsClient ->
36+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
3737 val result = kmsClient.createKey(request)
3838 println (" Created a customer key with id " + result.keyMetadata?.arn)
3939 return result.keyMetadata?.keyId
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ suspend fun createNewGrant(
5757 operations = grantOperationList
5858 }
5959
60- KmsClient { region = " us-west-2" }.use { kmsClient ->
60+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
6161 val response = kmsClient.createGrant(request)
6262 return response.grantId
6363 }
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ suspend fun deleteSpecificAlias(aliasNameVal: String?) {
4242 aliasName = aliasNameVal
4343 }
4444
45- KmsClient { region = " us-west-2" }.use { kmsClient ->
45+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
4646 kmsClient.deleteAlias(request)
4747 println (" $aliasNameVal was deleted." )
4848 }
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ suspend fun describeSpecifcKey(keyIdVal: String?) {
4141 keyId = keyIdVal
4242 }
4343
44- KmsClient { region = " us-west-2" }.use { kmsClient ->
44+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
4545 val response = kmsClient.describeKey(request)
4646 println (" The key description is ${response.keyMetadata?.description} " )
4747 println (" The key ARN is ${response.keyMetadata?.arn} " )
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ suspend fun disableKey(keyIdVal: String?) {
4141 keyId = keyIdVal
4242 }
4343
44- KmsClient { region = " us-west-2" }.use { kmsClient ->
44+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
4545 kmsClient.disableKey(request)
4646 println (" $keyIdVal was successfully disabled" )
4747 }
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ suspend fun enableKey(keyIdVal: String?) {
4141 keyId = keyIdVal
4242 }
4343
44- KmsClient { region = " us-west-2" }.use { kmsClient ->
44+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
4545 kmsClient.enableKey(request)
4646 println (" $keyIdVal was successfully enabled." )
4747 }
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ suspend fun encryptData(keyIdValue: String): ByteArray? {
4848 plaintext = myBytes
4949 }
5050
51- KmsClient { region = " us-west-2" }.use { kmsClient ->
51+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
5252 val response = kmsClient.encrypt(encryptRequest)
5353 val algorithm: String = response.encryptionAlgorithm.toString()
5454 println (" The encryption algorithm is $algorithm " )
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ suspend fun listAllAliases() {
2727 limit = 15
2828 }
2929
30- KmsClient { region = " us-west-2" }.use { kmsClient ->
30+ KmsClient .fromEnvironment { region = " us-west-2" }.use { kmsClient ->
3131 val response = kmsClient.listAliases(request)
3232 response.aliases?.forEach { alias ->
3333 println (" The alias name is ${alias.aliasName} " )
You can’t perform that action at this time.
0 commit comments