AWS EC2 Meta-Data provides the necessary information about itself from EC2 (duh!) - is there anything equivalent for lambda.
I understand the multi-tenancy and short-lived behavior of the lambda function unlike EC2 but essential info like Account ID, VPC AZ, Region would help do a lot of AWS automation.
No, unfortunately not. The context object is the closest thing, but the information it offers is very limited. http://docs.aws.amazon.com/lambda/latest/dg/programming-model-v2.html
If you're invoking the lambda functions yourself or in a programmatic way, you could pass the account ID and region in the payload.
You can set an environment variable when you deploy the lambda: https://docs.aws.amazon.com/lambda/latest/dg/env_variables.html
There are already AWS_REGION
and AWS_DEFAULT_REGION
variables there: https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html#lambda-environment-variables.
event
can have fields like requestContext.accountId
: https://docs.aws.amazon.com/lambda/latest/dg/eventsources.html?shortFooter=true#eventsources-api-gateway-request
Found this out when browsing Terraform's lambda_function configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With