Skip to content

Commit 1ea5626

Browse files
committed
updated the Kotlin SDK build number
1 parent 2f6fd6f commit 1ea5626

File tree

4 files changed

+14
-113
lines changed

4 files changed

+14
-113
lines changed

kotlin/services/stepfunctions/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ repositories {
2727
}
2828
apply(plugin = "org.jlleitschuh.gradle.ktlint")
2929
dependencies {
30-
implementation("aws.sdk.kotlin:sfn:1.2.28")
31-
implementation("aws.sdk.kotlin:iam:1.2.28")
32-
implementation("aws.sdk.kotlin:secretsmanager:1.2.28")
30+
implementation("aws.sdk.kotlin:sfn:1.3.112")
31+
implementation("aws.sdk.kotlin:iam:1.3.112")
32+
implementation("aws.sdk.kotlin:secretsmanager:1.3.112")
3333
implementation("aws.smithy.kotlin:http-client-engine-okhttp:0.30.0")
3434
implementation("aws.smithy.kotlin:http-client-engine-crt:0.30.0")
3535
implementation("com.google.code.gson:gson:2.10")

kotlin/services/stepfunctions/src/main/kotlin/com/kotlin/stepfunctions/GetStream.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ package com.kotlin.stepfunctions
44

55
import com.fasterxml.jackson.databind.JsonNode
66
import com.fasterxml.jackson.databind.ObjectMapper
7+
import java.io.FileInputStream
78
import java.io.InputStream
89

910
class GetStream {
10-
suspend fun getStream(): String {
11+
suspend fun getStream(location:String): String {
1112
// Get JSON to use for the state machine and place the activityArn value into it.
12-
val input: InputStream = this::class.java.classLoader.getResourceAsStream("chat_sfn_state_machine.json")
13+
val input: InputStream = FileInputStream(location)
1314
val mapper = ObjectMapper()
1415
val jsonNode: JsonNode = mapper.readValue(input, JsonNode::class.java)
1516
return mapper.writeValueAsString(jsonNode)

kotlin/services/stepfunctions/src/main/kotlin/com/kotlin/stepfunctions/StepFunctionsScenario.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,18 @@ suspend fun main(args: Array<String>) {
6767
roleName - The name of the IAM role to create for this state machine.
6868
activityName - The name of an activity to create.
6969
stateMachineName - The name of the state machine to create.
70+
jsonFile - The location of the chat_sfn_state_machine.json file. You can located it in resources/sample_files.
7071
"""
7172

72-
if (args.size != 3) {
73+
if (args.size != 4) {
7374
println(usage)
7475
exitProcess(0)
7576
}
7677

7778
val roleName = args[0]
7879
val activityName = args[1]
7980
val stateMachineName = args[2]
81+
val jsonFile = args[3]
8082
val sc = Scanner(System.`in`)
8183
var action = false
8284

@@ -116,7 +118,7 @@ suspend fun main(args: Array<String>) {
116118

117119
// Get JSON to use for the state machine and place the activityArn value into it.
118120
val stream = GetStream()
119-
val jsonString = stream.getStream()
121+
val jsonString = stream.getStream(jsonFile)
120122

121123
// Modify the Resource node.
122124
val objectMapper = ObjectMapper()
@@ -258,14 +260,14 @@ suspend fun describeExe(executionArnVal: String?) {
258260
SfnClient { region = "us-east-1" }.use { sfnClient ->
259261
val response = sfnClient.describeExecution(executionRequest)
260262
status = response.status.toString()
261-
if (status.compareTo("RUNNING") == 0) {
263+
if (status.compareTo("Running") == 0) {
262264
println("The state machine is still running, let's wait for it to finish.")
263265
Thread.sleep(2000)
264-
} else if (status.compareTo("SUCCEEDED") == 0) {
266+
} else if (status.compareTo("Succeeded") == 0) {
265267
println("The Step Function workflow has succeeded")
266268
hasSucceeded = true
267269
} else {
268-
println("The Status is neither running or succeeded")
270+
println("The Status is $status")
269271
}
270272
}
271273
}

kotlin/services/stepfunctions/src/test/kotlin/StepFunctionsKotlinTest.kt

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -69,115 +69,13 @@ class StepFunctionsKotlinTest {
6969
}
7070

7171
@Test
72-
@Order(2)
72+
@Order(1)
7373
fun listStateMachines() =
7474
runBlocking {
7575
listMachines()
7676
println("Test 4 passed")
7777
}
7878

79-
@Test
80-
@Order(2)
81-
fun testMVP() =
82-
runBlocking {
83-
val sc = Scanner(System.`in`)
84-
var action = false
85-
86-
val polJSON = """{
87-
"Version": "2012-10-17",
88-
"Statement": [
89-
{
90-
"Sid": "",
91-
"Effect": "Allow",
92-
"Principal": {
93-
"Service": "states.amazonaws.com"
94-
},
95-
"Action": "sts:AssumeRole"
96-
}
97-
]
98-
}"""
99-
100-
println(DASHES)
101-
println("List activities using a Paginator.")
102-
listActivitesPagnator()
103-
println("Create an activity.")
104-
val activityArn = createActivity(activityNameSC)
105-
println("The ARN of the Activity is $activityArn")
106-
107-
println("List state machines using a paginator.")
108-
listStatemachinesPagnator()
109-
println(DASHES)
110-
111-
// Get JSON to use for the state machine and place the activityArn value into it.
112-
val stream = GetStream()
113-
val jsonString = stream.getStream()
114-
115-
// Modify the Resource node.
116-
val objectMapper = ObjectMapper()
117-
val root: JsonNode = objectMapper.readTree(jsonString)
118-
(root.path("States").path("GetInput") as ObjectNode).put("Resource", activityArn)
119-
120-
// Convert the modified Java object back to a JSON string.
121-
val stateDefinition = objectMapper.writeValueAsString(root)
122-
println(stateDefinition)
123-
124-
println(DASHES)
125-
println("Create a state machine.")
126-
val roleARN = createIAMRole(roleNameSC, polJSON)
127-
val stateMachineArn = createMachine(roleARN, stateMachineNameSC, stateDefinition)
128-
println("The ARN of the state machine is $stateMachineArn")
129-
println("The ARN of the state machine is")
130-
println(DASHES)
131-
132-
println(DASHES)
133-
println("Describe the state machine.")
134-
describeStateMachine(stateMachineArn)
135-
println("What should ChatSFN call you?")
136-
val userName = "foo"
137-
println("Hello $userName")
138-
println(DASHES)
139-
140-
println(DASHES)
141-
// The JSON to pass to the StartExecution call.
142-
val executionJson = "{ \"name\" : \"$userName\" }"
143-
println(executionJson)
144-
println("Start execution of the state machine and interact with it.")
145-
val runArn = startWorkflow(stateMachineArn, executionJson)
146-
println("The ARN of the state machine execution is $runArn")
147-
var myList: List<String>
148-
while (!action) {
149-
myList = getActivityTask(activityArn)
150-
println("ChatSFN: " + myList[1])
151-
println("$userName please specify a value.")
152-
val myAction = "done"
153-
action = true
154-
val taskJson = "{ \"action\" : \"$myAction\" }"
155-
println(taskJson)
156-
sendTaskSuccess(myList[0], taskJson)
157-
}
158-
println(DASHES)
159-
160-
println(DASHES)
161-
println("Describe the execution.")
162-
describeExe(runArn)
163-
println(DASHES)
164-
165-
println(DASHES)
166-
println("Delete the activity.")
167-
deleteActivity(activityArn)
168-
println(DASHES)
169-
170-
println(DASHES)
171-
println("Delete the state machines.")
172-
deleteMachine(stateMachineArn)
173-
println(DASHES)
174-
175-
println(DASHES)
176-
println("The AWS Step Functions example scenario is complete.")
177-
println(DASHES)
178-
println("Test 4 passed")
179-
}
180-
18179
private suspend fun getSecretValues(): String {
18280
val secretName = "test/stepfunctions"
18381
val valueRequest =

0 commit comments

Comments
 (0)