https://serverless-stack.com/ logo
#help
Title
# help
s

Seth Geoghegan

05/06/2022, 8:15 PM
I'm wondering what the SST.Script Running After Deploy example looks like using the functional approach
I've got the AfterDeployStack defined using the functional style
Copy code
import { Script, StackContext, use } from "@serverless-stack/resources";
import { DbStack } from "./DbStack";

export function AfterDeployStack({ stack, app }: StackContext) {
  const { cluster } = use(DbStack);

  new Script(stack, "AfterDeploy", {
    defaults: {
      function: {
        environment: {
          DB_NAME: app.stageName,
          CLUSTER_ARN: cluster.clusterArn,
          SECRET_ARN: cluster.secretArn,
        },
        permissions: [cluster],
      },
    },
    onCreate: "src/database.create",
    onDelete: "src/database.remove",
  });

}
Trying to create tables in a shared RDS Cluster when running
sst start
and later remove them when the stack is removed
t

thdxr

05/06/2022, 9:54 PM
hey seth this is actually a gap I noticed yesterday when porting the docs which is why I haven't ported this yet
we're thinking about providing either 1.
app.getStack(MyStack)
so you can create dependencies or 2.
dependsOn(MyStack)
which would do this for you
s

Seth Geoghegan

05/06/2022, 10:15 PM
I see. No big deal, I can either use the class approach or simply use a regular `sst.Function`and manually invoke the feature via the SST Console.
t

thdxr

05/09/2022, 1:56 PM
@Seth Geoghegan I updated the Script doc to show functional stacks should be deployed in a few min. Note if you want to coordinate it centrally in the main file we also exported a
getStack(func)
function All available in 1.0.4
s

Seth Geoghegan

05/09/2022, 2:21 PM
Perfect timing, I'm looking at that right now! Thanks