@Override public void execute(Context context) throws Exception { String name = resource.remoteInstanceProfile.getInstanceProfileName(); logger.info("delete instance profile and related role and policy, name={}", name); if (!resource.remoteInstanceProfile.getRoles().isEmpty()) { // if the associated role doesn't exist anymore, skip to delete (this is not expected state, cmn create role for every instance profile) AWS.iam.iam.removeRoleFromInstanceProfile(new RemoveRoleFromInstanceProfileRequest() .withInstanceProfileName(name) .withRoleName(name)); AWS.iam.iam.deleteRolePolicy(new DeleteRolePolicyRequest().withRoleName(name).withPolicyName(name)); AWS.iam.iam.deleteRole(new DeleteRoleRequest().withRoleName(name)); } AWS.iam.iam.deleteInstanceProfile(new DeleteInstanceProfileRequest().withInstanceProfileName(name)); }
@Override public void delete(DeleteRolePolicyRequest request) { delete(request, null); }
@Override public void delete(DeleteRolePolicyRequest request, ResultCapture<Void> extractor) { resource.performAction("Delete", request, extractor); }
/** * Performs the <code>Delete</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>RolePolicy</code> resource, and any conflicting parameter value set * in the request will be overridden: * <ul> * <li> * <b><code>RoleName</code></b> * - mapped from the <code>RoleName</code> identifier. * </li> * <li> * <b><code>PolicyName</code></b> * - mapped from the <code>Name</code> identifier. * </li> * </ul> * * <p> * * @see DeleteRolePolicyRequest */ void delete(DeleteRolePolicyRequest request);
/** * Performs the <code>Delete</code> action and use a ResultCapture to * retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>RolePolicy</code> resource, and any conflicting parameter value set * in the request will be overridden: * <ul> * <li> * <b><code>RoleName</code></b> * - mapped from the <code>RoleName</code> identifier. * </li> * <li> * <b><code>PolicyName</code></b> * - mapped from the <code>Name</code> identifier. * </li> * </ul> * * <p> * * @see DeleteRolePolicyRequest */ void delete(DeleteRolePolicyRequest request, ResultCapture<Void> extractor);