Search in sources :

Example 1 with DeleteRoleAliasRequest

use of software.amazon.awssdk.services.iot.model.DeleteRoleAliasRequest in project aws-greengrass-nucleus by aws-greengrass.

the class IotJobsUtils method cleanUpIotRoleForTest.

/**
 * Clean Up IoT/IAM roles for using TES.
 *
 * @param roleName      IAM role Name
 * @param roleAliasName IOT roleAlias name
 * @param certArn       IOT certificate Arn
 */
public static void cleanUpIotRoleForTest(IotClient iotClient, IamClient iamClient, String roleName, String roleAliasName, String certArn) {
    try {
        DeleteRoleAliasRequest deleteRoleAliasRequest = DeleteRoleAliasRequest.builder().roleAlias(roleAliasName).build();
        iotClient.deleteRoleAlias(deleteRoleAliasRequest);
    } catch (ResourceNotFoundException | NoSuchEntityException e) {
    // Ignore as role alias does not exist
    }
    try {
        DeleteRoleRequest deleteRoleRequest = DeleteRoleRequest.builder().roleName(roleName).build();
        iamClient.deleteRole(deleteRoleRequest);
    } catch (ResourceNotFoundException | NoSuchEntityException e) {
    // Ignore as role alias does not exist
    }
}
Also used : DeleteRoleRequest(software.amazon.awssdk.services.iam.model.DeleteRoleRequest) ResourceNotFoundException(software.amazon.awssdk.services.iot.model.ResourceNotFoundException) DeleteRoleAliasRequest(software.amazon.awssdk.services.iot.model.DeleteRoleAliasRequest) NoSuchEntityException(software.amazon.awssdk.services.iam.model.NoSuchEntityException)

Aggregations

DeleteRoleRequest (software.amazon.awssdk.services.iam.model.DeleteRoleRequest)1 NoSuchEntityException (software.amazon.awssdk.services.iam.model.NoSuchEntityException)1 DeleteRoleAliasRequest (software.amazon.awssdk.services.iot.model.DeleteRoleAliasRequest)1 ResourceNotFoundException (software.amazon.awssdk.services.iot.model.ResourceNotFoundException)1