Search in sources :

Example 6 with AmazonIdentityManagement

use of com.amazonaws.services.identitymanagement.AmazonIdentityManagement in project aws-doc-sdk-examples by awsdocs.

the class CreatePolicy method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply a policy name\n" + "Ex: CreatePolicy <policy-name>\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String policy_name = args[0];
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    CreatePolicyRequest request = new CreatePolicyRequest().withPolicyName(policy_name).withPolicyDocument(POLICY_DOCUMENT);
    CreatePolicyResult response = iam.createPolicy(request);
    System.out.println("Successfully created policy: " + response.getPolicy().getPolicyName());
}
Also used : CreatePolicyRequest(com.amazonaws.services.identitymanagement.model.CreatePolicyRequest) CreatePolicyResult(com.amazonaws.services.identitymanagement.model.CreatePolicyResult) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Example 7 with AmazonIdentityManagement

use of com.amazonaws.services.identitymanagement.AmazonIdentityManagement in project aws-doc-sdk-examples by awsdocs.

the class CreateUser method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply a username\n" + "Ex: CreateUser <username>\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String username = args[0];
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    CreateUserRequest request = new CreateUserRequest().withUserName(username);
    CreateUserResult response = iam.createUser(request);
    System.out.println("Successfully created user: " + response.getUser().getUserName());
}
Also used : CreateUserResult(com.amazonaws.services.identitymanagement.model.CreateUserResult) CreateUserRequest(com.amazonaws.services.identitymanagement.model.CreateUserRequest) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Example 8 with AmazonIdentityManagement

use of com.amazonaws.services.identitymanagement.AmazonIdentityManagement in project aws-doc-sdk-examples by awsdocs.

the class AccessKeyLastUsed method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply an access key id\n" + "Ex: AccessKeyLastUsed <access-key-id>\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String access_id = args[0];
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    GetAccessKeyLastUsedRequest request = new GetAccessKeyLastUsedRequest().withAccessKeyId(access_id);
    GetAccessKeyLastUsedResult response = iam.getAccessKeyLastUsed(request);
    System.out.println("Access key was last used at: " + response.getAccessKeyLastUsed().getLastUsedDate());
}
Also used : GetAccessKeyLastUsedResult(com.amazonaws.services.identitymanagement.model.GetAccessKeyLastUsedResult) GetAccessKeyLastUsedRequest(com.amazonaws.services.identitymanagement.model.GetAccessKeyLastUsedRequest) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Example 9 with AmazonIdentityManagement

use of com.amazonaws.services.identitymanagement.AmazonIdentityManagement in project aws-doc-sdk-examples by awsdocs.

the class DeleteAccessKey method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply a username and access key id\n" + "Ex: DeleteAccessKey <username> <access-key-id>\n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String username = args[0];
    String access_key = args[1];
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    DeleteAccessKeyRequest request = new DeleteAccessKeyRequest().withAccessKeyId(access_key).withUserName(username);
    DeleteAccessKeyResult response = iam.deleteAccessKey(request);
    System.out.println("Successfully deleted access key " + access_key + " from user " + username);
}
Also used : DeleteAccessKeyResult(com.amazonaws.services.identitymanagement.model.DeleteAccessKeyResult) DeleteAccessKeyRequest(com.amazonaws.services.identitymanagement.model.DeleteAccessKeyRequest) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Example 10 with AmazonIdentityManagement

use of com.amazonaws.services.identitymanagement.AmazonIdentityManagement in project aws-doc-sdk-examples by awsdocs.

the class DeleteServerCertificate method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply a certificate name\n" + "Ex: DeleteServerCertificate <certificate-name>\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String cert_name = args[0];
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    DeleteServerCertificateRequest request = new DeleteServerCertificateRequest().withServerCertificateName(cert_name);
    DeleteServerCertificateResult response = iam.deleteServerCertificate(request);
    System.out.println("Successfully deleted server certificate " + cert_name);
}
Also used : DeleteServerCertificateRequest(com.amazonaws.services.identitymanagement.model.DeleteServerCertificateRequest) DeleteServerCertificateResult(com.amazonaws.services.identitymanagement.model.DeleteServerCertificateResult) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Aggregations

AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)22 AmazonServiceException (com.amazonaws.AmazonServiceException)2 AttachedPolicy (com.amazonaws.services.identitymanagement.model.AttachedPolicy)2 ListAttachedRolePoliciesRequest (com.amazonaws.services.identitymanagement.model.ListAttachedRolePoliciesRequest)2 ListAttachedRolePoliciesResult (com.amazonaws.services.identitymanagement.model.ListAttachedRolePoliciesResult)2 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)2 AmazonClientException (com.amazonaws.AmazonClientException)1 AccessKeyMetadata (com.amazonaws.services.identitymanagement.model.AccessKeyMetadata)1 AttachRolePolicyRequest (com.amazonaws.services.identitymanagement.model.AttachRolePolicyRequest)1 CreateAccessKeyRequest (com.amazonaws.services.identitymanagement.model.CreateAccessKeyRequest)1 CreateAccessKeyResult (com.amazonaws.services.identitymanagement.model.CreateAccessKeyResult)1 CreateAccountAliasRequest (com.amazonaws.services.identitymanagement.model.CreateAccountAliasRequest)1 CreateAccountAliasResult (com.amazonaws.services.identitymanagement.model.CreateAccountAliasResult)1 CreatePolicyRequest (com.amazonaws.services.identitymanagement.model.CreatePolicyRequest)1 CreatePolicyResult (com.amazonaws.services.identitymanagement.model.CreatePolicyResult)1 CreateUserRequest (com.amazonaws.services.identitymanagement.model.CreateUserRequest)1 CreateUserResult (com.amazonaws.services.identitymanagement.model.CreateUserResult)1 DeleteAccessKeyRequest (com.amazonaws.services.identitymanagement.model.DeleteAccessKeyRequest)1 DeleteAccessKeyResult (com.amazonaws.services.identitymanagement.model.DeleteAccessKeyResult)1 DeleteAccountAliasRequest (com.amazonaws.services.identitymanagement.model.DeleteAccountAliasRequest)1