**npm install -g node-lambda**
These instructions ensure that you have the right environment for Lambdas development and deployment.
In order to be able to connect and deploy services on AWS, it is essential to correctly set the environment variables corresponding to the access credentials. The following variables must be set using the corresponding AWS account access keys:
AWS_ACCESS_KEY_ID: Access key identifier. AWS_SECRET_ACCESS_KEY: Secret key associated with the AWS_ACCESS_KEY_ID. AWS_SESSION_TOKEN : Session token, required if you use temporary credentials (for example, when working with IAM roles). You can obtain these keys in the “Access Keys” section within the AWS account. To set environment variables.
event.json
file configurationIt is essential that you correctly prepare your event.json
file. This file contains the event that will be simulated during the test of each service. Follow these steps to set it up properly:
File Structure: The event.json
file must be in JSON format and reflect the data expected by the Lambda function you are going to test. Make sure the fields match the parameters required by your service.
Basic example of an event.json
file:
{
"httpMethod": "POST", // Here we specify the HTTP method we need, such as POST or GET.
"path": "/auth-service/service", // We specify the path and the service to be consumed.
"queryStringParameters": { // We enter the parameters to be sent via the URL, if necessary.
"parameter1": "value1",
"parameter2": "value2"
},
"multiValueHeaders": {
"x-forwarded-for": ["ip1", "ip2"], // We specify the IPs that will be validated.
"origin": "<https://example.com>" // We enter the origin to validate if it matches the origin sent in the body.
},
"body": "encrypted_data_here", // We include the encrypted data with the necessary information, depending on the service requested.
"isBase64Encoded": false // Indicates whether the body is Base64 encoded or not.
}
POST
or GET
.