Is it possible to invoke a Lamda on deployment?

I’d like to invoke a Lamda on deployment to set the HTTP path for one of my other Lamdas in another service. Is this possible to do or am I thinking about going at this the wrong way? Are there other technologies that would suit me better or would this idea work? Since getting the path is possible with

${cf:${self:service}-${self:provider.stage}.ServiceEndpoint}

It seems possible to me. I’d like my entire deployment process to be automatic and setting this path automatically every time I deploy would be great. Any help is appreciated.

Invoking sounds like a fragile way to do this - what happens if the invoke to update the second service fails/times-out? Has the deployment of the first service failed? What if your invocation breaks the second service (e.g. incorrect endpoint update)? Now you have two broken services…

Usually I would use a DNS alias to point at the latest/active deployment, and point my dependent services to that (instead of directly at a specific service deployment endpoint). When it comes time to use a new version, you update the DNS record to point to the new version. This means you don’t need to touch the second service (and risk breaking it). This model also has the potential to use canary deployments (as long as your application can handle it).

Obviously this is all worst-case scenarios, but that’s what you have to plan for - you don’t get the “happy path” (all the time).

Thanks for your help that is a much more elegant solution. I’m looking now into route 53 thanks for the help!

It’s basically a blue/green deployment - look that up for countless examples if you haven’t seen it already.