From ac421db10dbddb32d7a82344dde82833716eb54b Mon Sep 17 00:00:00 2001 From: SankyRed Date: Thu, 4 Apr 2024 14:36:56 -0500 Subject: [PATCH 1/2] apigatewayv2 end-to-end test --- tests/end-to-end.rs | 1 + tests/end-to-end/apigatewayv2/csharp/Stack.cs | 58 +++++++++++ tests/end-to-end/apigatewayv2/golang/stack.go | 79 +++++++++++++++ tests/end-to-end/apigatewayv2/java/Stack.diff | 98 +++++++++++++++++++ .../apigatewayv2/java/Stack.template.json | 75 ++++++++++++++ .../java/src/main/java/com/myorg/MyApp.java | 19 ++++ .../java/src/main/java/com/myorg/Stack.java | 64 ++++++++++++ tests/end-to-end/apigatewayv2/python/stack.py | 52 ++++++++++ tests/end-to-end/apigatewayv2/template.json | 64 ++++++++++++ .../apigatewayv2/typescript/Stack.diff | 98 +++++++++++++++++++ .../typescript/Stack.template.json | 75 ++++++++++++++ .../end-to-end/apigatewayv2/typescript/app.ts | 10 ++ .../apigatewayv2/typescript/stack.ts | 54 ++++++++++ 13 files changed, 747 insertions(+) create mode 100644 tests/end-to-end/apigatewayv2/csharp/Stack.cs create mode 100644 tests/end-to-end/apigatewayv2/golang/stack.go create mode 100644 tests/end-to-end/apigatewayv2/java/Stack.diff create mode 100644 tests/end-to-end/apigatewayv2/java/Stack.template.json create mode 100644 tests/end-to-end/apigatewayv2/java/src/main/java/com/myorg/MyApp.java create mode 100644 tests/end-to-end/apigatewayv2/java/src/main/java/com/myorg/Stack.java create mode 100644 tests/end-to-end/apigatewayv2/python/stack.py create mode 100644 tests/end-to-end/apigatewayv2/template.json create mode 100644 tests/end-to-end/apigatewayv2/typescript/Stack.diff create mode 100644 tests/end-to-end/apigatewayv2/typescript/Stack.template.json create mode 100644 tests/end-to-end/apigatewayv2/typescript/app.ts create mode 100644 tests/end-to-end/apigatewayv2/typescript/stack.ts diff --git a/tests/end-to-end.rs b/tests/end-to-end.rs index 8cabfeba..320eeb10 100644 --- a/tests/end-to-end.rs +++ b/tests/end-to-end.rs @@ -84,6 +84,7 @@ test_case!(cloudwatch, "CloudwatchStack", &["golang"]); test_case!(ecs, "EcsStack", &["java", "golang"]); test_case!(ec2, "Ec2Stack", &["java", "golang"]); test_case!(efs, "EfsStack", &["java", "golang"]); +test_case!(apigatewayv2, "ApiGatewayV2Stack", &["csharp", "golang", "python"]); // Add new test cases here diff --git a/tests/end-to-end/apigatewayv2/csharp/Stack.cs b/tests/end-to-end/apigatewayv2/csharp/Stack.cs new file mode 100644 index 00000000..5d68b942 --- /dev/null +++ b/tests/end-to-end/apigatewayv2/csharp/Stack.cs @@ -0,0 +1,58 @@ +using Amazon.CDK; +using Amazon.CDK.AWS.ApiGatewayV2; +using Constructs; +using System.Collections.Generic; + +namespace ApiGatewayV2Stack +{ + public class ApiGatewayV2StackProps : StackProps + { + } + + public class ApiGatewayV2Stack : Stack + { + /// + /// Endpoint for the HTTP API + /// + public object ApiEndpoint { get; } + + public ApiGatewayV2Stack(Construct scope, string id, ApiGatewayV2StackProps props = null) : base(scope, id, props) + { + + // Resources + var myApi = new CfnApi(this, "MyApi", new CfnApiProps + { + Name = "MyHttpApi", + ProtocolType = "HTTP", + Description = "My HTTP API", + }); + var defaultStage = new CfnStage(this, "DefaultStage", new CfnStageProps + { + ApiId = myApi.Ref, + StageName = "default", + AutoDeploy = true, + }); + var helloWorldIntegration = new CfnIntegration(this, "HelloWorldIntegration", new CfnIntegrationProps + { + ApiId = myApi.Ref, + IntegrationType = "HTTP_PROXY", + IntegrationUri = "https://jsonplaceholder.typicode.com/posts/1", + IntegrationMethod = "GET", + PayloadFormatVersion = "1.0", + }); + var helloWorldRoute = new CfnRoute(this, "HelloWorldRoute", new CfnRouteProps + { + ApiId = myApi.Ref, + RouteKey = "GET /hello", + Target = string.Join("/", new [] + { + "integrations", + helloWorldIntegration.Ref, + }), + }); + + // Outputs + ApiEndpoint = $"https://{myApi.Ref}.execute-api.{Region}.amazonaws.com/default"; + } + } +} diff --git a/tests/end-to-end/apigatewayv2/golang/stack.go b/tests/end-to-end/apigatewayv2/golang/stack.go new file mode 100644 index 00000000..0f8cc9eb --- /dev/null +++ b/tests/end-to-end/apigatewayv2/golang/stack.go @@ -0,0 +1,79 @@ +package main + +import ( + "fmt" + + cdk "github.com/aws/aws-cdk-go/awscdk/v2" + apigatewayv2 "github.com/aws/aws-cdk-go/awscdk/v2/awsapigatewayv2" + "github.com/aws/constructs-go/constructs/v10" + "github.com/aws/jsii-runtime-go" +) + +type ApiGatewayV2StackProps struct { + cdk.StackProps +} + +type ApiGatewayV2Stack struct { + cdk.Stack + /// Endpoint for the HTTP API + ApiEndpoint interface{} // TODO: fix to appropriate type +} + +func NewApiGatewayV2Stack(scope constructs.Construct, id string, props *ApiGatewayV2StackProps) *ApiGatewayV2Stack { + var sprops cdk.StackProps + if props != nil { + sprops = props.StackProps + } + stack := cdk.NewStack(scope, &id, &sprops) + + myApi := api_gateway_v2.NewCfnApi( + stack, + jsii.String("MyApi"), + &api_gateway_v2.CfnApiProps{ + Name: jsii.String("MyHttpApi"), + ProtocolType: jsii.String("HTTP"), + Description: jsii.String("My HTTP API"), + }, + ) + + api_gateway_v2.NewCfnStage( + stack, + jsii.String("DefaultStage"), + &api_gateway_v2.CfnStageProps{ + ApiId: myApi.Ref(), + StageName: jsii.String("default"), + AutoDeploy: jsii.Bool(true), + }, + ) + + helloWorldIntegration := api_gateway_v2.NewCfnIntegration( + stack, + jsii.String("HelloWorldIntegration"), + &api_gateway_v2.CfnIntegrationProps{ + ApiId: myApi.Ref(), + IntegrationType: jsii.String("HTTP_PROXY"), + IntegrationUri: jsii.String("https://jsonplaceholder.typicode.com/posts/1"), + IntegrationMethod: jsii.String("GET"), + PayloadFormatVersion: jsii.String("1.0"), + }, + ) + + api_gateway_v2.NewCfnRoute( + stack, + jsii.String("HelloWorldRoute"), + &api_gateway_v2.CfnRouteProps{ + ApiId: myApi.Ref(), + RouteKey: jsii.String("GET /hello"), + Target: cdk.Fn_Join(jsii.String("/"), &[]*string{ + jsii.String("integrations"), + helloWorldIntegration.Ref(), + }), + }, + ) + + return &ApiGatewayV2Stack{ + Stack: stack, + ApiEndpoint: jsii.String(fmt.Sprintf("https://%v.execute-api.%v.amazonaws.com/default", myApi.Ref(), stack.Region())), + } +} + diff --git a/tests/end-to-end/apigatewayv2/java/Stack.diff b/tests/end-to-end/apigatewayv2/java/Stack.diff new file mode 100644 index 00000000..9ceb989b --- /dev/null +++ b/tests/end-to-end/apigatewayv2/java/Stack.diff @@ -0,0 +1,98 @@ +diff --git a/./tests/end-to-end/apigatewayv2/template.json b/tests/end-to-end/apigatewayv2-java-working-dir/cdk.out/Stack.template.json +index fd7cdf1..442de83 100644 +--- a/./tests/end-to-end/apigatewayv2/template.json ++++ b/tests/end-to-end/apigatewayv2-java-working-dir/cdk.out/Stack.template.json +@@ -1,12 +1,11 @@ + { +- "AWSTemplateFormatVersion": "2010-09-09", + "Resources": { + "MyApi": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { ++ "Description": "My HTTP API", + "Name": "MyHttpApi", +- "ProtocolType": "HTTP", +- "Description": "My HTTP API" ++ "ProtocolType": "HTTP" + } + }, + "DefaultStage": { +@@ -15,8 +14,20 @@ + "ApiId": { + "Ref": "MyApi" + }, +- "StageName": "default", +- "AutoDeploy": true ++ "AutoDeploy": true, ++ "StageName": "default" ++ } ++ }, ++ "HelloWorldIntegration": { ++ "Type": "AWS::ApiGatewayV2::Integration", ++ "Properties": { ++ "ApiId": { ++ "Ref": "MyApi" ++ }, ++ "IntegrationMethod": "GET", ++ "IntegrationType": "HTTP_PROXY", ++ "IntegrationUri": "https://jsonplaceholder.typicode.com/posts/1", ++ "PayloadFormatVersion": "1.0" + } + }, + "HelloWorldRoute": { +@@ -28,9 +39,9 @@ + "RouteKey": "GET /hello", + "Target": { + "Fn::Join": [ +- "/", ++ "", + [ +- "integrations", ++ "integrations/", + { + "Ref": "HelloWorldIntegration" + } +@@ -38,27 +49,27 @@ + ] + } + } +- }, +- "HelloWorldIntegration": { +- "Type": "AWS::ApiGatewayV2::Integration", +- "Properties": { +- "ApiId": { +- "Ref": "MyApi" +- }, +- "IntegrationType": "HTTP_PROXY", +- "IntegrationUri": "https://jsonplaceholder.typicode.com/posts/1", +- "IntegrationMethod": "GET", +- "PayloadFormatVersion": "1.0" +- } + } + }, + "Outputs": { + "ApiEndpoint": { + "Description": "Endpoint for the HTTP API", + "Value": { +- "Fn::Sub": "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/default" ++ "Fn::Join": [ ++ "", ++ [ ++ "https://", ++ { ++ "Ref": "MyApi" ++ }, ++ ".execute-api.", ++ { ++ "Ref": "AWS::Region" ++ }, ++ ".amazonaws.com/default" ++ ] ++ ] + } + } + } + } +\ No newline at end of file +- +\ No newline at end of file diff --git a/tests/end-to-end/apigatewayv2/java/Stack.template.json b/tests/end-to-end/apigatewayv2/java/Stack.template.json new file mode 100644 index 00000000..442de838 --- /dev/null +++ b/tests/end-to-end/apigatewayv2/java/Stack.template.json @@ -0,0 +1,75 @@ +{ + "Resources": { + "MyApi": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Description": "My HTTP API", + "Name": "MyHttpApi", + "ProtocolType": "HTTP" + } + }, + "DefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "AutoDeploy": true, + "StageName": "default" + } + }, + "HelloWorldIntegration": { + "Type": "AWS::ApiGatewayV2::Integration", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "IntegrationMethod": "GET", + "IntegrationType": "HTTP_PROXY", + "IntegrationUri": "https://jsonplaceholder.typicode.com/posts/1", + "PayloadFormatVersion": "1.0" + } + }, + "HelloWorldRoute": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "RouteKey": "GET /hello", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "HelloWorldIntegration" + } + ] + ] + } + } + } + }, + "Outputs": { + "ApiEndpoint": { + "Description": "Endpoint for the HTTP API", + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "MyApi" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".amazonaws.com/default" + ] + ] + } + } + } +} \ No newline at end of file diff --git a/tests/end-to-end/apigatewayv2/java/src/main/java/com/myorg/MyApp.java b/tests/end-to-end/apigatewayv2/java/src/main/java/com/myorg/MyApp.java new file mode 100644 index 00000000..34c54ed6 --- /dev/null +++ b/tests/end-to-end/apigatewayv2/java/src/main/java/com/myorg/MyApp.java @@ -0,0 +1,19 @@ +//auto-generated +package com.myorg; +import software.amazon.awscdk.App; +import software.amazon.awscdk.AppProps; +import software.amazon.awscdk.DefaultStackSynthesizer; +import software.amazon.awscdk.StackProps; +public class MyApp { + public static void main(final String[] args) { + App app = new App(AppProps.builder() + .defaultStackSynthesizer(DefaultStackSynthesizer.Builder.create() + .generateBootstrapVersionRule(false) + .build()) + .build()); + new ApiGatewayV2Stack(app, "Stack", StackProps.builder() + .build()); + app.synth(); + + } +} diff --git a/tests/end-to-end/apigatewayv2/java/src/main/java/com/myorg/Stack.java b/tests/end-to-end/apigatewayv2/java/src/main/java/com/myorg/Stack.java new file mode 100644 index 00000000..ee9d6229 --- /dev/null +++ b/tests/end-to-end/apigatewayv2/java/src/main/java/com/myorg/Stack.java @@ -0,0 +1,64 @@ +package com.myorg; + +import software.constructs.Construct; + +import java.util.*; +import software.amazon.awscdk.CfnMapping; +import software.amazon.awscdk.CfnTag; +import software.amazon.awscdk.Stack; +import software.amazon.awscdk.StackProps; + +import software.amazon.awscdk.*; +import software.amazon.awscdk.services.apigatewayv2.*; + +class ApiGatewayV2Stack extends Stack { + private Object apiEndpoint; + + public Object getApiEndpoint() { + return this.apiEndpoint; + } + + public ApiGatewayV2Stack(final Construct scope, final String id) { + super(scope, id, null); + } + + public ApiGatewayV2Stack(final Construct scope, final String id, final StackProps props) { + super(scope, id, props); + + CfnApi myApi = CfnApi.Builder.create(this, "MyApi") + .name("MyHttpApi") + .protocolType("HTTP") + .description("My HTTP API") + .build(); + + CfnStage defaultStage = CfnStage.Builder.create(this, "DefaultStage") + .apiId(myApi.getRef()) + .stageName("default") + .autoDeploy(true) + .build(); + + CfnIntegration helloWorldIntegration = CfnIntegration.Builder.create(this, "HelloWorldIntegration") + .apiId(myApi.getRef()) + .integrationType("HTTP_PROXY") + .integrationUri("https://jsonplaceholder.typicode.com/posts/1") + .integrationMethod("GET") + .payloadFormatVersion("1.0") + .build(); + + CfnRoute helloWorldRoute = CfnRoute.Builder.create(this, "HelloWorldRoute") + .apiId(myApi.getRef()) + .routeKey("GET /hello") + .target(String.join("/", + "integrations", + helloWorldIntegration.getRef())) + .build(); + + this.apiEndpoint = "https://" + myApi.getRef() + ".execute-api." + this.getRegion() + ".amazonaws.com/default"; + CfnOutput.Builder.create(this, "CfnOutputApiEndpoint") + .key("ApiEndpoint") + .value(this.apiEndpoint.toString()) + .description("Endpoint for the HTTP API") + .build(); + + } +} diff --git a/tests/end-to-end/apigatewayv2/python/stack.py b/tests/end-to-end/apigatewayv2/python/stack.py new file mode 100644 index 00000000..91caefa8 --- /dev/null +++ b/tests/end-to-end/apigatewayv2/python/stack.py @@ -0,0 +1,52 @@ +from aws_cdk import Stack +import aws_cdk as cdk +import aws_cdk.aws_apigatewayv2 as apigatewayv2 +from constructs import Construct + +class ApiGatewayV2Stack(Stack): + def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: + super().__init__(scope, construct_id, **kwargs) + + # Resources + myApi = apigatewayv2.CfnApi(self, 'MyApi', + name = 'MyHttpApi', + protocol_type = 'HTTP', + description = 'My HTTP API', + ) + + defaultStage = apigatewayv2.CfnStage(self, 'DefaultStage', + api_id = myApi.ref, + stage_name = 'default', + auto_deploy = True, + ) + + helloWorldIntegration = apigatewayv2.CfnIntegration(self, 'HelloWorldIntegration', + api_id = myApi.ref, + integration_type = 'HTTP_PROXY', + integration_uri = 'https://jsonplaceholder.typicode.com/posts/1', + integration_method = 'GET', + payload_format_version = '1.0', + ) + + helloWorldRoute = apigatewayv2.CfnRoute(self, 'HelloWorldRoute', + api_id = myApi.ref, + route_key = 'GET /hello', + target = '/'.join([ + 'integrations', + helloWorldIntegration.ref, + ]), + ) + + # Outputs + """ + Endpoint for the HTTP API + """ + self.api_endpoint = f"""https://{myApi.ref}.execute-api.{self.region}.amazonaws.com/default""" + cdk.CfnOutput(self, 'CfnOutputApiEndpoint', + key = 'ApiEndpoint', + description = 'Endpoint for the HTTP API', + value = str(self.api_endpoint), + ) + + + diff --git a/tests/end-to-end/apigatewayv2/template.json b/tests/end-to-end/apigatewayv2/template.json new file mode 100644 index 00000000..fd7cdf1d --- /dev/null +++ b/tests/end-to-end/apigatewayv2/template.json @@ -0,0 +1,64 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Resources": { + "MyApi": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Name": "MyHttpApi", + "ProtocolType": "HTTP", + "Description": "My HTTP API" + } + }, + "DefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "StageName": "default", + "AutoDeploy": true + } + }, + "HelloWorldRoute": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "RouteKey": "GET /hello", + "Target": { + "Fn::Join": [ + "/", + [ + "integrations", + { + "Ref": "HelloWorldIntegration" + } + ] + ] + } + } + }, + "HelloWorldIntegration": { + "Type": "AWS::ApiGatewayV2::Integration", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "IntegrationType": "HTTP_PROXY", + "IntegrationUri": "https://jsonplaceholder.typicode.com/posts/1", + "IntegrationMethod": "GET", + "PayloadFormatVersion": "1.0" + } + } + }, + "Outputs": { + "ApiEndpoint": { + "Description": "Endpoint for the HTTP API", + "Value": { + "Fn::Sub": "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/default" + } + } + } + } + \ No newline at end of file diff --git a/tests/end-to-end/apigatewayv2/typescript/Stack.diff b/tests/end-to-end/apigatewayv2/typescript/Stack.diff new file mode 100644 index 00000000..cb1cde0a --- /dev/null +++ b/tests/end-to-end/apigatewayv2/typescript/Stack.diff @@ -0,0 +1,98 @@ +diff --git a/./tests/end-to-end/apigatewayv2/template.json b/tests/end-to-end/apigatewayv2-typescript-working-dir/cdk.out/Stack.template.json +index fd7cdf1..442de83 100644 +--- a/./tests/end-to-end/apigatewayv2/template.json ++++ b/tests/end-to-end/apigatewayv2-typescript-working-dir/cdk.out/Stack.template.json +@@ -1,12 +1,11 @@ + { +- "AWSTemplateFormatVersion": "2010-09-09", + "Resources": { + "MyApi": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { ++ "Description": "My HTTP API", + "Name": "MyHttpApi", +- "ProtocolType": "HTTP", +- "Description": "My HTTP API" ++ "ProtocolType": "HTTP" + } + }, + "DefaultStage": { +@@ -15,8 +14,20 @@ + "ApiId": { + "Ref": "MyApi" + }, +- "StageName": "default", +- "AutoDeploy": true ++ "AutoDeploy": true, ++ "StageName": "default" ++ } ++ }, ++ "HelloWorldIntegration": { ++ "Type": "AWS::ApiGatewayV2::Integration", ++ "Properties": { ++ "ApiId": { ++ "Ref": "MyApi" ++ }, ++ "IntegrationMethod": "GET", ++ "IntegrationType": "HTTP_PROXY", ++ "IntegrationUri": "https://jsonplaceholder.typicode.com/posts/1", ++ "PayloadFormatVersion": "1.0" + } + }, + "HelloWorldRoute": { +@@ -28,9 +39,9 @@ + "RouteKey": "GET /hello", + "Target": { + "Fn::Join": [ +- "/", ++ "", + [ +- "integrations", ++ "integrations/", + { + "Ref": "HelloWorldIntegration" + } +@@ -38,27 +49,27 @@ + ] + } + } +- }, +- "HelloWorldIntegration": { +- "Type": "AWS::ApiGatewayV2::Integration", +- "Properties": { +- "ApiId": { +- "Ref": "MyApi" +- }, +- "IntegrationType": "HTTP_PROXY", +- "IntegrationUri": "https://jsonplaceholder.typicode.com/posts/1", +- "IntegrationMethod": "GET", +- "PayloadFormatVersion": "1.0" +- } + } + }, + "Outputs": { + "ApiEndpoint": { + "Description": "Endpoint for the HTTP API", + "Value": { +- "Fn::Sub": "https://${MyApi}.execute-api.${AWS::Region}.amazonaws.com/default" ++ "Fn::Join": [ ++ "", ++ [ ++ "https://", ++ { ++ "Ref": "MyApi" ++ }, ++ ".execute-api.", ++ { ++ "Ref": "AWS::Region" ++ }, ++ ".amazonaws.com/default" ++ ] ++ ] + } + } + } + } +\ No newline at end of file +- +\ No newline at end of file diff --git a/tests/end-to-end/apigatewayv2/typescript/Stack.template.json b/tests/end-to-end/apigatewayv2/typescript/Stack.template.json new file mode 100644 index 00000000..442de838 --- /dev/null +++ b/tests/end-to-end/apigatewayv2/typescript/Stack.template.json @@ -0,0 +1,75 @@ +{ + "Resources": { + "MyApi": { + "Type": "AWS::ApiGatewayV2::Api", + "Properties": { + "Description": "My HTTP API", + "Name": "MyHttpApi", + "ProtocolType": "HTTP" + } + }, + "DefaultStage": { + "Type": "AWS::ApiGatewayV2::Stage", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "AutoDeploy": true, + "StageName": "default" + } + }, + "HelloWorldIntegration": { + "Type": "AWS::ApiGatewayV2::Integration", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "IntegrationMethod": "GET", + "IntegrationType": "HTTP_PROXY", + "IntegrationUri": "https://jsonplaceholder.typicode.com/posts/1", + "PayloadFormatVersion": "1.0" + } + }, + "HelloWorldRoute": { + "Type": "AWS::ApiGatewayV2::Route", + "Properties": { + "ApiId": { + "Ref": "MyApi" + }, + "RouteKey": "GET /hello", + "Target": { + "Fn::Join": [ + "", + [ + "integrations/", + { + "Ref": "HelloWorldIntegration" + } + ] + ] + } + } + } + }, + "Outputs": { + "ApiEndpoint": { + "Description": "Endpoint for the HTTP API", + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "MyApi" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".amazonaws.com/default" + ] + ] + } + } + } +} \ No newline at end of file diff --git a/tests/end-to-end/apigatewayv2/typescript/app.ts b/tests/end-to-end/apigatewayv2/typescript/app.ts new file mode 100644 index 00000000..f209fe1f --- /dev/null +++ b/tests/end-to-end/apigatewayv2/typescript/app.ts @@ -0,0 +1,10 @@ +// auto-generated! a human should update this! +import * as cdk from "aws-cdk-lib"; +import { ApiGatewayV2Stack } from "./stack"; +const app = new cdk.App({ + defaultStackSynthesizer: new cdk.DefaultStackSynthesizer({ + generateBootstrapVersionRule: false, + }), +}); +new ApiGatewayV2Stack(app, "Stack"); +app.synth(); diff --git a/tests/end-to-end/apigatewayv2/typescript/stack.ts b/tests/end-to-end/apigatewayv2/typescript/stack.ts new file mode 100644 index 00000000..4f654a4b --- /dev/null +++ b/tests/end-to-end/apigatewayv2/typescript/stack.ts @@ -0,0 +1,54 @@ +import * as cdk from 'aws-cdk-lib'; +import * as apigatewayv2 from 'aws-cdk-lib/aws-apigatewayv2'; + +export interface ApiGatewayV2StackProps extends cdk.StackProps { +} + +export class ApiGatewayV2Stack extends cdk.Stack { + /** + * Endpoint for the HTTP API + */ + public readonly apiEndpoint; + + public constructor(scope: cdk.App, id: string, props: ApiGatewayV2StackProps = {}) { + super(scope, id, props); + + // Resources + const myApi = new apigatewayv2.CfnApi(this, 'MyApi', { + name: 'MyHttpApi', + protocolType: 'HTTP', + description: 'My HTTP API', + }); + + const defaultStage = new apigatewayv2.CfnStage(this, 'DefaultStage', { + apiId: myApi.ref, + stageName: 'default', + autoDeploy: true, + }); + + const helloWorldIntegration = new apigatewayv2.CfnIntegration(this, 'HelloWorldIntegration', { + apiId: myApi.ref, + integrationType: 'HTTP_PROXY', + integrationUri: 'https://jsonplaceholder.typicode.com/posts/1', + integrationMethod: 'GET', + payloadFormatVersion: '1.0', + }); + + const helloWorldRoute = new apigatewayv2.CfnRoute(this, 'HelloWorldRoute', { + apiId: myApi.ref, + routeKey: 'GET /hello', + target: [ + 'integrations', + helloWorldIntegration.ref, + ].join('/'), + }); + + // Outputs + this.apiEndpoint = `https://${myApi.ref}.execute-api.${this.region}.amazonaws.com/default`; + new cdk.CfnOutput(this, 'CfnOutputApiEndpoint', { + key: 'ApiEndpoint', + description: 'Endpoint for the HTTP API', + value: this.apiEndpoint!.toString(), + }); + } +} From 3348d98976921a8a85c83d1a2a03aab8e0404bbf Mon Sep 17 00:00:00 2001 From: SankyRed Date: Tue, 16 Apr 2024 16:05:59 -0500 Subject: [PATCH 2/2] unskipping python and csharp --- tests/end-to-end.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/end-to-end.rs b/tests/end-to-end.rs index 320eeb10..8dc7dd1f 100644 --- a/tests/end-to-end.rs +++ b/tests/end-to-end.rs @@ -84,7 +84,7 @@ test_case!(cloudwatch, "CloudwatchStack", &["golang"]); test_case!(ecs, "EcsStack", &["java", "golang"]); test_case!(ec2, "Ec2Stack", &["java", "golang"]); test_case!(efs, "EfsStack", &["java", "golang"]); -test_case!(apigatewayv2, "ApiGatewayV2Stack", &["csharp", "golang", "python"]); +test_case!(apigatewayv2, "ApiGatewayV2Stack", &["golang"]); // Add new test cases here