admin管理员组

文章数量:1122846

I am very new to AWS SDK and trying to understand how to test their libraries. In this one, I am trying to retrieve the available ec2 instances which works fine. But I couldn't figure out a way to write unit tests for it.

import software.amazon.awssdk.services.ec2.Ec2Client
import software.amazon.awssdk.services.ec2.model.Instance

fun getEc2ResourceList(): MutableList<CloudResource> {
        val ec2Response = ec2Client.describeInstances().reservations()
        val instanceList = ArrayList<Instance>()
    
        ec2Response.forEach {
            it.instances().forEach { instance ->
                instanceList.add(instance)
            }
        }
    
        val ec2List: MutableList<CloudResource> = ArrayList()
    
        for (instance in instanceList) {
           // Some Mapping 
           
          ec2List.add(instance)
        }

        return ec2List
    }

本文标签: amazon web servicesAWS SDK EC2 Client Unit Testing using KotlinStack Overflow