I'm wondering what the SST.Script <Running After D...
# help
s
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
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
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
@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
Perfect timing, I'm looking at that right now! Thanks