Skip to content

(aws-autoscaling): Missing KeyPair field on autoScalingGroupProps #29237

@Brads3290

Description

@Brads3290

Describe the bug

Using the KeyName to specify a key pair will be deprecated on the launchTemplateProps construct.

When using KeyName on autoScalingGroupProps, CDK gives the following warning on synth:

[WARNING] aws-cdk-lib.aws_ec2.LaunchTemplateProps#keyName is deprecated.
  - Use `keyPair` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair
  This API will be removed in the next major release.

Presumably autoScalingGroupProps uses launchTemplateProps underneath. autoScalingGroupProps should have a KeyPair property that is passed to the underlying launchTemplateProps.

Expected Behavior

autoScalingGroupProps should have a KeyPair property that is passed to the underlying launchTemplateProps.

Current Behavior

[WARNING] aws-cdk-lib.aws_ec2.LaunchTemplateProps#keyName is deprecated.
  - Use `keyPair` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair
  This API will be removed in the next major release.

Reproduction Steps

var asg = new AutoScalingGroup(this, "Asg", new AutoScalingGroupProps() {
    Vpc = props.Vpc,
    VpcSubnets = new SubnetSelection() {
        AvailabilityZones = props.AvailabilityZone is not null
            ? new[] { props.AvailabilityZone }
            : null,
    },
    InstanceType = InstanceType.Of(InstanceClass.T3A, InstanceSize.MEDIUM),
    MachineImage = EcsOptimizedImage.AmazonLinux2023(),
    SecurityGroup = instanceSg,
    KeyName = props.Ec2KeyPair, // <-- This
});

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.129.0 (build d5ab0df)

Framework Version

No response

Node.js Version

v18.16.1

OS

MacOS

Language

.NET

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-autoscalingRelated to Amazon EC2 Auto ScalingbugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions