Amplify-cli: Multi-env - add back support for existing lambda?

Created on 29 Jan 2019  路  4Comments  路  Source: aws-amplify/amplify-cli

Is your feature request related to a problem? Please describe.

Re-enable: Use a Lambda function already deployed on AWS

I hoped to use lambdas deployed/managed with AWS-CDK (which also builds SNS/SQS/other stuff for the lambda to use) in my Amplify project, but the ability to do that has been removed in multi-env: https://github.com/aws-amplify/amplify-cli/blob/multienv/packages/amplify-category-api/provider-utils/awscloudformation/service-walkthroughs/apigw-walkthrough.js#L311

Describe the solution you'd like

Please could they be added back, or someone point me at a an alternative solution

Describe alternatives you've considered

I could do something with aws-cdk lambda having it's own ApiGW and manually configuring it as an endpoint. But then I'd need to get the cognito user pool / other attributes from amplify out and into cdk.

I could go to build Cognito/AppSync etc myself with AWS-CDK - rather than use amplify cli at all, but seems a shame to loose the great features - it's just getting everything to place nice together that's potentially complex!

Additional context

Love Amplify - thank you

enhancement functions

Most helpful comment

@kaustavghosh06 thanks for the reply - I see the issue - not sure of the solution! - I'm currently going with deploy lambda's/API gateway with CDK and then integrate the relevant endpoint with Amplify.

Closing for now - thanks

All 4 comments

@ranguard The challenge of using an already deployed Lambda function is multi-environments. With multi-environments, you can have multiple environments of the same stack in a different region or even a different AWS account. If we allow users to specific ARN's of lambda functions in the infrastructure definition, then it becomes too hard to replicate this infrastructure in another environment. Having said that we're brainstorming on ideas to see if we could still make this option available. Would be great to hear your thoughts on this as well.

@kaustavghosh06 thanks for the reply - I see the issue - not sure of the solution! - I'm currently going with deploy lambda's/API gateway with CDK and then integrate the relevant endpoint with Amplify.

Closing for now - thanks

@kaustavghosh06 @ranguard I have 2 apps sharing the same DynamoDB table and lambda function for CRUD ops. And today when I tried to wanted to add the multi env support I faced the same problem.

Then each app will use the lambda function with API gateway, the difference is the security . One of the app does not have any login so I can not restrict it to authenticated users, but in the other I use a cognito user pool, so I want to restrict the API usage to authenticated users.

Is there a way to import the lambda function from another amplify project in my scenario? Or the only option for now is to not use amplify for the api creation?

I've reverted to <1.0.0 because of this. I like developing my lambda functions with serverless. Let's me reuse code and use babel easily.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rehos picture rehos  路  3Comments

jexh picture jexh  路  3Comments

adriatikgashi picture adriatikgashi  路  3Comments

nason picture nason  路  3Comments

kangks picture kangks  路  3Comments