Skip to content

tomoki10/cdk-mentor

Repository files navigation

cdk-mentor

This library acts as a mentor to AWS CDK users, providing guidance and suggestions for better infrastructure coding practices. Inspired by cfn_nag.

Stability: Experimental

View on Construct Hub

Overview Image

cdk-mentor-demo

This library uses Aspects and is executed during the prepare phase.

phase

Introduction

% npm install -D cdk-mentor
import * as cdk from 'aws-cdk-lib';
import * as sns from 'aws-cdk-lib/aws-sns';
import { TestStack } from '../lib/test-stack';
import { CdkMentor } from 'cdk-mentor';

const app = new cdk.App();
const stack = new TestStack(app, 'TestStack');
cdk.Aspects.of(app).add(new CdkMentor());
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as sns from 'aws-cdk-lib/aws-sns';

export class TestStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    new sns.Topic(this, 'testTopic'); // Construct ID is NOT PascalCase
  }
}
% npx cdk synth -q
[Error at /TestStack/testTopic/Resource] [ERR:001]: Construct ID "testTopic"should be defined in PascalCase.
Found errors

Available Rules

  • Recommends PascalCase for Construct IDs
  • Avoid Stack or Construct in Construct IDs
  • Detecte strong cross-stack references

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published