List of usage examples for com.amazonaws.services.identitymanagement.model CreateGroupRequest CreateGroupRequest
public CreateGroupRequest(String groupName)
From source file:org.cloudfoundry.community.servicebroker.s3.service.Iam.java
License:Apache License
public Group createGroup(String groupName) { CreateGroupRequest request = new CreateGroupRequest(groupName); request.setPath(groupPath);// w w w.ja v a 2s . c o m CreateGroupResult result = iam.createGroup(request); return result.getGroup(); }
From source file:org.dasein.prototype.iamc.AWS.java
License:Apache License
public boolean grantAccessToUser(String username, Service service) { String entityName;/* w w w. j a v a 2s.com*/ Action action; switch (service) { case ElasticBeanstalk: entityName = "iamc-eb"; action = ElasticBeanstalkActions.AllElasticBeanstalkActions; break; case EC2: entityName = "iamc-ec2"; action = EC2Actions.AllEC2Actions; break; default: return false; } try { iamClient.getGroup(new GetGroupRequest(entityName)); } catch (NoSuchEntityException e) { iamClient.createGroup(new CreateGroupRequest(entityName)); } Policy policy = new Policy(entityName).withStatements( new Statement(Statement.Effect.Allow).withActions(action).withResources(new Resource("*"))); iamClient.putGroupPolicy(new PutGroupPolicyRequest(entityName, entityName, policy.toJson())); iamClient.addUserToGroup(new AddUserToGroupRequest(entityName, username)); return true; }