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

api-gateway: Immutable Constructs cannot be used for LambdaProxyIntegration and addRoutes #12201

Closed
dariusjs opened this issue Dec 22, 2020 · 1 comment
Labels
guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged.

Comments

@dariusjs
Copy link

dariusjs commented Dec 22, 2020

❓ General Issue

The Question

Similar to issue #6885 I've found that for the api-gatewayv2 the higher level constructs don't allow immutable objects. In the below code example "Functuon.fromFunctionArn" is a immutable construct.

The work around I copied form issue 6885 is as below. The commented out lines are the ones that are unsupported immutables.

const lambda = Function.fromFunctionArn(this, "lambda", importedLambdaArn);

const lambdaIntegration = new LambdaProxyIntegration({
  // handler: lambda
  handler: Object.defineProperty(lambda, Symbol.for('constructs.Construct.node'), {
    value: (lambda.node as any)._actualNode,
  }),
});


const httpApi = new HttpApi(this, 'HttpApi', {
  apiName: 'http-api',
});


httpApi.addRoutes({
  path: '/route',
  methods: [HttpMethod.GET],
  // integration: lambdaIntegration,
  integration: Object.defineProperty(lambdaIntegration, Symbol.for('constructs.Construct.node'), {
    value: (lambdaIntegration.bind as any)._actualNode,
  }),
});

Environment

  • CDK CLI Version: 1.78.0 (build 2c74f4c)
  • Module Version: 1.78.0
  • Node.js Version: v14.4.0
  • OS: macOs
  • Language (Version): Typescript 4.0.5

Other information

Not sure if I am just to eager using the higher level experimental constructs, but I'd like to know if I am going about this the right way.

@dariusjs dariusjs added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Dec 22, 2020
@dariusjs dariusjs changed the title api-gateway: Immutable Function cannot be used for LambdaProxyIntegration and addRoutes api-gateway: Immutable Constructs cannot be used for LambdaProxyIntegration and addRoutes Dec 22, 2020
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant