# lambda-cf-stack-inspection

> Describe the CloudFormation stack that a Lambda function belongs to

Latest version **1.0.1** (published 2016-10-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install lambda-cf-stack-inspection
pnpm add lambda-cf-stack-inspection
yarn add lambda-cf-stack-inspection
bun add lambda-cf-stack-inspection
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-10-23 |
| First published | 2016-10-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | https://www.npmjs.com/~tomdunn |
| Maintainers | tomdunn |
| Keywords | aws, cloudformation, lambda, configuration |

## Links

- npm: https://www.npmjs.com/package/lambda-cf-stack-inspection
- Repository: https://github.com/TomDunn/lambda-cf-stack-inspection
- Homepage: https://github.com/TomDunn/lambda-cf-stack-inspection#readme
- Issues: https://github.com/TomDunn/lambda-cf-stack-inspection/issues
- npm.io page: https://npm.io/package/lambda-cf-stack-inspection

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-10-23
- 1.0.0 — 2016-10-23

## README

# Inspect a Lambda's CloudFormation Stack

Helps [Lambda Functions][1] resolve dynamic configuration values such as the names of other resources in their [CloudFormation][2] stack.

Lambda functions do not currently support custom configuration variables (like ENV vars) so this makes it difficult to inject stage specific configuration variables. For example - the INTEGRATION stage of my Lambda function should use the INTEGRATION version of my DynamoDB table.

This module helps with that problem by using CloudFormation APIs to look up the other resources that belong to the same stack of the Lambda Function - in this way a Lambda function can discover resources using the logical IDs they were assigned in CloudFormation. It also provides access to the Stack Parameters and Stack Outputs.

This module assumes that it is being used by a Lambda Function that is managed by CloudFormation - it will not work otherwise.

## Installation

```sh
npm install --save lambda-cf-stack-inspection
```

## Usage

### Setting up the module

```javascript
const AWS = require('aws-sdk');
// configure the AWS SDK if needed, for example by setting the region
AWS.config.update({region: 'us-east-1'});

// requiring the module returns a factory function which takes the configued AWS SDK object
const cfUtil = require('lambda-cf-stack-inspection')(AWS);
```
### Using

```javascript
// CloudFormation has a concept of a physical resource ID. For the Lambda Functions this is the function name
// Here physicalResourceId could come from process.env.AWS_LAMBDA_FUNCTION_NAME
cfUtil.getStackDescriptionForResource(physicalResourceId).then(stackInfo => {
  stackInfo.resources(); // returns an array of CloudFormation resources in the stack
  stackInfo.resourcesByType(); // returns an object with structure: CloudFormationResourceType => [resources]
  stackInfo.resourcesByLogicalId(); // returns an object keyed by the LogicalId of the resources
  stackInfo.stackParameters(); // returns the stack parameters
  stackInfo.stackOutputs(); // returns the Outputs of the stack
});
```

[1]: https://aws.amazon.com/lambda/
[2]: https://aws.amazon.com/cloudformation/

---
_Source: https://npm.io/package/lambda-cf-stack-inspection · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
