Skip to content

Commit

Permalink
added more lintered files
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon committed Jun 8, 2024
1 parent 6056394 commit 3a18b25
Show file tree
Hide file tree
Showing 20 changed files with 1,800 additions and 1,692 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ suspend fun updateTableItemPartiQL(ddb: DynamoDbClient) {
// Query the table where the year is 2013.
suspend fun queryTablePartiQL(ddb: DynamoDbClient) {
val sqlStatement = "SELECT * FROM MoviesPartiQ where year = ?"

val parameters: MutableList<AttributeValue> = java.util.ArrayList()
parameters.add(AttributeValue.N("2013"))
val response = executeStatementPartiQL(ddb, sqlStatement, parameters)
Expand Down
2 changes: 1 addition & 1 deletion kotlin/services/dynamodb/src/test/kotlin/DynamoDB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class DynamoDB {
awards,
awardVal,
songTitle,
songTitleVal,
songTitleVal
)
println("Test 3 passed")
}
Expand Down
122 changes: 62 additions & 60 deletions kotlin/services/ec2/src/main/kotlin/com/kotlin/ec2/AllocateAddress.kt
Original file line number Diff line number Diff line change
@@ -1,60 +1,62 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package com.kotlin.ec2

// snippet-start:[ec2.kotlin.allocate_address.import]
import aws.sdk.kotlin.services.ec2.Ec2Client
import aws.sdk.kotlin.services.ec2.model.AllocateAddressRequest
import aws.sdk.kotlin.services.ec2.model.AssociateAddressRequest
import aws.sdk.kotlin.services.ec2.model.DomainType
import kotlin.system.exitProcess
// snippet-end:[ec2.kotlin.allocate_address.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<instanceId>
Where:
instanceId - An instance id value that you can obtain from the AWS Management Console.
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val instanceId = args[0]
val idValue = getAllocateAddress(instanceId)
println("The id value for the allocated elastic IP address is $idValue")
}

// snippet-start:[ec2.kotlin.allocate_address.main]
suspend fun getAllocateAddress(instanceIdVal: String?): String? {
val allocateRequest = AllocateAddressRequest {
domain = DomainType.Vpc
}

Ec2Client { region = "us-west-2" }.use { ec2 ->
val allocateResponse = ec2.allocateAddress(allocateRequest)
val allocationIdVal = allocateResponse.allocationId

val request = AssociateAddressRequest {
instanceId = instanceIdVal
allocationId = allocationIdVal
}

val associateResponse = ec2.associateAddress(request)
return associateResponse.associationId
}
}
// snippet-end:[ec2.kotlin.allocate_address.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package com.kotlin.ec2

// snippet-start:[ec2.kotlin.allocate_address.import]
import aws.sdk.kotlin.services.ec2.Ec2Client
import aws.sdk.kotlin.services.ec2.model.AllocateAddressRequest
import aws.sdk.kotlin.services.ec2.model.AssociateAddressRequest
import aws.sdk.kotlin.services.ec2.model.DomainType
import kotlin.system.exitProcess
// snippet-end:[ec2.kotlin.allocate_address.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<instanceId>
Where:
instanceId - An instance id value that you can obtain from the AWS Management Console.
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val instanceId = args[0]
val idValue = getAllocateAddress(instanceId)
println("The id value for the allocated elastic IP address is $idValue")
}

// snippet-start:[ec2.kotlin.allocate_address.main]
suspend fun getAllocateAddress(instanceIdVal: String?): String? {
val allocateRequest =
AllocateAddressRequest {
domain = DomainType.Vpc
}

Ec2Client { region = "us-west-2" }.use { ec2 ->
val allocateResponse = ec2.allocateAddress(allocateRequest)
val allocationIdVal = allocateResponse.allocationId

val request =
AssociateAddressRequest {
instanceId = instanceIdVal
allocationId = allocationIdVal
}

val associateResponse = ec2.associateAddress(request)
return associateResponse.associationId
}
}
// snippet-end:[ec2.kotlin.allocate_address.main]
144 changes: 75 additions & 69 deletions kotlin/services/ec2/src/main/kotlin/com/kotlin/ec2/CreateInstance.kt
Original file line number Diff line number Diff line change
@@ -1,69 +1,75 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package com.kotlin.ec2

// snippet-start:[ec2.kotlin.create_instance.import]
import aws.sdk.kotlin.services.ec2.Ec2Client
import aws.sdk.kotlin.services.ec2.model.CreateTagsRequest
import aws.sdk.kotlin.services.ec2.model.InstanceType
import aws.sdk.kotlin.services.ec2.model.RunInstancesRequest
import aws.sdk.kotlin.services.ec2.model.Tag
import kotlin.system.exitProcess
// snippet-end:[ec2.kotlin.create_instance.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<name> <amiId>
Where:
name - An instance name that you can obtain from the AWS Management Console (for example, ami-xxxxxx5c8b987b1a0).
amiId - An Amazon Machine Image (AMI) value that you can obtain from the AWS Management Console (for example, i-xxxxxx2734106d0ab).
"""

if (args.size != 2) {
println(usage)
exitProcess(0)
}

val name = args[0]
val amiId = args[1]
createEC2Instance(name, amiId)
}

// snippet-start:[ec2.kotlin.create_instance.main]
suspend fun createEC2Instance(name: String, amiId: String): String? {
val request = RunInstancesRequest {
imageId = amiId
instanceType = InstanceType.T1Micro
maxCount = 1
minCount = 1
}

Ec2Client { region = "us-west-2" }.use { ec2 ->
val response = ec2.runInstances(request)
val instanceId = response.instances?.get(0)?.instanceId
val tag = Tag {
key = "Name"
value = name
}

val requestTags = CreateTagsRequest {
resources = listOf(instanceId.toString())
tags = listOf(tag)
}
ec2.createTags(requestTags)
println("Successfully started EC2 Instance $instanceId based on AMI $amiId")
return instanceId
}
}
// snippet-end:[ec2.kotlin.create_instance.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package com.kotlin.ec2

// snippet-start:[ec2.kotlin.create_instance.import]
import aws.sdk.kotlin.services.ec2.Ec2Client
import aws.sdk.kotlin.services.ec2.model.CreateTagsRequest
import aws.sdk.kotlin.services.ec2.model.InstanceType
import aws.sdk.kotlin.services.ec2.model.RunInstancesRequest
import aws.sdk.kotlin.services.ec2.model.Tag
import kotlin.system.exitProcess
// snippet-end:[ec2.kotlin.create_instance.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<name> <amiId>
Where:
name - An instance name that you can obtain from the AWS Management Console (for example, ami-xxxxxx5c8b987b1a0).
amiId - An Amazon Machine Image (AMI) value that you can obtain from the AWS Management Console (for example, i-xxxxxx2734106d0ab).
"""

if (args.size != 2) {
println(usage)
exitProcess(0)
}

val name = args[0]
val amiId = args[1]
createEC2Instance(name, amiId)
}

// snippet-start:[ec2.kotlin.create_instance.main]
suspend fun createEC2Instance(
name: String,
amiId: String,
): String? {
val request =
RunInstancesRequest {
imageId = amiId
instanceType = InstanceType.T1Micro
maxCount = 1
minCount = 1
}

Ec2Client { region = "us-west-2" }.use { ec2 ->
val response = ec2.runInstances(request)
val instanceId = response.instances?.get(0)?.instanceId
val tag =
Tag {
key = "Name"
value = name
}

val requestTags =
CreateTagsRequest {
resources = listOf(instanceId.toString())
tags = listOf(tag)
}
ec2.createTags(requestTags)
println("Successfully started EC2 Instance $instanceId based on AMI $amiId")
return instanceId
}
}
// snippet-end:[ec2.kotlin.create_instance.main]
99 changes: 50 additions & 49 deletions kotlin/services/ec2/src/main/kotlin/com/kotlin/ec2/CreateKeyPair.kt
Original file line number Diff line number Diff line change
@@ -1,49 +1,50 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package com.kotlin.ec2

// snippet-start:[ec2.kotlin.create_key_pair.import]
import aws.sdk.kotlin.services.ec2.Ec2Client
import aws.sdk.kotlin.services.ec2.model.CreateKeyPairRequest
import kotlin.system.exitProcess
// snippet-end:[ec2.kotlin.create_key_pair.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<keyName>
Where:
keyName - A key pair name (for example, TestKeyPair).
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val keyName = args[0]
createEC2KeyPair(keyName)
}

// snippet-start:[ec2.kotlin.create_key_pair.main]
suspend fun createEC2KeyPair(keyNameVal: String) {
val request = CreateKeyPairRequest {
keyName = keyNameVal
}

Ec2Client { region = "us-west-2" }.use { ec2 ->
val response = ec2.createKeyPair(request)
println("The key ID is ${response.keyPairId}")
}
}
// snippet-end:[ec2.kotlin.create_key_pair.main]
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package com.kotlin.ec2

// snippet-start:[ec2.kotlin.create_key_pair.import]
import aws.sdk.kotlin.services.ec2.Ec2Client
import aws.sdk.kotlin.services.ec2.model.CreateKeyPairRequest
import kotlin.system.exitProcess
// snippet-end:[ec2.kotlin.create_key_pair.import]

/**
Before running this Kotlin code example, set up your development environment,
including your credentials.
For more information, see the following documentation topic:
https://docs.aws.amazon.com/sdk-for-kotlin/latest/developer-guide/setup.html
*/

suspend fun main(args: Array<String>) {
val usage = """
Usage:
<keyName>
Where:
keyName - A key pair name (for example, TestKeyPair).
"""

if (args.size != 1) {
println(usage)
exitProcess(0)
}

val keyName = args[0]
createEC2KeyPair(keyName)
}

// snippet-start:[ec2.kotlin.create_key_pair.main]
suspend fun createEC2KeyPair(keyNameVal: String) {
val request =
CreateKeyPairRequest {
keyName = keyNameVal
}

Ec2Client { region = "us-west-2" }.use { ec2 ->
val response = ec2.createKeyPair(request)
println("The key ID is ${response.keyPairId}")
}
}
// snippet-end:[ec2.kotlin.create_key_pair.main]
Loading

0 comments on commit 3a18b25

Please sign in to comment.