(CLI): output machine readable stack output information in all stack related cli operations.
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Description
Stack outputs are a useful abstraction which allows easier integration with downstream tools and processes.
Currently the outputs can only be retrieved programatically by reading the outputs file produced by `cdk deploy -O `.
Provide a way to retrieve the outputs from `cdk diff` and `cdk list` commands.
### Use Case
There are situations when downstream tools need to consume the infrastructure created by the cdk. Typically this is achieved by creating Cloudformation outputs which are treated as the contract between the implemented infrastructure and the rest of the world:
1. create the CDK resources
2. create the outputs required for the integration to work, e.g - expose the name of an S3 bucket.
3. Update the custom process to use the new CDK outputs e.g `./custom_automation.sh deploy --inputs-file cdk-outputs.json`
This works fine for deployments
```sh
$ cdk deploy --outputs-file cdk-outputs.json
#....
$./custom_automation.sh --inputs-file outputs.json
```
but not if we diff or simply try to test the contract between the CDK and our custom process:
```sh
$ cdk diff # does not have --outputs-file option
$ ./custom_automation.sh diff --inputs-file ....
```
In fact there's no way to test the contract unless we deploy the cdk app first.
Ideally the CDK should treat stack outputs as first class citizens and show them in all stack lifecycle commands - deploy, diff, info etc.
### Proposed Solution
Print machine readable information about the outputs when using stack management commands:
For example:
info
```sh
$ cdk list -l
- id: Stack1
name: Stack1
environment:
account: "123456789012"
region: us-east-1
name: aws://123456789012/us-east-1
outputs:
BucketName: {"Fn::Sub":" .........} # output not created yet
IamRoleArn: arn:aws:iam::123456789012:role/FooRole # output created in previous iterations
```
diff
```sh
$ cdk diff --outputs-file cdk-outputs.json
```
destroy
```sh
$ cdk destroy --outputs-file cdk-removed-outputs.json`
```
synthezise:
- add `.artifacts..outputs` section in `manifests.json` for each stack
### Other information
_No response_
### Acknowledge
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
Contributor guide
Research direction
Start by tracing the existing `cdk deploy --outputs-file` flow, then compare the `cdk diff`, `cdk list`, `cdk destroy`, and synthesize operations named in the issue. Review `manifests.json` and define how planned and previously created outputs should be represented; done means stack-related commands expose consistent machine-readable outputs without requiring deployment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cli, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100