Andreas
02/10/2021, 11:20 PMJay
Frank
--output-files
flag for sst deploy
- https://github.com/serverless-stack/serverless-stack/issues/94Andreas
02/11/2021, 7:46 AMAndreas
02/11/2021, 7:46 AM// Output the Endpoint Address so it can be used in post-deploy
new CfnOutput(this, 'HasuraDatabaseUserSecretArn', {
value: hasuraUserSecret.secretArn,
});
Jay
Andreas
02/11/2021, 5:28 PMAndreas
02/13/2021, 6:33 PMFrank
cdk deploy
, any other cdk commands accept the --outputs-file
flag?
• Is there any cdk command that consumes the outputs file as input?
• What's the outputted file format? (Might be helpful to share an example here)
• Does deploying a single stack (ie. cdk deploy stackA --outputs-file xxxx
) also outputs the file? Is the format the same for deploying all stacks (ie. cdk deploy --outputs-file xxxx
)?Frank
Andreas
02/14/2021, 12:31 AMcdk deploy
, any other cdk commands accept the --outputs-file
flag?
No, only deploy
accepts the flags —outputs-file
and the shorthand -O
• Is there any cdk command that consumes the outputs file as input?
No. I've been programmatically reading it in a post deploy script.
const cdkOutputsData = JSON.parse(readFileSync('cdk.outputs.json', 'utf-8'));
const masterSecretArn = cdkOutputsData['app-name-HasuraStack'].HasuraDatabaseMasterSecretArn;
• What's the outputted file format? (Might be helpful to share an example here)
# HasuraStack.ts
new cdk.CfnOutput(this, 'HasuraDatabaseUserSecretArn', {
value: hasuraUserSecret.secretArn,
});
new cdk.CfnOutput(this, 'HasuraDatabaseMasterSecretArn', {
value: hasuraDatabase.secret!.secretArn,
});
cdk deploy --outputs-file cdk.outputs.json
# cdk.outputs.json
{
"app-name-HasuraStack": {
"HasuraDatabaseMasterSecretArn": "arn:aws:secretsmanager:us-west-2:123:secret:HasuraDatabaseSecret123",
"HasuraDatabaseUrlSecretArn": "arn:aws:secretsmanager:us-west-2:123:secret:AppName-HasuraDatabaseUrl-123"
},
"app-name-CognitoStack": {
"UserPoolId": "us-west-2_123",
"ValidateEmailEndpoint865F3B39": "<<https://123.execute-api.us-west-2.amazonaws.com/prod/>>"
},
}
• Does deploying a single stack (ie. cdk deploy stackA --outputs-file xxxx
) also outputs the file? Is the format the same for deploying all stacks (ie. cdk deploy --outputs-file xxxx
)?
Yes it does, with the same format. When only deploying one stack in a multistack environment the output file will only include that stack and have this format:
{
"myStackOne": {
"MyStackOneArn": "arn:aws:s3:::mystackone-1234"
}
}
Frank
Frank
yarn
at the root
• Run yarn test
to make sure the tests pass
• All the cli options are defined in packages/cli/bin/scripts.js
. SST uses yargs to parse the options. This is their doc http://yargs.js.org/docs/#api-reference-commandcmd-desc-builder-handler
• sst deploy
runs packages/cli/scripts/deploy.js
. There is a printResults
method that prints out stack outputs and exports to the terminal at the end of the deploy. The stackStates
object should have all the data you need to create the outputs file. One thing I'd check is that in the case some stacks deployed successfully and some failed, does cdk create the outputs file with partial data? Let's keep the behavior the same.
To test the deploy command, go into packages/cli/test/base
and run yarn
. And then you can run yarn deploy --outputs-file
to test your command. Currently there are 4 stacks in the base
project, feel free to change it as suited. Just don't commit the changes.Andreas
02/14/2021, 5:03 PMAndreas
02/14/2021, 5:17 PMdeploy.js
, right?Andreas
02/14/2021, 5:21 PMFrank
Frank