Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@almamedia-open-source/cdk-project-context

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@almamedia-open-source/cdk-project-context - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

15

API.md

@@ -436,2 +436,3 @@ # API Reference <a name="API Reference" id="api-reference"></a>

| [`getDefaultRegion`](#almamediaopensourcecdkprojectcontextprojectcontextgetdefaultregion) | *No description.* |
| [`getEnvironment`](#almamediaopensourcecdkprojectcontextprojectcontextgetenvironment) | *No description.* |
| [`getName`](#almamediaopensourcecdkprojectcontextprojectcontextgetname) | *No description.* |

@@ -545,2 +546,16 @@

##### `getEnvironment` <a name="@almamedia-open-source/cdk-project-context.ProjectContext.getEnvironment" id="almamediaopensourcecdkprojectcontextprojectcontextgetenvironment"></a>
```typescript
import { ProjectContext } from '@almamedia-open-source/cdk-project-context'
ProjectContext.getEnvironment(scope: Construct)
```
###### `scope`<sup>Required</sup> <a name="@almamedia-open-source/cdk-project-context.ProjectContext.parameter.scope" id="almamediaopensourcecdkprojectcontextprojectcontextparameterscope"></a>
- *Type:* [`constructs.Construct`](#constructs.Construct)
---
##### `getName` <a name="@almamedia-open-source/cdk-project-context.ProjectContext.getName" id="almamediaopensourcecdkprojectcontextprojectcontextgetname"></a>

@@ -547,0 +562,0 @@

4

lib/project-context.d.ts

@@ -38,4 +38,8 @@ import { Construct } from 'constructs';

static getAuthorEmail(scope: Construct): string | undefined;
/**
* @experimental
*/
static getEnvironment(scope: Construct): string;
private static getProjectContext;
private static getProjectAccountContext;
}

22

lib/project-context.js

@@ -17,7 +17,6 @@ "use strict";

const type = (scope.node.tryGetContext('account-type') ||
scope.node.tryGetContext('account') ||
scope.node.tryGetContext('a'));
scope.node.tryGetContext('account'));
if (typeof type !== 'string') {
// TODO decide if add annotation or throw?
aws_cdk_lib_1.Annotations.of(scope).addError('Account Type not specified! Provide account type as context argument for CDK CLI, for example: --context account=dev');
aws_cdk_lib_1.Annotations.of(scope).addError('Account Type not specified! Provide account type as context argument for CDK CLI, for example: --context account-type=dev');
}

@@ -76,2 +75,15 @@ return type;

}
/**
* @experimental
*/
static getEnvironment(scope) {
const environment = (scope.node.tryGetContext('environment-type') ||
scope.node.tryGetContext('environment') ||
scope.node.tryGetContext('env'));
if (typeof environment !== 'string') {
// TODO decide if add annotation or throw?
aws_cdk_lib_1.Annotations.of(scope).addError('Environment Type not specified! Provide environment type as context argument for CDK CLI, for example: --context environment-type=staging');
}
return environment;
}
static getProjectContext(scope) {

@@ -89,3 +101,3 @@ const projectContext = scope.node.tryGetContext(project_1.Project.CONTEXT_SCOPE);

_a = JSII_RTTI_SYMBOL_1;
ProjectContext[_a] = { fqn: "@almamedia-open-source/cdk-project-context.ProjectContext", version: "0.0.5" };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdC1jb250ZXh0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Byb2plY3QtY29udGV4dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLDZDQUEwQztBQUcxQyx1Q0FBb0M7Ozs7QUFHcEMsTUFBYSxjQUFjOzs7O0lBRXpCLE1BQU0sQ0FBQyxjQUFjLENBQUMsS0FBZ0I7UUFDcEMsTUFBTSxJQUFJLEdBQUcsQ0FDWCxLQUFLLENBQUMsSUFBSSxDQUFDLGFBQWEsQ0FBQyxjQUFjLENBQUM7WUFDeEMsS0FBSyxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsU0FBUyxDQUFDO1lBQ25DLEtBQUssQ0FBQyxJQUFJLENBQUMsYUFBYSxDQUFDLEdBQUcsQ0FBQyxDQUM5QixDQUFDO1FBRUYsSUFBSSxPQUFPLElBQUksS0FBSyxRQUFRLEVBQUU7WUFDNUIsMENBQ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GhvckVtYWlsKHNjb3BlOiBDb25zdHJ1Y3QpOiBzdHJpbmcgfCB1bmRlZmluZWQge1xuICAgIGNvbnN0IHByb2plY3RDb250ZXh0ID0gUHJvamVjdENvbnRleHQuZ2V0UHJvamVjdENvbnRleHQoc2NvcGUpO1xuICAgIHJldHVybiBwcm9qZWN0Q29udGV4dC5hdXRob3IuZW1haWw7XG4gIH1cblxuICBwcml2YXRlIHN0YXRpYyBnZXRQcm9qZWN0Q29udGV4dChzY29wZTogQ29uc3RydWN0KTogUHJvamVjdENvbmZpZ3VyYXRpb24ge1xuICAgIGNvbnN0IHByb2plY3RDb250ZXh0ID0gPFByb2plY3RDb25maWd1cmF0aW9uPnNjb3BlLm5vZGUudHJ5R2V0Q29udGV4dChQcm9qZWN0LkNPTlRFWFRfU0NPUEUpO1xuICAgIHJldHVybiBwcm9qZWN0Q29udGV4dDtcbiAgfVxuXG4gIHByaXZhdGUgc3RhdGljIGdldFByb2plY3RBY2NvdW50Q29udGV4dChzY29wZTogQ29uc3RydWN0KTogQWNjb3VudCB7XG4gICAgY29uc3QgYWNjb3VudFR5cGUgPSBQcm9qZWN0Q29udGV4dC5nZXRBY2NvdW50VHlwZShzY29wZSk7XG4gICAgY29uc3QgcHJvamVjdENvbnRleHQgPSBQcm9qZWN0Q29udGV4dC5nZXRQcm9qZWN0Q29udGV4dChzY29wZSk7XG4gICAgcmV0dXJuIHByb2plY3RDb250ZXh0LmFjY291bnRzW2FjY291bnRUeXBlXTtcbiAgfVxuXG5cbn1cbiJdfQ==
ProjectContext[_a] = { fqn: "@almamedia-open-source/cdk-project-context.ProjectContext", version: "0.0.6" };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdC1jb250ZXh0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Byb2plY3QtY29udGV4dC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLD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jb3BlOiBDb25zdHJ1Y3QpOiBzdHJpbmcge1xuICAgIGNvbnN0IHR5cGUgPSAoXG4gICAgICBzY29wZS5ub2RlLnRyeUdldENvbnRleHQoJ2FjY291bnQtdHlwZScpIHx8XG4gICAgICBzY29wZS5ub2RlLnRyeUdldENvbnRleHQoJ2FjY291bnQnKVxuICAgICk7XG5cbiAgICBpZiAodHlwZW9mIHR5cGUgIT09ICdzdHJpbmcnKSB7XG4gICAgICAvLyBUT0RPIGRlY2lkZSBpZiBhZGQgYW5ub3RhdGlvbiBvciB0aHJvdz9cbiAgICAgIEFubm90YXRpb25zLm9mKHNjb3BlKS5hZGRFcnJvcignQWNjb3VudCBUeXBlIG5vdCBzcGVjaWZpZWQhIFByb3ZpZGUgYWNjb3VudCB0eXBlIGFzIGNvbnRleHQgYXJndW1lbnQgZm9yIENESyBDTEksIGZvciBleGFtcGxlOiAtLWNvbnRleHQgYWNjb3VudC10eXBlPWRldicpO1xuICAgIH1cblxuICAgIHJldHVybiB0eXBlO1xuICB9XG5cbiAgc3RhdGljIGdldEFjY291bnRJZChzY29wZTogQ29uc3RydWN0KTogc3RyaW5nIHtcbiAgICBjb25zdCBhY2NvdW50ID0gUHJvamVjdENvbnRleHQuZ2V0UHJvamVjdEFjY291bnRDb250ZXh0KHNjb3BlKTtcbiAgICByZXR1cm4gYWNjb3VudC5pZDtcbiAgfVxuXG4gIHN0YXRpYyBnZXRBY2NvdW50Q29uZmlnKHNjb3BlOiBDb25zdHJ1Y3QsIGtleTogc3RyaW5nKTogYW55IHtcbiAgICBjb25zdCBhY2NvdW50ID0gUHJvamVjdENvbnRleHQuZ2V0UHJvamVjdEFjY291bnRDb250ZXh0KHNjb3BlKTtcbiAgICByZXR1cm4gYWNjb3VudC5jb25maWc/LltrZXldO1xuICB9XG5cbiAgc3RhdGljIGdldERlZmF1bHRSZWdpb24oc2NvcGU6IENvbnN0cnVjdCk6IHN0cmluZyB7XG4gICAgY29uc3QgcHJvamVjdENvbnRleHQgPS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50VHlwZShzY29wZSk7XG4gICAgY29uc3QgcHJvamVjdENvbnRleHQgPSBQcm9qZWN0Q29udGV4dC5nZXRQcm9qZWN0Q29udGV4dChzY29wZSk7XG4gICAgcmV0dXJuIHByb2plY3RDb250ZXh0LmFjY291bnRzW2FjY291bnRUeXBlXTtcbiAgfVxuXG5cbn1cbiJdfQ==

@@ -66,3 +66,3 @@ "use strict";

_a = JSII_RTTI_SYMBOL_1;
Project[_a] = { fqn: "@almamedia-open-source/cdk-project-context.Project", version: "0.0.5" };
Project[_a] = { fqn: "@almamedia-open-source/cdk-project-context.Project", version: "0.0.6" };
/**

@@ -69,0 +69,0 @@ * (experimental) Namespace/key how this tool internally keeps track of the project configuration.

@@ -80,3 +80,3 @@ {

},
"version": "0.0.5",
"version": "0.0.6",
"jest": {

@@ -83,0 +83,0 @@ "testMatch": [

@@ -95,3 +95,3 @@ # AWS CDK Project Context

3. Run CDK commands with `account` CLI context flag to **_select_ the desired account configuration**:
3. Run CDK commands with `account-type` (or shorthand: `account`) CLI context flag to **_select_ the desired account configuration**:
```shell

@@ -112,1 +112,33 @@ npx cdk deploy --context account=dev

| AccountBaseDomain | `example.net` |
### Application Environment Retrieval
Often you may want to deploy multiple different application environments – “isolated copies” of your CDK application such as feature environments – into same AWS account. To manage that, you need some kind of "modifier" which selects the target application environment.
You may use this utility to retrieve application _environment_ information. In the context of this utility, _environment_ is just a string value such as `staging` or `production` – not to be confused with [CDK environments](https://docs.aws.amazon.com/cdk/v2/guide/environments.html) (which instead define the target AWS Account & Region configuration for a stack).
1. Somewhere in your stacks you may use static method `ProjectContext.getEnvironment(scope)`:
```ts
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import { PC } from '@almamedia-open-source/cdk-project-context'; // Using the PC shorthand here
export class MyStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
// Get the default region for this project
new CfnOutput(this, 'Environment', { value: PC.getEnvironment(this) });
}
}
```
2. Specify `environment-type` (or shorthand: `environment` or `env`) CLI context flag to **_select_ the desired environment**:
```shell
npx cdk deploy --context account=dev --context environment=staging
```
3. You'll get the following CloudFormation outputs:
| Name | Example Value |
| :---------- | :------------ |
| Environment | `staging` |

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc