I'm using AWS Lambda functions, in node.js.
is there any way to configure the lambda function to use hosts records?
for example:
{domain:'www.example.com',ip:'190.10.20.30'}
Related
I am trying to attach a Lambda function in another AWS account to the CloudFront on the Origin response but I get below error.
The CloudFront distribution under account <lambda_account> cannot be associated with a Lambda function under a different account: <cloudfront_account>. Function: arn:aws:lambda:us-east-1:<lambda_account>:function:test_edge_lambda:1
Is there any work around to achieve this?
Im using AWS Amplify for one of my project. I have React in the front and Express as backend. In my localhost I can just add a proxy to my package.json and make call for the api but how can I do so in the AWS? How can I run both express and React side by side and call the api in the amplify or do i need to use EC2?
thanks
if you want to use a "regular REST api" (i.e. non-graphql, no appsync) you'd most likely configure an API Gateway with a Lambda function integration.
For the lambda you can then configure "Serverless ExpressJS function" and have your express code in the lambda.
Here is an example:
$amplify add api
Scanning for plugins...
Plugin scan successful
? Please select from one of the below mentioned services: REST
? Provide a friendly name for your resource to be used as a label for this category in the project: myapi
? Provide a path (e.g., /book/{isbn}): /items
? Choose a Lambda source Create a new Lambda function
? Provide a friendly name for your resource to be used as a label for this category in the project: mylambda
? Provide the AWS Lambda function name: mylambda
? Choose the function runtime that you want to use: NodeJS
? Choose the function template that you want to use:
CRUD function for DynamoDB (Integration with API Gateway)
Hello World
Lambda trigger
❯ Serverless ExpressJS function (Integration with API Gateway)
Local lambda invocation for local development is also possible (usually via a lambda docker image)
I have a lambda function in aws that contains about 80 jobs- the jobs are triggered on a schedule by cloudwatch rules, and the lambda knows which job to run based on the parameters on those rules.
Some jobs require new cloudwatch rules to be created programatically, and others require old rules to be deleted.
Is there a way to create/delete the cloudwatch rules that trigger a lambda entirely from within that lambda?
An AWS Lambda function can call any AWS API.
To add a new Amazon CloudWatch Events rule, use:
put_rule() to define a rule, then
put_targets() to associate a target (eg an AWS Lambda function) with the rule
To delete a rule, use:
remove_targets() and then
delete_rule()
the lambda functions having Repository if yes how to check the Repository details how it will be deployed if no Repository.
Theres no "hidden" or "shared" repository that can be used between different lambda functions, every file you need should be uploaded in the zip file you upload.
Read a more detailed explanation here.
Lambda functions do not have repositories. You can create a deployment package yourself or write your code directly in the Lambda console, in which case the console creates the deployment package for you and uploads it, creating your Lambda function.
If your custom code requires only the AWS SDK library, then you can use the inline editor in the AWS Lambda console. Using the console, you can edit and upload your code to AWS Lambda. The console will zip up your code with the relevant configuration information into a deployment package that the Lambda service can run.
You can also test your code in the console by manually invoking it using sample event data.
In the case of the deployment package, you may either upload it directly or upload the .zip file first to an Amazon S3 bucket in the same AWS region where you want to create the Lambda function, and then specify the bucket name and object key name when you create the Lambda function using the console or the AWS CLI
The setup is using S3 as a storage, API gateway for the rest endpoint and Lambda (Python) for get/fetch of file in S3.
I'm using Boto3 for the Lambda function (Python) to check if the file exists in S3, and I was able to download it but being stored in Lambda machine ("/tmp"). The API Gateway can trigger the lambda function already. Is there a way that once the lambda function is triggered then the download will happen in the browser?
Thanks!
Here is how we did it:
Check and Redirect:
API Gateway --> Lambda (return 302)
Deliver Content:
CloudFront --> S3
Check for S3 existence with Lambda returning a 302 to cloudfront. You can also return Signed URL from Lambda with a valid time to access the URL from CloudFront.
Hope it helps.