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

Support for python lambda functions on AWS #366

Open
kdenz opened this issue May 4, 2024 · 4 comments
Open

Support for python lambda functions on AWS #366

kdenz opened this issue May 4, 2024 · 4 comments
Assignees

Comments

@kdenz
Copy link

kdenz commented May 4, 2024

Hi! Loved SST, thank you so much for all the work over the years! Curious when python lambda functions will be supported for AWS? I think it might help adoption too because right now AI development is huge and there's no easy to use serverless frameworks for python out there. Most people needed to resort to using FastAPI or something. I was using SST v2 but the setup has been painful as it's not well-documented, and VSCode debugger just didn't work at all unlike node.js counterpart. Pulumi supports Python lambdas already but there's no live debugging on their roadmap.

https://www.pulumi.com/docs/clouds/aws/guides/lambda/

Copy link
Contributor

thdxr commented May 6, 2024

our challenge is no one on the team uses python day to day so it's quite hard for us to create a good python experience given how many different ways there is to do things in that ecosystem

nothing stops us from supporting it technically we just don't have much clarity on what supporting it well means

@thdxr thdxr self-assigned this May 6, 2024
@RamblinGambler
Copy link

Is it possible to document a working python function pattern using the pulumi api in the ion run block? That way the dev team doesn't have to commit to building an experience they are unfamiliar with and on the flipside this would do two things:

  1. Give people who just want to run some python a pattern to follow. It doesn't have to be the best experience like the rest of the native ion behavior but its something for devs to go off of and extend.

  2. The more people use it the more interest there will be to improve it.

I am having a bear of a time getting python pulumi functions to be recognized in the ion run block. I could use some better guidance than the scattered bits of info between the sites and discord, but once it works I can help improve it.

@cmanou
Copy link
Contributor

cmanou commented May 14, 2024

The way i've been working around it from a purely deployment point of view with ion, which still has problems with dev experience is via docker image lambdas. I have a docker image based of the python lambda base images (since I found its easiest way to deal with dependencies for platform specific) and then use code similar to this in the run block

const imageRepository = new aws.ecr.Repository(
      "ImageRepository",
      { name: "<name_repository>" }
);

const imageAuthToken = aws.ecr.getAuthorizationTokenOutput({
  registryId: imageRepository.registryId,
});
const image = new docker.Image("Image", {
  imageName: $interpolate`${imageRepository.repositoryUrl}:latest`,
  build: {
    context: path.join($cli.paths.root, "projects/<path_to_docker_context>"),
    platform: "linux/amd64",
  },
  registry: {
    server: imageAuthToken.proxyEndpoint,
    username: imageAuthToken.userName,
    password: $util.secret(imageAuthToken.password),
  },
});
const lambdaRole = new aws.iam.Role("LambdaRole", {
  assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({
    Service: "lambda.amazonaws.com",
  }),
  inlinePolicies: [],
  managedPolicyArns: [
    "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
  ],
});

const lambdaHandler = new aws.lambda.Function(`HandlerFunction`, {
  name: `${$app.name}-${$app.stage}-HandlerFunction`,
  imageUri: image.repoDigest,
  timeout: 120,
  architectures: ["x86_64"],
  packageType: "Image",
  role: lambdaRole.arn,
});

But yeah better support from a dev experience side would be great. Though I agree with @thdxr that the ecosystem has many varied options for things so supporting all of them will be an up hill battle and there doesn't seem to be any leading contenders especially in the dependency management/bundling side of things.

Potentially a middle ground could be something like first class docker image support for SST functions and live mode could maybe do something with running the images in the local test mode that spins up a http server but that would only work if you use the proper base images on the runtime interface client.

@kdenz
Copy link
Author

kdenz commented May 15, 2024

Much agreed! For now I would look forward to just feature parity with SST v2's Function, where it at least allows easy development and deployment of python lambda functions, with live debugging / breakpoint debugging / SST console logs on cloud, etc. Just wondering if there's any timeline for SST Ion's Function to support python runtimes like SST v2? @thdxr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants