# @aws-cdk/rtv

> Runtime values support for the AWS CDK

Latest version **0.8.0** (published 2018-07-31) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @aws-cdk/rtv
pnpm add @aws-cdk/rtv
yarn add @aws-cdk/rtv
bun add @aws-cdk/rtv
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score; popular repo.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2018-07-31 |
| First published | 2018-07-31 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 64.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12916 |
| Author | Amazon Web Services |
| Maintainers | amzn-oss, eladb, romainmuller |
| Keywords | aws, cdk, rtv |

## Links

- npm: https://www.npmjs.com/package/@aws-cdk/rtv
- Repository: https://github.com/awslabs/aws-cdk
- Homepage: https://github.com/awslabs/aws-cdk#readme
- Issues: https://github.com/awslabs/aws-cdk/issues
- npm.io page: https://npm.io/package/@aws-cdk/rtv

## Dependencies (3)

- [@aws-cdk/cdk](https://npm.io/package/@aws-cdk/cdk.md) ^0.8.0+bb95676
- [@aws-cdk/aws-iam](https://npm.io/package/@aws-cdk/aws-iam.md) ^0.8.0+bb95676
- [@aws-cdk/aws-ssm](https://npm.io/package/@aws-cdk/aws-ssm.md) ^0.8.0+bb95676

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.8.0 (latest) — 2018-07-31

## README

## Runtime Values

The CDK allows apps to advertise values from __construction time__ to __runtime
code__. For example, consider code in a Lambda function which needs to know the
URL of the SQS queue created as part of your CDK app.

Runtime values are advertised as textual SSM parameters with the following key:

```
/rtv/<stack-name>/<package>/<name>
```

Therefore, in order to advertise a value you will need to:

1. Make the current stack name available as an environment variable to your
   runtime code. The convention is to use `RTV_STACK_NAME`.
2. Use the `RuntimeValue` construct in order to create the SSM parameter and
   specify least-privilege permissions.

For example, say we want to publish a queue's URL to a lambda function.

### Construction Code

```ts
import { RuntimeValue } from '@aws-cdk/rtv'

const queue = new Queue(this, 'MyQueue', { /* props.... */ });
const fn = new Lambda(this, 'MyFunction', { /* props... */ });
const fleet = new Fleet(this, 'MyFleet', { /* props... */ });

// this line defines an AWS::SSM::Parameter resource with the
// key "/rtv/<stack-name>/com.myorg/MyQueueURL" and the actual queue URL as value
const queueUrlRtv = new RuntimeValue(this, 'QueueRTV', {
    package: 'com.myorg',
    name: 'MyQueueURL',
    value: queue.queueUrl
});

// this line adds read permissions for this SSM parameter to the policies associated with
// the IAM roles of the Lambda function and the EC2 fleet
queueUrlRtv.grantRead(fn.role);
queueUrlRtv.grantRead(fleet.role);

// adds the `RTV_STACK_NAME` to the environment of the lambda function
// and the fleet (via user-data)
fn.env(RuntimeValue.ENV_NAME, RuntimeValue.ENV_VALUE);
fleet.env(RuntimeValue.ENV_NAME, RuntimeValue.ENV_VALUE);
```

### Runtime Code

Then, your runtime code will need to use the SSM Parameter Store AWS SDK in
order to format the SSM parameter key and read the value. In future releases, we
will provide runtime libraries to make this easy.

---
_Source: https://npm.io/package/@aws-cdk/rtv · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
