Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A linter for the AWS Construct Library's API. It reflects a construct library's module via it's .jsii manifest and checks that the module adheres to the AWS Resource Construct Design Guidelines.


First, the module must be built through jsii (the linter reads the .jsii manifest).

Now, if you simply run awslint from a module directory, you will see a list of diagnostic messages.

For example:

$ cd @aws-cdk/aws-sns
$ awslint
@aws-cdk/aws-sns.ISubscription -- warning: every resource must have a resource interface [resource-interface]
@aws-cdk/aws-sns.ITopicPolicy -- warning: every resource must have a resource interface [resource-interface]

Each diagnostics includes the following elements:

@aws-cdk/aws-sns.ISubscription -- warning: every resource must have a resource interface [resource-interface]
[----------------------------]    [------] [-------------------------------------------] [------------------]
               ^                     ^                          ^                                 ^
               |                     |                          |                                 |
             scope                 level                     message                             rule

Options and Configuration

awslint accepts options either through the command-line (i.e. --debug) or via an awslint key in the module's package.json.

  "awslint": {
    "debug": true


The --include and --exclude options can be used to specify which rules will be evaluated.

For example:

# evaluate only the "resource-props" and "import" rules in all scopes
$ awslint -i resource-props -i import

# evaluate only the "import" rule in all scopes besides ones that begin with "@aws-cdk/aws-s3"
$ awslint -i import -x "*:@aws-cdk/aws-s3*"

Filters are specified using the following pattern:


If a "*" suffix is provided, the component is treated as a prefix. Otherwise, it is evaluated as a full match.

If scope is not specified, all scopes are implied (*).


  • *:* - matches all rules in all scopes
  • *:@aws-cdk/aws-apigateway.IRestApi* - matches all rules in scopes that begin with @aws-cdk/aws-apigateway.IRestApi
  • resource-props - matches the resource-props rule in all scopes
  • resource-* - matches all rules that begin with resource-.
  • resource-*:@aws-cdk/aws-sns* - matches all resource- rules with scope that begins with @aws-cdk/aws-sns.

When a rule is excluded, it will be displayed as skipped: in the output and will always considered to pass.

Saving State

The --save option can be used to capture all failed linting rules and save them as excludes in the module's package.json file. This is useful to bootstrap the linting process and
progressively fix errors.

$ awslint --save
[shows errors]

$ cat package.json
  "awslint": {
    "exclude": [
      "...", // added by awslint --save
      "...", // added by awslint --save

$ awslint
[no errors]

If --save is specified, awslint will always exit with status code 0.

Output Options

  • Use --verbose to print all passing linter rules (disabled by default).
  • Use --quiet to hide all warnings and skips (just prints errors)

Listing Rules

To list all linter rules:

$ awslint list
module-name: module name must be @aws-cdk/aws-<namespace>
construct-ctor: signature of all construct constructors should be "scope, id, props"
resource-class: every resource must have a resource class (L2)

The AWS Resource Construct Design Guidelines document includes references for all rules. For example, see #resource-class for a discussion about the "resource-class" rule.

You can’t perform that action at this time.