-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
@aws-cdk/aws-apigatewayv2Related to Amazon API Gateway v2Related to Amazon API Gateway v2bugThis issue is a bug.This issue is a bug.p1
Description
Trying to have lambda in a separate stack than the httpgateway results in a cyclic dependency.
Similar issues fixed earlier: #4010
Reproduction Steps
aws.ts
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from '@aws-cdk/core';
import { HttpGatewayStack } from '../lib/http-gateway-stack';
import LambdaStack from '../lib/lambda-stack'
const app = new cdk.App();
const lambdaStack = new LambdaStack(app, 'ApiLambdaStack')
new HttpGatewayStack(app, 'ApiHttpGatewayStack', {
handler: lambdaStack.function
});
Lambda Stack:
import * as cdk from '@aws-cdk/core'
import * as lambda from '@aws-cdk/aws-lambda';
import * as path from 'path';
export default class LambdaStack extends cdk.Stack {
public readonly function: lambda.Function
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props)
this.function = new lambda.Function(this, 'ApiLambda', {
runtime: lambda.Runtime.NODEJS_12_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(path.join(__dirname, '../../api')),
});
}
}
HttpGatewayStack:
import * as cdk from '@aws-cdk/core'
import * as httpGateway from '@aws-cdk/aws-apigatewayv2'
import * as lambda from '@aws-cdk/aws-lambda'
export class HttpGatewayStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: cdk.StackProps & {
handler: lambda.Function,
}) {
super(scope, id, props)
const api = new httpGateway.HttpApi(this, 'Api', {
defaultIntegration: new httpGateway.LambdaProxyIntegration({
handler: props.handler
}),
})
}
}
Error Log
Error: 'ApiLambdaStack' depends on 'ApiHttpGatewayStack' (ApiLambdaStack -> ApiHttpGatewayStack/Api/Resource.Ref). Adding this dependency (ApiHttpGatewayStack -> ApiLambdaStack/ApiLambda/Resource.Arn) would create a cyclic reference.
Environment
- **CLI Version 1.51
- **Framework Version: 1.51
- **Node.js Version: v12.18.2
- **OS : mac catalina
- **Language (Version): typescript 3.9
Kelbrad and moltar
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-apigatewayv2Related to Amazon API Gateway v2Related to Amazon API Gateway v2bugThis issue is a bug.This issue is a bug.p1