Skip to content

Commit

Permalink
refactor(runtime-values): deprecate @aws-cdk/runtime-values (#2724)
Browse files Browse the repository at this point in the history
The runtime-values module is no longer supported.
  • Loading branch information
Elad Ben-Israel authored and RomainMuller committed Jun 3, 2019
1 parent 56be82c commit 0b1bbf7
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 399 deletions.
52 changes: 1 addition & 51 deletions packages/@aws-cdk/runtime-values/README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,4 @@
## 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.
This module has been deprecated. Use environment variables or SSM parameters to publish values to runtime code.

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/runtime-values'

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.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/runtime-values/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './rtv';
throw new Error(`@aws-cdk/runtime-values is deprecated`);
85 changes: 0 additions & 85 deletions packages/@aws-cdk/runtime-values/lib/rtv.ts

This file was deleted.

16 changes: 1 addition & 15 deletions packages/@aws-cdk/runtime-values/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@aws-cdk/runtime-values",
"version": "0.33.0",
"description": "Runtime values support for the AWS CDK",
"deprecated": "This module has been deprecated. Use environment variables or SSM parameters to publish values to runtime code",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"jsii": {
Expand Down Expand Up @@ -55,25 +56,10 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert": "^0.33.0",
"@aws-cdk/aws-ec2": "^0.33.0",
"@aws-cdk/aws-lambda": "^0.33.0",
"@aws-cdk/aws-sqs": "^0.33.0",
"cdk-build-tools": "^0.33.0",
"cdk-integ-tools": "^0.33.0",
"pkglint": "^0.33.0"
},
"dependencies": {
"@aws-cdk/aws-iam": "^0.33.0",
"@aws-cdk/aws-ssm": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
"homepage": "https://github.com/awslabs/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-iam": "^0.33.0",
"@aws-cdk/aws-ssm": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
"engines": {
"node": ">= 8.10.0"
},
Expand Down
144 changes: 0 additions & 144 deletions packages/@aws-cdk/runtime-values/test/integ.rtv.lambda.expected.json

This file was deleted.

42 changes: 0 additions & 42 deletions packages/@aws-cdk/runtime-values/test/integ.rtv.lambda.ts

This file was deleted.

Loading

0 comments on commit 0b1bbf7

Please sign in to comment.