Skip to content

chore: upgrade CDK stack runtime, remove SDK v2, add WAF ACL - #67

Open
tukue wants to merge 2 commits into
mainfrom
backup/waf-runtime-upgrade
Open

chore: upgrade CDK stack runtime, remove SDK v2, add WAF ACL#67
tukue wants to merge 2 commits into
mainfrom
backup/waf-runtime-upgrade

Conversation

@tukue

@tukue tukue commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Description

Type of Change

  • Bug fix
  • New feature
  • Enhancement (improvement to existing functionality)
  • Documentation update
  • Refactoring / Tech debt
  • Dependency update
  • CI/CD change

Testing

  • npm run build passes
  • npm test passes
  • npm run lint passes (if applicable)
  • npm run synth passes (if applicable)

Platform Impact

Checklist

  • My code follows the project's code style
  • I have added tests that prove my fix/feature works
  • New and existing tests pass
  • I have updated documentation as needed

@tukue tukue self-assigned this Sep 8, 2026
@tukue tukue added the enhancement New feature or request label Sep 8, 2026

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This PR upgrades the CDK stack runtime to Node.js 24 and removes AWS SDK v2 dependencies, which aligns with AWS best practices. However, there are critical issues that must be addressed before merge.

Critical Issues Requiring Action

  1. Logic Error: The Lambda function removed all DynamoDB interaction code, but the CDK stack still configures DynamoDB permissions and environment variables. This creates a mismatch between infrastructure and application code.

  2. Security Vulnerability: The API Gateway CORS configuration allows all origins (gateway.Cors.ALL_ORIGINS), exposing the API to CSRF attacks and unauthorized access.

Recommended Actions

  • Restore DynamoDB client and operations in the Lambda function, OR remove DynamoDB-related infrastructure if not needed
  • Replace gateway.Cors.ALL_ORIGINS with specific allowed domain(s)
  • Align infrastructure configuration with actual Lambda function requirements

The WAFv2 additions are a positive security improvement. Please address the blocking issues before merging.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread lib/cdk-app-stack.ts Outdated
handler: 'handler',
runtime: lambda.Runtime.NODEJS_24_X,
environment: {
DYNAMODB_TABLE_NAME: dynamodbTable.tableName,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lambda function no longer interacts with DynamoDB after removing AWS SDK v2. Remove this environment variable or restore DynamoDB client in the Lambda function to match infrastructure expectations.

Comment thread lib/cdk-app-stack.ts Outdated
restApiName: "Demo API",
description: "Demo API with Lambda and DynamoDB",
defaultCorsPreflightOptions: {
allowOrigins: gateway.Cors.ALL_ORIGINS,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Security Vulnerability: Using gateway.Cors.ALL_ORIGINS exposes the API to any domain, enabling cross-site request forgery (CSRF) and unauthorized access1. Replace with specific allowed origins for production use.

Suggested change
allowOrigins: gateway.Cors.ALL_ORIGINS,
allowOrigins: [''], // Replace with your actual domain(s)

Footnotes

  1. CWE-346: Origin Validation Error - https://cwe.mitre.org/data/definitions/346.html

Comment thread lib/function.ts
};
import { APIGatewayEvent, Context, APIGatewayProxyResult } from 'aws-lambda';

export const handler = async (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: Lambda function removes all DynamoDB interaction code while the CDK stack (lines 34, 49 in cdk-app-stack.ts) still grants DynamoDB permissions and passes DYNAMODB_TABLE_NAME environment variable. This creates a mismatch where infrastructure expects database operations but the function cannot perform them. Either restore DynamoDB client initialization and operations in this function, or remove the DynamoDB-related infrastructure configuration if database access is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant