aws-solutions / centralized-network-inspection-on-aws

Centralized Network Inspection on AWS configures the AWS resources needed to filter network traffic. This solution saves you time by automating the process of provisioning a centralized AWS Network Firewall to inspect traffic between your Amazon VPCs.
https://aws.amazon.com/solutions/implementations/centralized-network-inspection-on-aws
Apache License 2.0
39 stars 19 forks source link

Fails to build with latest Node & CDK #12

Closed Marakai closed 1 year ago

Marakai commented 3 years ago

Describe the bug

Using recent Node, NPM and CDK versions and following README, build fails with

> npm run build                          

> network-firewall-automation-solution@1.0.0 build
> tsc

lib/network-firewall-automation-solution-stack.ts:282:53 - error TS2345: Argument of type 'this' is not assignable to parameter of type 'Construct'.
  Type 'NetworkFirewallAutomationStack' is not assignable to type 'Construct'.
    Types of property 'node' are incompatible.
      Type 'ConstructNode' is missing the following properties from type 'ConstructNode': metadataEntry, addValidation

282     const cloudWatchLogGroup = new logs.CfnLogGroup(this, 'CloudWatchLogGroup', {
                                                        ~~~~

lib/network-firewall-automation-solution-stack.ts:287:5 - error TS2322: Type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/core/lib/cfn-condition").CfnCondition' is not assignable to type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/aws-logs/node_modules/@aws-cdk/core/lib/cfn-condition").CfnCondition'.
  Types of property 'expression' are incompatible.
    Type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/core/lib/cfn-condition").ICfnConditionExpression | undefined' is not assignable to type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/aws-logs/node_modules/@aws-cdk/core/lib/cfn-condition").ICfnConditionExpression | undefined'.
      Type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/core/lib/cfn-condition").ICfnConditionExpression' is not assignable to type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/aws-logs/node_modules/@aws-cdk/core/lib/cfn-condition").ICfnConditionExpression'.
        Types of property 'resolve' are incompatible.
          Type '(context: import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/core/lib/resolvable").IResolveContext) => any' is not assignable to type '(context: import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/aws-logs/node_modules/@aws-cdk/core/lib/resolvable").IResolveContext) => any'.
            Types of parameters 'context' and 'context' are incompatible.
              Type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/aws-logs/node_modules/@aws-cdk/core/lib/resolvable").IResolveContext' is not assignable to type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/core/lib/resolvable").IResolveContext'.
                The types of 'scope.node' are incompatible between these types.
                  Type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/aws-logs/node_modules/@aws-cdk/core/lib/construct-compat").ConstructNode' is not assignable to type 'import("/Users/marakai/Development/TPG/aws-network-firewall-deployment-automations-for-aws-transit-gateway/source/node_modules/@aws-cdk/core/lib/construct-compat").ConstructNode'.
                    Types have separate declarations of a private property 'host'.

287     cloudWatchLogGroup.cfnOptions.condition = isLoggingInCloudWatch;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

lib/network-firewall-automation-solution-stack.ts:452:43 - error TS2345: Argument of type 'this' is not assignable to parameter of type 'Construct'.

452     const logGroup = new logs.CfnLogGroup(this, "LogGroupFlowLogs", {
                                              ~~~~

Found 3 errors.

To Reproduce

Update NPM to 7.20.0 Update Node to 16.5.0 CDK version is 1.114.0

$ npm run build

Expected behavior

As per README should build without issues.

Please complete the following information about the solution:

gockle commented 3 years ago

@Marakai The current source code is configured to work for the cdk 1.77.0 and Node 15.X.X, For the source to compile with a newer version of Node and CDK, the code needs to be updated, specifically in how the new cdk patterns are used. These changes will be available in a newer release for the solution, I will add a task in the solution backlog to ensure that the changes are made.

AaronSchuetter commented 1 year ago

The solution has been updated to use CDK v2 and Node 16.