@@ -240,124 +240,6 @@ class EC2Test {
240240 println (" Test 14 passed" )
241241 }
242242
243- @Test
244- @Order(15 )
245- fun fullEC2ScenarioTest () =
246- runBlocking {
247- var newInstanceId: String
248- println (DASHES )
249- println (" 1. Create an RSA key pair and save the private key material as a .pem file." )
250- createKeyPairSc(keyNameSc, fileNameSc)
251- println (DASHES )
252-
253- println (DASHES )
254- println (" 2. List key pairs." )
255- describeEC2KeysSc()
256- println (DASHES )
257-
258- println (DASHES )
259- println (" 3. Create a security group." )
260- val groupId = createEC2SecurityGroupSc(groupNameSc, groupDescSc, vpcIdSc, myIpAddressSc)
261- groupId?.let { assertTrue(it.isNotEmpty()) }
262- println (DASHES )
263-
264- println (DASHES )
265- println (" 4. Display security group info for the newly created security group." )
266- describeSecurityGroupsSc(groupId.toString())
267- println (DASHES )
268-
269- println (DASHES )
270- println (" 5. Get a list of Amazon Linux 2 AMIs and select one with amzn2 in the name." )
271- val instanceId = getParaValuesSc()
272- instanceId?.let { assertTrue(it.isNotEmpty()) }
273- println (" The instance ID is $instanceId " )
274- println (DASHES )
275-
276- println (DASHES )
277- println (" 6. Get more information about an amzn2 image and return the AMI value." )
278- val amiValue = instanceId?.let { describeImageSc(it) }
279- amiValue?.let { assertTrue(it.isNotEmpty()) }
280- println (" The AMI value is $amiValue ." )
281- println (DASHES )
282-
283- println (DASHES )
284- println (" 7. Get a list of instance types." )
285- var instanceType = getInstanceTypesSc()
286- assertTrue(instanceType.isNotEmpty())
287- println (DASHES )
288-
289- println (DASHES )
290- println (" 8. Create an instance." )
291- instanceType = " m5.large"
292- println (" Wait 1 min before creating the instance using $instanceType " )
293- // TimeUnit.MINUTES.sleep(1)
294- newInstanceId = runInstanceSc(instanceType, keyNameSc, groupNameSc, amiValue.toString())
295- assertTrue(newInstanceId.isNotEmpty())
296- println (DASHES )
297-
298- println (DASHES )
299- println (" 9. Display information about the running instance." )
300- var ipAddress = describeEC2InstancesSc(newInstanceId)
301- assertTrue(ipAddress.isNotEmpty())
302- println (" You can SSH to the instance using this command:" )
303- println (" ssh -i " + fileNameSc + " ec2-user@" + ipAddress)
304- println (DASHES )
305-
306- println (DASHES )
307- println (" 10. Stop the instance." )
308- stopInstanceSc(newInstanceId)
309- println (DASHES )
310-
311- println (DASHES )
312- println (" 11. Start the instance." )
313- startInstanceSc(newInstanceId)
314- ipAddress = describeEC2InstancesSc(newInstanceId)
315- ipAddress.let { assertTrue(it.isNotEmpty()) }
316- println (" You can SSH to the instance using this command:" )
317- println (" ssh -i " + fileNameSc + " ec2-user@" + ipAddress)
318- println (DASHES )
319-
320- println (DASHES )
321- println (" 12. Allocate an Elastic IP and associate it with the instance." )
322- val allocationId = allocateAddressSc()
323- allocationId?.let { assertTrue(it.isNotEmpty()) }
324- val associationId = associateAddressSc(newInstanceId, allocationId)
325- associationId?.let { assertTrue(it.isNotEmpty()) }
326- println (" The associate Id value is $associationId " )
327- println (DASHES )
328-
329- println (DASHES )
330- println (" 13. Describe the instance again." )
331- ipAddress = describeEC2InstancesSc(newInstanceId)
332- ipAddress.let { assertTrue(it.isNotEmpty()) }
333- println (" You can SSH to the instance using this command:" )
334- println (" ssh -i " + fileNameSc + " ec2-user@" + ipAddress)
335- println (DASHES )
336-
337- println (DASHES )
338- println (" 14. Disassociate and release the Elastic IP address." )
339- disassociateAddressSc(associationId)
340- releaseEC2AddressSc(allocationId)
341- println (DASHES )
342-
343- println (DASHES )
344- println (" 15. Terminate the instance and use a waiter." )
345- terminateEC2Sc(newInstanceId)
346- println (DASHES )
347-
348- println (DASHES )
349- println (" 16. Delete the security group." )
350- if (groupId != null ) {
351- deleteEC2SecGroupSc(groupId)
352- }
353- println (DASHES )
354-
355- println (DASHES )
356- println (" 17. Delete the key pair." )
357- deleteKeysSc(keyNameSc)
358- println (DASHES )
359- }
360-
361243 private suspend fun getSecretValues (): String {
362244 val secretName = " test/ec2"
363245 val valueRequest =
0 commit comments