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

Ability to add a custom domain to a lambda function in amplify gen2 #2420

Open
cookiejest opened this issue Jan 10, 2025 · 5 comments
Open
Labels
pending-response Issue is pending response from author pending-triage Incoming issues that need categorization question Question or confusion about some aspect of the product

Comments

@cookiejest
Copy link

Environment information

I have a requirement to create a separate domain for a public api that is protected by a non expiring auth token. The domain should be at api.mydonain.com, my current amplify gen2 app is at www.mydonain.com

What is the best practice way to do this?

Describe the feature

Add a custom domain to an amplify gen2 custom function

Use case

Have a public API that has a separate domain and auth check

@cookiejest cookiejest added the pending-triage Incoming issues that need categorization label Jan 10, 2025
@ykethan
Copy link
Member

ykethan commented Jan 10, 2025

Hey @cookiejest, wanted to better understand your case. Are you looking to create a new API such as AppSync/API gateway with Lambda function as data source and add a custom domain to the API?
or are you looking to add a custom domain to the Amplify hosting branch application on the console?

@ykethan ykethan added question Question or confusion about some aspect of the product pending-response Issue is pending response from author labels Jan 10, 2025
@cookiejest
Copy link
Author

I want to do the equivilent of creating a lambda function and assigning a custom url to the lambda function that is separate from the amplify gen2 domain of the UI application.

Ideally I also want to secure the lambda function using a unique api key per user that is seperate from the authorization of the amplify gen 2 app

@github-actions github-actions bot removed the pending-response Issue is pending response from author label Jan 10, 2025
@ykethan
Copy link
Member

ykethan commented Jan 13, 2025

Hey @cookiejest, thank you for the information. AWS Lambda does provide a function URL that can be used to invoke a function but do note that this only provides AWS IAM as auth.

For your use case I would suggest using an API such as REST API(API gateway) or GraphQL(AppSync) that provides these capabilities in using a API key auth and Lambda function as datasource.
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-setup-api-key-with-console.html
https://docs.aws.amazon.com/appsync/latest/devguide/security-authz.html

@ykethan ykethan added the pending-response Issue is pending response from author label Jan 13, 2025
@cookiejest
Copy link
Author

Ok, I can add the generated lambda function from amplify into a manually configured api gateway for production. Is the url ever likely to change in production during an amplify deploy?

If so is there an example to configure it within amplify.

Thanks,

@github-actions github-actions bot removed the pending-response Issue is pending response from author label Jan 16, 2025
@ykethan
Copy link
Member

ykethan commented Jan 20, 2025

Hey @cookiejest, on a branch deploy Amplify will deploy a new Lambda function.
Refer to the following documentation providing a example with various auth modes and Lambda as datasource.
https://docs.amplify.aws/react/build-a-backend/add-aws-services/rest-api/

@ykethan ykethan added the pending-response Issue is pending response from author label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-response Issue is pending response from author pending-triage Incoming issues that need categorization question Question or confusion about some aspect of the product
Projects
None yet
Development

No branches or pull requests

2 participants