List of usage examples for com.amazonaws.services.identitymanagement AmazonIdentityManagement getRole
GetRoleResult getRole(GetRoleRequest getRoleRequest);
Retrieves information about the specified role, including the role's path, GUID, ARN, and the role's trust policy that grants permission to assume the role.
From source file:com.haskins.cloudtrailviewer.dialog.resourcedetail.detailpanels.IamRoleDetail.java
License:Open Source License
@Override public String retrieveDetails(ResourceDetailRequest detailRequest) { String response = null;/*from ww w . j av a2 s. c o m*/ try { AmazonIdentityManagement client = new AmazonIdentityManagementClient(credentials); GetRoleRequest request = new GetRoleRequest(); request.setRoleName(detailRequest.getResourceName()); GetRoleResult result = client.getRole(request); buildUI(result); } catch (IllegalArgumentException | AmazonClientException e) { response = e.getMessage(); LOGGER.log(Level.WARNING, "Problem retrieving IAM Role details from AWS", e); } return response; }
From source file:com.netflix.spinnaker.clouddriver.ecs.deploy.ops.CreateServerGroupAtomicOperation.java
License:Apache License
private void checkRoleTrustRelations(String roleName) { updateTaskStatus("Checking role trust relations for: " + roleName); AmazonIdentityManagement iamClient = getAmazonIdentityManagementClient(); GetRoleResult response = iamClient.getRole(new GetRoleRequest().withRoleName(roleName)); Role role = response.getRole(); Set<IamTrustRelationship> trustedEntities = iamPolicyReader .getTrustedEntities(role.getAssumeRolePolicyDocument()); Set<String> trustedServices = trustedEntities.stream() .filter(trustRelation -> trustRelation.getType().equals("Service")) .map(IamTrustRelationship::getValue).collect(Collectors.toSet()); if (!trustedServices.contains(NECESSARY_TRUSTED_SERVICE)) { throw new IllegalArgumentException( "The " + roleName + " role does not have a trust relationship to ecs-tasks.amazonaws.com."); }/*w w w . j av a 2 s . c o m*/ }