From the original question and the comments I gathered the following requirements for your Lambda:
- You want to talk to the Route53 API.
- You want to parameterise the Lambda to allow passing a domain name to the Lambda on every invocation.
The easiest and probably most fitting way to achieve this is to pass the domain as "event" data on every invocation.
exports.handler = async (event) => {
const domain = event["domain"];
console.log("Domain: %s", domain);
// your Route53 code goes here...
};
To run the Lambda and pass the "domain" you have a lot of options.
Option 1: AWS Console
You can go to the AWS console, open the Lambda, switch to the "Test" tab and just use the following input JSON:
{
"domain": "www.google.com"
}

Option 2: AWS CLI v2
From the command line you could invoke that Lambda using the AWS CLI.
aws \
lambda \
invoke \
--cli-binary-format raw-in-base64-out \
--function-name <function-name> \
--payload '{"domain":"www.google.com"}' \
outfile.txt
Option 3: AWS SDK
You can also write some code in a other Lambda, in a script on your local machine or any other way that can use the AWS Lambda and invoke the Lambda like this.
The following is an example of simple NodeJS CLI "code" using the v3 of the AWS SDK.
import { LambdaClient, InvokeCommand } from "@aws-sdk/client-lambda";
async function main() {
const client = new LambdaClient({ region: "<your-region>" });
const payload = JSON.stringify({
"domain": "www.google.com"
});
const input = {
"FunctionName": "<function-name>",
"Payload": payload
};
const command = new InvokeCommand(input);
const response = await client.send(command);
console.log(response);
}
main()
If you run node index.js
you will invoke the Lambda with the given payload.
To setup node:
npm init
npm install @aws-sdk/client-lambda
Remember to set type
to module
in the package.json
.