I'm trying to add an HttpApi to my project that already uses CDK v2.
I'm able to retrieve the HttpApi class from @aws-cdk/aws-apigatewayv2:
https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-apigatewayv2.HttpApi.html
But I'm not able to retrieve the construct in the new v2 aws-cdk-lib module:
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2-readme.html
Has the package been moved in v2?
Also, what is the difference between HttpApi and this https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_sam.CfnHttpApi.html?
Thanks :)
The CDK v2's L2 HttpApi construct is in @aws-cdk/aws-apigatewayv2-alpha. In CDK V2, experimental modules are published in separate "alpha" packages.
CfnHttpApi is the L1 construct that represents the CloudFormation AWS::ApiGatewayV2::Api resource. Under the hood, HttpApi has a CfnHttpApi as a child node. Cfn-prefixed constructs are published in aws-cdk-lib because they are stable.
Here's where to find the constructs:
| Package | CDK Version | Constructs |
|---|---|---|
| aws-cdk-lib | v2 | CfnHttpApi (L1, stable) |
| @aws-cdk/aws-apigatewayv2-alpha | v2 | HttpApi (L2, experimental) |
| @aws-cdk/aws-apigatewayv2 | v1 | HttpApi (L2, experimental), CfnHttpApi (L1, stable) |
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With