Java Code Examples for software.amazon.awssdk.regions.Region#AWS_GLOBAL

The following examples show how to use software.amazon.awssdk.regions.Region#AWS_GLOBAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AttachRolePolicy.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    final String USAGE =
            "To run this example, supply a role name that you can obtain from the AWS Console\n" +
                    "Ex: AttachRolePolicy <role-name> <policy-arn>\n";

    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String roleName = args[0];
    String policyArn = args[1];

    // snippet-start:[iam.java2.attach_role_policy.client] 
    Region region = Region.AWS_GLOBAL;
    IamClient iam = IamClient.builder()
            .region(region)
            .build();
    // snippet-end:[iam.java2.attach_role_policy.client]

    attachIAMRolePolicy(iam, roleName, policyArn);
}
 
Example 2
Source File: CreateAccountAlias.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply an alias which has to be digits\n" +
                        "Ex: CreateAccountAlias <alias>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String alias = args[0];
        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        createIAMAccountAlias(iam, alias);
    }
 
Example 3
Source File: DeletePolicy.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply a policy ARN value\n" +
                        "Ex: DeletePolicy <policy-arn>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }
        String policyARN = args[0];

        // Create the IamClient object
        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        deleteIAMPolicy(iam, policyARN);
    }
 
Example 4
Source File: DeleteAccessKey.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
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 accessKey = args[1];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        deleteKey(iam , username, accessKey);
    }
 
Example 5
Source File: UpdateUser.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply the current username and a new\n" +
                        "username. Ex:\n\n" +
                        "UpdateUser <current-name> <new-name>\n";

        if (args.length < 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String curName = args[0];
        String newName = args[1];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        updateIAMUser(iam, curName, newName) ;
    }
 
Example 6
Source File: IAMServiceIntegrationTest.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
@BeforeAll
public static void setUp() throws IOException {

    Region region = Region.AWS_GLOBAL;
    iam =  IamClient.builder().region(region).build();

    try (InputStream input = IAMServiceIntegrationTest.class.getClassLoader().getResourceAsStream("config.properties")) {

        Properties prop = new Properties();
        prop.load(input);
        // Populate the data members required for all tests
        userName = prop.getProperty("userName");
        policyName= prop.getProperty("policyName");
        policyARN= prop.getProperty("policyARN");
        roleName=prop.getProperty("roleName");
        accountAlias=prop.getProperty("accountAlias");

        if (input == null) {
            System.out.println("Sorry, unable to find config.properties");
            return;
        }

    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
Example 7
Source File: AccessKeyLastUsed.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply an access key id that you can ontain from the AWS Console\n" +
                        "Ex: AccessKeyLastUsed <access-key-id>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String accessId = args[0];

        //Create an IamClient object
        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        getAccessKeyLastUsed(iam, accessId) ;
    }
 
Example 8
Source File: DeleteUser.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply a username\n" +
                        "Ex: DeleteUser <username>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String username = args[0];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        deleteIAMUser(iam, username);
    }
 
Example 9
Source File: UpdateServerCertificate.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply the current certificate name and\n" +
                        "a new name. Ex:\n\n" +
                        "UpdateServerCertificate <current-name> <new-name>\n";

        if (args.length != 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String curName = args[0];
        String newName = args[1];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();

        updateCertificate(iam, curName, newName) ;
    }
 
Example 10
Source File: DeleteAccountAlias.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply an account alias\n" +
                        "Ex: DeleteAccountAlias <account-alias>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String alias = args[0];
        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        deleteIAMAccountAlias(iam, alias) ;
    }
 
Example 11
Source File: DetachRolePolicy.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply a role name and policy arn\n" +
                        "Ex: DetachRolePolicy <role-name> <policy-arn>>\n";

        if (args.length != 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String roleName = args[0];
        String policyArn = args[1];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();

        detachPolicy(iam, roleName, policyArn);
        System.out.println("Done");

    }
 
Example 12
Source File: DeleteServerCertificate.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
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 certName = args[0];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        deleteCert(iam, certName) ;
    }
 
Example 13
Source File: UpdateAccessKey.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply a username, access key id and status\n" +
                        "Ex: UpdateAccessKey <username> <access-key-id> <Activate|Inactive>\n";
        if (args.length != 3) {
            System.out.println(USAGE);
            System.exit(1);
       }

        String username = args[0];
        String accessId = args[1];
        String status = args[2];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();
       }
 
Example 14
Source File: GetServerCertificate.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply a certificate name\n" +
                        "Ex: GetServerCertificate <certificate-name>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String certName = args[0];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();

        getCertificate(iam, certName );
    }
 
Example 15
Source File: CreateUser.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
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];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        String result = createIAMUser(iam, username) ;
        System.out.println("Successfully created user: " +result);

    }
 
Example 16
Source File: ListAccessKeys.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply an IAM  username\n" +
                        "Ex: ListAccessKeys <username>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }
        String username = args[0];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        listKeys(iam,username) ;
    }
 
Example 17
Source File: ListUsers.java    From aws-doc-sdk-examples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder()
                .region(region)
                .build();

        listAllUsers(iam );
    }
 
Example 18
Source File: GetPolicy.java    From aws-doc-sdk-examples with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {

        final String USAGE =
                "To run this example, supply a policy arn\n" +
                        "Ex: GetPolicy <policy-arn>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String policyArn = args[0];

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();

        getIAMPolicy(iam,policyArn);

    }
 
Example 19
Source File: ListAccountAliases.java    From aws-doc-sdk-examples with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();
        listAliases(iam);
    }
 
Example 20
Source File: ListServerCertificates.java    From aws-doc-sdk-examples with Apache License 2.0 3 votes vote down vote up
public static void main(String[] args) {

        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();

        listCertificates(iam);
    }