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

[aws-lambda-python] Does not include allowPublicSubnets property #10018

Closed
ctSkennerton opened this issue Aug 27, 2020 · 0 comments · Fixed by #10022
Closed

[aws-lambda-python] Does not include allowPublicSubnets property #10018

ctSkennerton opened this issue Aug 27, 2020 · 0 comments · Fixed by #10022
Assignees
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. in-progress This issue is being actively worked on. needs-triage This issue or PR still needs to be triaged.

Comments

@ctSkennerton
Copy link

I get the following message when trying to use cdk deploy:

Lambda Functions in a public subnet can NOT access the internet. If you are aware of this limitation and would still like to place the function int a public subnet, set `allowPublicSubnet` to true

But it doesn't look like the @aws-cdk/aws-lambda-python type definition allows for that property as I get a compilation error

Reproduction Steps

import * as cdk from '@aws-cdk/core';
import * as lambda from '@aws-cdk/aws-lambda';
import * as pythonLambda from '@aws-cdk/aws-lambda-python';
import * as ec2 from '@aws-cdk/aws-ec2';

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

    let vpc = ec2.Vpc.fromLookup(this, 'VPC', {
      // This imports the default VPC but you can also
      // specify a 'vpcName' or 'tags'.
      isDefault: true,
    });

    // The code that defines your stack goes here
    const lambdaFunc = new pythonLambda.PythonFunction(this, 'Func', {
      runtime: lambda.Runtime.PYTHON_3_7,
      handler: 'lamda_handler',
      entry: './python-function',
      index: 'app.py',
      vpc: vpc,
      allowPublicSubnet: true
     });
  }
}

What did you expect to happen?

the compilation to occur successfully

What actually happened?

error TS2345: Argument of type '{ runtime: lambda.Runtime; handler: string; entry: string; index: string; timeout: cdk.Duration; ... 4 more ...; allowPublicSubnet: boolean; }' is not assignable to parameter of type 'PythonFunctionProps'.
  Object literal may only specify known properties, and 'allowPublicSubnet' does not exist in type 'PythonFunctionProps'.

111       allowPublicSubnet: true

Environment

  • **CLI Version : 1.61.0 (cdk --version)
  • **Framework Version: 1.61.0
  • Node.js Version: v14.6.0
  • **OS : MacOS catalina
  • Language (Version): typescript 3.9.7

Other


This is 🐛 Bug Report

@ctSkennerton ctSkennerton added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 27, 2020
@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Aug 31, 2020
@mergify mergify bot closed this as completed in #10022 Sep 1, 2020
mergify bot pushed a commit that referenced this issue Sep 1, 2020
…10022)

Fixes #10018.
Fixes #10027.

#9468 added a flag (`allowPublicSubnet`) to `FunctionProps`, but `PythonFunction` and `NodejsFunction` props derive from `FunctionOptions`. This renders these derived function constructs unable to bypass the public subnet check that occurs in the base `Function` construct. We can resolve this issue by moving `allowPublicSubnet` to `FunctionOptions`.

I also moved `filesystem` up to `FunctionOptions` while I was here.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. in-progress This issue is being actively worked on. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants