Hey guys. I would like to publish my deployment ou...
# sst
a
Hey guys. I would like to publish my deployment outputs from CDK/SST into Slack, once the deployment finishes. I can do this in many ways, but I was thinking to use SST somehow when the process finishes, and using the Slack API do publish the results. Is the “script” construct designed to do this kind of things? Thanks.
d
I would heavily suggest doing this outside Cloudformation. Things like handling errors will be impossible, and things like ensuring it runs every time will be difficult.
a
Yes, I agree with that.
But I know SST has the “script” concept.
I thought you can execute things outside CF.
d
Github actions or any other CI tool will handle this trivially and likely already has something built.
a
Yeah, I’m using bitbucket pipelines, I was trying to avoid having more stuff there.
And put them in my infrastructure code.
But looks like it uses a Lambda.
I already have Lambda integrations with Slack API.
d
I believe
Script
is just a wrapper on
CustomResource
a
@thdxr do you think my use-case would make sense for Script?
Makes sense @Derek Kershner.
t
yeah I think that makes sense
a
I’m able to create scripts for different stages or the deployment?
Maybe I want to send a notification when the process starts, and when it ends?
t
yeah you can conditionally create the resources and passin the values you need forwarded to slack
a
Ok going to check.
Also what I like about this, is that I can re-use my Slack logic already existing in other lambdas.
Something I like is I can decouple my logic away from the CI/CD provider.
@Derek Kershner that was my initial intention, reusing + decoupling from Bitbucket.
d
just use the lack of a second message as indication of error?
a
Mmmm.
Good point.
I would need to handle reporting issues with the infrastructure code too.
d
If you have backend logic you'd like to use during the CI process, id just set up a tiny API.
a
Yeah that could be too.
d
like, if you need logic to decide the webhook url or something
a
Yeah, could be too.
Main goal was to reduce logic from the ci/cd.
And putting it into the Infra code… but well, that can also fail.
d
if this is your goal, you can just make a route that takes information and does everything needed for the CI/CD, but I would encourage you to think about why you are avoiding using CI/CD for its intended purpose as well. I have not used BitBucket, but something like github actions (and seed) can be controlled from code, similarly to the CDK, and would therefore achieve most benefits as well.
just advice though, of course, you know your constraints better than us.