AWS Lambda Production Check
This integration helps engineers quickly identify when they're working with AWS Lambda functions in production environments. It displays a warning when the AWS account ID matches a configured production account.
How does it help?β
A large number of mistakes are being done when engineers believe a resource is not in production, when it actually is.
This integration:
- Displays "In production env!" with important status if it's a production account
- Shows nothing if it's not a production account
Previewβ
How it looks in the extension
Configurationβ
The integration uses a simple account ID check. You'll need to update the PRODUCTION_ACCOUNT_ID constant in the integration file with your actual production AWS account ID.
const PRODUCTION_ACCOUNT_ID = '12345678'; // Replace with your production account ID
When it runsβ
This integration runs when:
- You're on an AWS Lambda function page (
console.aws.amazon.com/lambda) - The AWS account ID is available in the context
- The service type is
lambda
While this integration only checks the account ID, you could also modify it to check for function name patterns like -prod or -production suffixes for additional environment detection.
Installationβ
- Copy the integration file to your
examples/data/directory - Update the
PRODUCTION_ACCOUNT_IDwith your actual production account ID - The integration will automatically be available when you visit AWS Lambda function pages
Security Noteβ
This integration only reads the account ID from the page context and doesn't make any external API calls, making it safe to use without additional AWS credentials.
Codeβ
module.exports = {
metadata: {
name: 'aws-lambda-production-check',
description: 'Shows production environment status for AWS Lambda functions',
match: {
contextType: 'aws',
context: {
'service.name': { equals: 'lambda' },
'global.accountId': { exists: true }
}
},
cache: 3600
},
async run(context, secrets = {}, dataFiles = []) {
logger.info({
operation: 'aws-lambda-production-check',
step: 'initialization',
contextService: context.service.name,
accountId: context.global.accountId
}, 'AWS Lambda production check starting');
// Production account ID - replace with your actual production account ID
const PRODUCTION_ACCOUNT_ID = '12345678';
if (context.global.accountId === PRODUCTION_ACCOUNT_ID) {
logger.info({
operation: 'aws-lambda-production-check',
step: 'production-detected',
accountId: context.global.accountId,
functionName: context.service.resourceName
}, 'Production environment detected');
return [{
type: 'text',
content: 'In production env!',
status: 'important'
}];
}
logger.debug({
operation: 'aws-lambda-production-check',
step: 'no-production',
contextService: context.service.name,
accountId: context.global.accountId
}, 'Not in production environment');
return [];
}
};