IAM { String assumeRolePolicyDocument() { String service = "ec2." + region.getDomain(); return "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"" + service + "\"},\"Action\":\"sts:AssumeRole\"}]}"; } IAM(AWSCredentialsProvider credentials, Regions region); ServerCertificate createServerCert(UploadServerCertificateRequest request); void deleteServerCert(String name); List<ServerCertificateMetadata> listServerCerts(String path); List<InstanceProfile> listInstanceProfiles(String path); InstanceProfile createInstanceProfile(String path, String name, String policy); ServerCertificate getServerCert(String serverCertName); Optional<Policy> findRolePolicy(String roleName, String policyName); void createRolePolicy(String roleName, String policyName, String policyJSON); final AmazonIdentityManagement iam; }
@Test void assumeRolePolicy() { IAM iam = new IAM(new DefaultAWSCredentialsProviderChain(), Regions.US_EAST_1); String document = iam.assumeRolePolicyDocument(); assertThat(document).contains("\"Service\":\"ec2.amazonaws.com\""); }
@Test void assumeRolePolicyWithChinaRegion() { IAM iam = new IAM(new DefaultAWSCredentialsProviderChain(), Regions.CN_NORTH_1); String document = iam.assumeRolePolicyDocument(); assertThat(document).contains("\"Service\":\"ec2.amazonaws.com.cn\""); }