Netlify API: Redeploying an updated, data-driven file

Hi there,

I am currently trying to figure out the Netlify API. However since there are no descriptions to the function names in the API doc, I need to ask some stupid questions here, sorry. :pray:

I have an App where users can create lists of entries. Those lists are data driven and read more often then written.

At the moment those lists get rendered at build time with Eleventy and a database lookup, as well as through a lambda function redirect if the rendered page doesn’t exist.

This works like a charm for newly created lists. Until the next build run, a lamba ‘serverside renders’ my pages and when the build run comes along, those sites are now static content. Wohoo! JAMStack ftw. :partying_face:

Now I am trying to solve the case where the author of a list performs an update to an already existing list. Although It is not time critical, I want to ‘eventually’ have the new updated version be static content as well, so I am trying to do this via the Netlify deply API.

My first idea was to simply remove or invalidate the cache on the specific site. This way the redirect for new sites would grap again and the next build would render der the updated version of the page.

This however seems to not be supported by Netlifys atomic deploy design. :thinking:

Here is my current Idea

…do please tell me if this is feasable, not a good idea or completely bonkers. :nerd_face::see_no_evil:

When a list gets updated, a lambda function tells Netlify to

  1. listSiteDeploys
  2. getDeploy on the latest deploy
  3. createSiteDeploy with a copy of the previously gotten deploy, but with the updated file missing

And somehow I gues there could be a race condition if two of those functions run at the same time for different pages, but I did not find any mechanic to prvide locks on the deploy mechanic as a whole or to atomically sent an updated deploy for the currently active deploy.

Brainstormyness

Is that a feassable approach that just needs some tweeking or is it abnsolutely convoluted (seems a bit like that) ?

Are build hooks maybe something that could help me here?

Any other solutions to the same kind of problems that I should be aware of?

Any feedback is greatly appreciated.

:slight_smile:

It seems convoluted, but what you describe might work. You could also lock the latest deploy by updating it with locked: true as show in the API docs before doing the createSiteDeploy. All that aside, I think build hooks would be the option with the least work needed.

Hope that helps.

I saw the API for locking a deploy, yes. Unfortunatelly there is no description of any kind for what that actually does.

Do you know? What does ‘locking a deployment’ mean here? Can that deployment no longer be modified (I thought with atomic, that is not the case anyway?) Can no new deployment be made until the lock is removed or what is the mechanic here?

Hey @j-o-sh,

I don’t think you’ll get a better answer than the docs!