Cleanup of unapproved assets in Cloudinary
Overview
Alongside moving to Cloudinary for our DAM, we are moving to Contentful as our CMS. In order to keep Cloudinary lean, we will be moving assets associated with unapproved products into cold storage. The main focus of this workflow was for when products are permanently removed from sale on the website and so the Digital Merchandising team would mark them for removal. However, the Digital Brand team also produce content related to specific products or that contains specific product assets. For this they will often use assets from the Digital Merchandising folder in Cloudinary. When we clean up assets that have been unapproved by Digital Merchandising, we need to ensure that those assets are also removed and/or replaced in any content in Contentful.
Workflow for unapproval
If a product is no longer going to be sold, the Digital Merchandising team will use the unapproved status in Hybris to mark it for removal from Cloudinary. The suggested architecture for this would be as follows, with the full details here:
At point 4, the Platform Notification lambda would send a message to Slack to say that the assets are going to be unapproved and moved to cold storage. In order to notify the Digital Brand team of how those changes could affect Contentful, we could enhance this message with a list of content entries that contain the URLs of the assets that are unapproved.
- A product SKU is unapproved in Hybris and a notification is sent to the Hybris API Gateway including the SKU(s) that are unapproved
- The API Gateway has a direct integration with Amazon EventBridge and sends the appropriate event to EventBridge
- An archive image event is registered in the Image Event Bus which calls the Cloudinary Archive Step Function
- The Step Function first calls the Contentful Search Lambda which calls the Cloudinary Search API to fetch all of the asset URLs that contain the unapproved SKU(s). The Lambda then uses the Contentful Content Delivery API to search for all instances of those asset URLs in Contentful, and returns a list of content entries that are using them and that will therefore be affected by the changes and need review
- The Step Function then calls the Platform Notification Lambda to send a message to Slack listing the assets that are going to be unapproved and content entries that are going to be affected
- The Step Function calls the Contentful Asset Replace Lambda - this step needs further thought and discussion, initial ideas below
- Next the Step Function calls the Cold Storage Lambda, which moves assets from Cloudinary to the S3 Glacier Flexible Retrieval storage
- After the assets have been successfully moved to storage, the Step Function calls the Cloudinary Delete Lambda which uses the Delete method of the Cloudinary Admin API
- The Step Function calls the Platform Notification Lambda to send a message to Slack to say that assets have been successfully moved
Contentful Asset Replacement
In the case where we know asset URLs and therefore the content entries that are going to be affected by the removal of specific assets from Cloudinary, we could:
- Remove the invalid URL from content entries. Depending on the component that is rendered by that content entry, we can either:
- Replace the URL with a generic placholder image in the JS component
- Conditionally render the JS component, so that when the image URL is removed the component will no longer render on the page
- After these changes have been made, the entry is unpublished and tagged as "needs review" for the team to review it
- If necessary, we could send another notification to Slack confirming that the previously listed content entries have been updated and remind the team that they need review
- After a certain timeframe, for example 3 months, any content entries with the tag "needs review" that are still unpublished can be archived