Example usage for com.amazonaws.auth.policy.actions ElasticBeanstalkActions AllElasticBeanstalkActions

List of usage examples for com.amazonaws.auth.policy.actions ElasticBeanstalkActions AllElasticBeanstalkActions

Introduction

In this page you can find the example usage for com.amazonaws.auth.policy.actions ElasticBeanstalkActions AllElasticBeanstalkActions.

Prototype

ElasticBeanstalkActions AllElasticBeanstalkActions

To view the source code for com.amazonaws.auth.policy.actions ElasticBeanstalkActions AllElasticBeanstalkActions.

Click Source Link

Document

Represents any action executed on Elastic Beanstalk.

Usage

From source file:org.dasein.prototype.iamc.AWS.java

License:Apache License

public boolean grantAccessToUser(String username, Service service) {
    String entityName;//from  w  ww  .  ja v a  2  s.c  om
    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;
}