Is there a way/plan to have a way to pass argument...
# general
h
Is there a way/plan to have a way to pass arguments that belong to aws.lambda.Function to classes like HttpServer?
l
Hi Mia!
Short answer: maybe. However, it depends on what you're trying to pass along.
Another very viable approach (where you want total control over things) is to use aws.apigateway.x.API
h
One use case is if I want to run the lambda function with python3.6 but have built out all my infrastructure through pulumi with javascript — I want to pass the handler/code in
l
Ah, in that case, i would not recommend HttpServer. That's a helper which is really dedicated to make it easy to serve up pure-javascript through Http
if you'd like to run some other sort of lambda (i.e. one that is python backed) here's the pseudo code for how you'd do it:
Copy code
const lambda = new aws.Lambda.Function("name", ...all your args that make sense for the python version...);
const api = new aws.apigateway.x.Api("name", {
    routes: [{
        path: "/yourpath",
        method: "GET",
        eventHandler: lambda,
    }]
});
This is basically what HttpServer is doing itself:
h
ok cool, so just break it down and implement it myself - that makes sense. I assume I’ll also have to do some manual configuration of IAM that would get done by pulumi if it were all JS
l
yes. that's likely true
h
any status update on your python docs?
l
Looks liek we attach these policies:
Copy code
aws.iam.AWSLambdaFullAccess,                 // Provides wide access to "serverless" services (Dynamo, S3, etc.)
    aws.iam.AmazonEC2ContainerServiceFullAccess, // Required for lambda compute to be able to run Tasks
h
ok cool, thank you!
l
For Python questions, i will pull in @incalculable-sundown-82514
i
re: Python docs, a lot of documentation is now live here: https://pulumi.io/reference/pkg/python/index.html
we’re making rapid improvements, so there will be even more there as the week goes on, but hopefully there’s enough there to answer any questions you might have!
(and let me know if there’s not… I’m actively working on Python docs right now)
h
thanks @incalculable-sundown-82514
l
Also, very soon, the 'aws.apigateway.x.Api' will 'graduate' from an eXperimental module to a full fledged module in
@pulumi/awsx
.
👍 1
but htere won't be any changes to the functionality or api shape, it's just moving to a new place, and development on it will continue there instead of in
@pulumi/aws
awsx
is coming very soon, and will be our package for great
aws
-specific advanced functionality
👍 1
h
@lemon-spoon-91807 is there any specific documentation of ‘aws.apigateway.x.Api’ ? — in python I get
AttributeError: module 'pulumi_aws.apigateway' has no attribute 'x'
l
it's only JS/TS for now
h
ah, I see — right now is the best way to implement python serverless still to use pulumi in JS per above?
l
i'll let @incalculable-sundown-82514 weigh in, but probably 'yes'
you can still use the TS/JS to set up all the scaffolding
and then create Lambdas that point to python code
like actual python code files
i
h
@incalculable-sundown-82514 I tried to implement an api gateway based on that but got the above error… did you mean to send that one?
what do y’all think is the timeline for having python functionality on par with javascript’s?
i
We have a strategy that’s written down here: https://github.com/pulumi/pulumi/issues/2430
Realistically, based on the long-term plan in that issue, it would be at least a month.
h
awesome - that strategy write up is very helpful @incalculable-sundown-82514, thanks!
i
no problem!
h
@lemon-spoon-91807 any tips or tricks for passing things like bucket names around/into a python function from the pulumi lambda.function? I have asserted the handler and it’s picking that up fine, but I imagine I’d have to be able to pass arguments from the core javascript in that lambda block to use them in a nested lambda function
ah I can use env 😛
l
Copy code
/**
     * The Lambda environment's configuration settings. Fields documented below.
     */
    readonly environment?: pulumi.Input<{ variables?: pulumi.Input<{[key: string]: pulumi.Input<string>}> }>;
yup!