
Configure IAM privileges for the test profile, so it can only access the test resources. create a separate AWS IAM account for testing, and assign the keys for that account to a separate profile in ~/.aws/credentials (Unix) or %USERPROFILE%\.aws\credentials (Windows). If you’re working on a public repository (eg open-source code on github), never commit access keys to your version control system.Ī good approach to authentication, that automates away a lot of potential problems, is to:. Although Node.js SDK requires you to initialise a region locally, it will already be initialised when running in AWSĪnother critical thing to keep in mind, to avoid stupid mistakes and financial cost:. When a Lambda function is running on AWS, the code runs under a profile that is already authenticated, and authorisation is controlled by the IAM role assigned to your Lambda function. Here are some interesting guidelines to keep in mind: #Local dynamodb testing how to
The key issue is how to handle authentication and authorisation for external systems. If you want to run tests against those services as well, things get slightly more complicated. In practice, Lambda code often talks to other services, in particularly on AWS, such as DynamoDB, S3 or SNS. This means that you can, in theory, just run everything locally as simple automated tests. Lambda functions are simple JavaScript functions. Make sure to read Designing Testable Lambda Functions for tricks on minimising the need to run local integration tests as well. In this tutorial, you’ll learn how to run local automated tests for AWS Lambda functions.