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
}
}
Aggregations