CloudStore { boolean parseInstanceProfileArn(String profileArn) { if (!profileArn.startsWith("arn:aws:iam::")) { LOGGER.error("CloudStore: InstanceProfileArn does not start with 'arn:aws:iam::' : {}", profileArn); return false; } int idx = profileArn.indexOf(":instance-profile/"); if (idx == -1) { LOGGER.error("CloudStore: unable to parse InstanceProfileArn: {}", profileArn); return false; } final String awsProfile = profileArn.substring(idx + ":instance-profile/".length()); if (awsProfile.isEmpty()) { LOGGER.error("CloudStore: unable to extract profile/account data from InstanceProfileArn: {}", profileArn); return false; } idx = awsProfile.indexOf(','); if (idx == -1) { awsRole = awsProfile; } else { awsRole = awsProfile.substring(0, idx); } return true; } CloudStore(); void close(); void setHttpClient(HttpClient client); boolean isAwsEnabled(); AmazonS3 getS3Client(); AWSTemporaryCredentials assumeAWSRole(String account, String roleName, String principal,
                                                 Integer durationSeconds, String externalId); String getCloudAccount(String domainName);  }
@Test public void testParseInstanceProfileArn() { CloudStore store = new CloudStore(); assertTrue(store.parseInstanceProfileArn("arn:aws:iam::111111111111:instance-profile/athenz.zts,athenz")); assertEquals(store.awsRole, "athenz.zts"); store.close(); }