Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ec2: deprecation warning when using ec2.BastionHostLinux with default values. #25310

Open
nokok opened this issue Apr 26, 2023 · 2 comments
Open
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@nokok
Copy link

nokok commented Apr 26, 2023

Describe the bug

A warning will be generated if use the default values due to the use of a deprecated API in ec2.BastionHostLinux.

  console.warn
    [WARNING] aws-cdk-lib.aws_ec2.MachineImage#latestAmazonLinux is deprecated.
      use MachineImage.latestAmazonLinux2 instead
      This API will be removed in the next major release.

       8 |     const vpc = new cdk.aws_ec2.Vpc(this, "Vpc");
       9 |
    > 10 |     new cdk.aws_ec2.BastionHostLinux(this, "BastionHost", {
         |     ^
      11 |       vpc: vpc,
      12 |     });
      13 |   }

      at Object.print (node_modules/aws-cdk-lib/.warnings.jsii.js:83646:21)
      at Function.latestAmazonLinux (node_modules/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.js:139:37)
      at new BastionHostLinux (node_modules/aws-cdk-lib/aws-ec2/lib/bastion-host.ts:183:56)
      at new SandboxCdkStack (lib/sandbox-cdk-stack.ts:10:5)
      at Object.<anonymous> (test/sandbox-cdk.test.ts:9:17)

Expected Behavior

No warnings should be displayed.

Current Behavior

The following message is displayed:

aws-cdk-lib.aws_ec2.MachineImage#latestAmazonLinux is deprecated.
        Use MachineImage.latestAmazonLinux2 instead
        This API will be removed in the next major release.

Reproduction Steps

import * as cdk from "aws-cdk-lib";
import { Construct } from "constructs";

export class SandboxCdkStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    const vpc = new cdk.aws_ec2.Vpc(this, "Vpc");

    new cdk.aws_ec2.BastionHostLinux(this, "BastionHost", {
      vpc: vpc,
    });
  }
}

Possible Solution

Explicitly pass the machineImage argument.

Additional Information/Context

No response

CDK CLI Version

2.76.0

Framework Version

No response

Node.js Version

v18.14.2

OS

macOS

Language

Typescript

Language Version

No response

Other information

No response

@nokok nokok added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 26, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Apr 26, 2023
@pahud
Copy link
Contributor

pahud commented Apr 26, 2023

Yes but I am afraid the only solution is to specify machineImage for that to avoid breaking changes until the next major release. Having a PR to address that would require a feature flag I believe.

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. feature-request A feature should be added or improved. effort/medium Medium work item – several days of effort and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 26, 2023
@nokok
Copy link
Author

nokok commented Apr 28, 2023

Thanks for the reply!

It was certainly not a good idea to simply replace it as it could be a breaking change. I think I will close the draft PR (#25311 ) for now.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
3 participants