Skip to content

ec2: "[WARNING] aws-cdk-lib.aws_ec2.InstanceProps#keyName is deprecated" appears when there are no references to keyName in the stack #30806

@paulgear

Description

@paulgear

Describe the bug

When building a VPC stack, the following deprecation warning appears:

[WARNING] aws-cdk-lib.aws_ec2.InstanceProps#keyName is deprecated.

The stack does not reference any EC2 instance or InstanceProps or keyName or keyPair directly. I think this is coming from a call to aws_ec2.NatProvider.instance_v2, but I can't be certain because there appears to be no reference to keyName or key_name in that module, nor can I find any evidence that there is a default value for keyName.

Expected Behavior

  1. We should not get deprecation warnings for features we aren't using.
  2. We should get deprecation warnings with more context so that we can log more accurate bug reports.

Current Behavior

When building a VPC stack, the following deprecation warning appears:

[WARNING] aws-cdk-lib.aws_ec2.InstanceProps#keyName is deprecated.

Reproduction Steps

I'll attempt to provide one of these at a later time.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.148.0 (build e5740c0)

Framework Version

No response

Node.js Version

v18.20.3

OS

Linux (Ubuntu 24.04 LTS in docker)

Language

Python

Language Version

3.12.3

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions