
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@almamedia-open-source/cdk-project-context
Advanced tools
  [ use Project
instead of App
to initialize the CDK app:
import { Project } from '@almamedia-open-source/cdk-project-context';
// new Project instead of new App
const project = new Project({
name: 'my-cool-project',
author: {
organization: 'Acme Corp',
name: 'Mad Scientists',
email: 'mad.scientists@acme.example.com',
},
defaultRegion: 'eu-west-1', // defaults to one of: $CDK_DEFAULT_REGION, $AWS_REGION or us-east-1
accounts: {
dev: {
id: '111111111111',
config: {
baseDomain: 'example.net',
},
},
prod: {
id: '222222222222',
config: {
baseDomain: 'example.com',
},
},
},
})
Somewhere in your stacks you may use static methods of ProjectContext
class:
import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import { ProjectContext } from '@almamedia-open-source/cdk-project-context';
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, 'DefaultRegion', { value: ProjectContext.getDefaultRegion(this) });
// Get the project name
new CfnOutput(this, 'Name', { value: ProjectContext.getName(this) });
// Get information about the project author
new CfnOutput(this, 'AuthorOrganization', { value: ProjectContext.getAuthorOrganization(this) });
new CfnOutput(this, 'AuthorName', { value: ProjectContext.getAuthorName(this) });
new CfnOutput(this, 'AuthorEmail', { value: ProjectContext.getAuthorEmail(this) });
// Get AWS account specific configuration
new CfnOutput(this, 'AccountType', { value: ProjectContext.getAccountType(this) });
new CfnOutput(this, 'AccountId', { value: ProjectContext.getAccountId(this) });
new CfnOutput(this, 'AccountBaseDomain', { value: ProjectContext.getAccountConfig(this, 'baseDomain') });
}
}
There's also a shorthand alias PC
available, for example: PC.getAccountId(this)
.
Run CDK commands with account-type
(or shorthand: account
) CLI context flag to select the desired account configuration:
npx cdk deploy --context account=dev
You'll get the following CloudFormation outputs:
Name | Example Value |
---|---|
DefaultRegion | eu-west-1 |
Name | my-cool-project |
AuthorOrganization | Acme Corp |
AuthorName | Mad Scientists |
AuthorEmail | mad.scientists@acme.example.com |
AccountType | dev |
AccountId | 111111111111 |
AccountBaseDomain | example.net |
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 (which instead define the target AWS Account & Region configuration for a stack).
Somewhere in your stacks you may use static method ProjectContext.getEnvironment(scope)
:
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) });
}
}
Specify environment-type
(or shorthand: environment
or env
) CLI context flag to select the desired environment:
npx cdk deploy --context account=dev --context environment=staging
You'll get the following CloudFormation outputs:
Name | Example Value |
---|---|
Environment | staging |
FAQs
Opinionated CDK utility construct for managing project information & AWS account-specific configuration.
We found that @almamedia-open-source/cdk-project-context demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.