Skip to content

Running lambda container as non-root #1301

Answered by john-holden-1
plaisted asked this question in Q&A
Discussion options

You must be logged in to vote

The documentation states that "Lambda follows security best practices by defining a default Linux user with least-privileged permissions" (Source). You can confirm this by checking the user executing the process at runtime in your own lambda. For example in my NodeJS lambda, I have:

const os = require('os');
const util = require('util');

exports.handler = async () => {
  console.log('Executing user:\n', util.inspect(os.userInfo()));
}

Which logs the following line in CloudWatch:

Executing user: { uid: 993, gid: 990, username: 'sbx_user1051', homedir: '/home/sbx_user1051', shell: '/sbin/nologin' }

Which is obviously not root. Note that I get this user even if I specify a USER 1001 in my …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ashishdhingra
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
guidance Question that needs advice or information. module/custom-runtime
2 participants