diff --git a/packages/@aws-cdk/aws-logs/package.json b/packages/@aws-cdk/aws-logs/package.json index 3b756b35832f6..43da43dca4c5e 100644 --- a/packages/@aws-cdk/aws-logs/package.json +++ b/packages/@aws-cdk/aws-logs/package.json @@ -77,5 +77,10 @@ }, "engines": { "node": ">= 8.10.0" + }, + "awslint": { + "exclude": [ + "props-no-arn-refs:@aws-cdk/aws-logs.CrossAccountDestinationProps.targetArn" + ] } } diff --git a/tools/awslint/lib/rules/construct.ts b/tools/awslint/lib/rules/construct.ts index d1b50276dde9c..de6926a0bd53e 100644 --- a/tools/awslint/lib/rules/construct.ts +++ b/tools/awslint/lib/rules/construct.ts @@ -211,4 +211,20 @@ constructLinter.add({ e.assert(!property.type.unionOfTypes, `${e.ctx.propsFqn}.${property.name}`); } } +}); + +constructLinter.add({ + code: 'props-no-arn-refs', + message: 'props should use strong types instead of attributes. props should not have "arn" suffix', + eval: e => { + if (!e.ctx.propsType) { return; } + if (!e.ctx.hasPropsArgument) { return; } + + // this rule only applies to L2 constructs + if (e.ctx.classType.name.startsWith('Cfn')) { return; } + + for (const property of e.ctx.propsType.ownProperties) { + e.assert(!property.name.toLowerCase().endsWith('arn'), `${e.ctx.propsFqn}.${property.name}`); + } + } }); \ No newline at end of file