code: private AmazonEC2 getEC2Service() {
          String aWSAccessId = serverConfig.getAWSAccessId();
          String aWSSecretKey = serverConfig.getAWSSecretKey();
  
          AmazonEC2 ec2Service;
          if (null != aWSAccessId && !"".equals(aWSAccessId)
                  && null != aWSSecretKey && !"".equals(aWSSecretKey)) {
              ec2Service = new AmazonEC2Client(new BasicAWSCredentials(aWSAccessId, aWSSecretKey));
          } else {
              ec2Service = new AmazonEC2Client(new InstanceProfileCredentialsProvider());
          }
  
          String region = clientConfig.getRegion();
          region = region.trim().toLowerCase();
          ec2Service.setEndpoint("ec2." + region + ".amazonaws.com");
          return ec2Service;
      }
docs: Gets the EC2 service object to call AWS APIs.
  
  @return the EC2 service object to call AWS APIs.