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());
}
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());
}
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());
}
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);
}
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);
}
Aggregations