Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): Get StackOutputs in CDK application #8566

Open
rcollette opened this issue Jun 16, 2020 · 3 comments
Open

feat(cli): Get StackOutputs in CDK application #8566

rcollette opened this issue Jun 16, 2020 · 3 comments
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 package/tools Related to AWS CDK Tools or CLI

Comments

@rcollette
Copy link
Contributor

Use Case

I have an output

const output = new CfnOutput(this, 'BastionPublicIP', {
            exportName: 'bastion-public-ip',
            value: bastion.instancePublicIp,
            description: 'The public IP address of the bastion host'
        });

And I want a simple way where I can console out a message to the user for how to to connect to the bastion host, without having to write another shell script or application that has to parse the output json file.

console.log('Use the following ssh command to connect to the bastion host:');
console.log(`ssh ec2-user@${output.value}`)

Proposed Solution

Unfortunately, I am not aware of the internals of the cli, but it would seem like perhaps some form of protected callback method in the Stack or App might be provided.

There is Stack.resolve() but the documentation isn't clear as to what scenario it is used for.


This is a 🚀 Feature Request

@rcollette rcollette added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jun 16, 2020
@shivlaks
Copy link
Contributor

@rcollette I think what you're touching on is the programmatic usage of the CLI which would enable you to easily deploy stacks, write outputs wherever you would want with the instructions you want to share with the user.

Right now deploy will finish deploying all the stacks that were specified and the outputs will be written to a file (if specified) and console. The simplest way today would be to read that output file, which would be keyed under your stack name and print it out.

Out of curiosity, where would you want to be able to print your instructions out and how do you deploy your stacks today?

@rcollette
Copy link
Contributor Author

For something like deploying a bastion host, the user would run a CDK application. I am aware of the JSON output, but that requires launching a separate application since, unless I am unaware, there is no callback when the CLI has completed performing a deployment.

If there was some application callback method when deployment completes, then I could parse the json file in the same CDK application and write to the console, but it would seem more effective to return the same json data to that callback method, perhaps in a more general context object, allowing other completion data to be added as needed in the future (ex. a model of the stack current state?)

@SomayaB SomayaB added the package/tools Related to AWS CDK Tools or CLI label Jun 17, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jun 17, 2020
@shivlaks shivlaks added the effort/medium Medium work item – several days of effort label Jun 22, 2020
@shivlaks shivlaks added the p2 label Aug 21, 2020
@iDVB
Copy link

iDVB commented Dec 4, 2020

@shivlaks We would also love some way to hook into a "Post Deploy" step of the CLI.
Programmatic access to the CLI would be great... or some kind of Plugins API?

In Serverless Framework this can be done a number of ways or even building a custom plugin that can hook into various steps of the build and deploy process.

Our usecase is that we currently have SLS exporting a whitelist of CFN outputs as well as some custom ones stored statically in yaml... to a .env file which can then be baked into our frontend code buy most frameworks (CreateReactApp, GatsbyJS, NextJS etc.) Things like API endpoints etc.

Having plugin or programmatic access is required (beyond --outputs-file) as the above frameworks require prefexes on all things in the .env file. (eg. GATSBY_XXXX)

Doing this with SLS looks like this...
sls deploy > .env > gatsby build > fin

Doing this with CDK today looks like this...
CUSTOM_ENVS=blah make deploy > cdk deploy --outputs-file outputs.json > node out2env.js > .env > gatsby build > fin

Reallllly would love plugin or programmatic CLI support to wrap CDK is super warm fussy helpers so that frontend devs love CDK too.

@NGL321 NGL321 assigned rix0rrr and unassigned shivlaks Jan 25, 2021
@rix0rrr rix0rrr removed their assignment Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

5 participants