What's the best way to programmatically get the o...
# seed
r
What's the best way to programmatically get the outputs from a stack that's been deployed by seed.run?
t
if it's within the build you can use --outputs-file otherwise you can query cfn api
r
I've gone with querying the cfn api
WIP but this might be useful to someone:
Copy code
const AWS = require("aws-sdk");
const fs = require("fs");

AWS.config.update({ region: "us-east-1" });
const cloudFormation = new AWS.CloudFormation();

function formatStackOutputs(outputs) {
    return Object.fromEntries(outputs.map((o) => [o.OutputKey, o.OutputValue]));
}

async function main() {
    const stacks = await cloudFormation.describeStacks().promise();

    const stageName = process.env.SEED_STAGE_NAME;
    console.log("Stage name", stageName);
    const outputs = Object.fromEntries(
        stacks.Stacks.filter((s) => s.StackName.startsWith(stageName)).map((s) => [
            s.StackName,
            formatStackOutputs(s.Outputs),
        ])
    );
    console.log("Outputs", outputs);
    fs.writeFileSync("outputs.json", JSON.stringify(outputs, null, 2), "utf8");
}

main();