简体   繁体   English

如何在无服务器中保护AWS访问密钥

[英]How to secure the AWS access key in serverless

I am writing a serverless application which is connected to DynamoDB. 我正在编写连接到DynamoDB的无服务器应用程序。
Currently I am reading the access key ID and security access key from a json file. 目前,我正在从json文件读取访问密钥ID和安全访问密钥。
I am going to use Jenkins for CI and need a way to secure these keys. 我将使用Jenkins for CI,并且需要一种保护这些密钥的方法。

What I am going to do is setting the keys as environmental variables and read them in the application. 我要做的是将键设置为环境变量,并在应用程序中读取它们。 But the problem is I don't know how to set the environmental variables every time a lambda function is started. 但是问题是我不知道每次启动lambda函数时如何设置环境变量。

I have read there's a way to configure this in serverless.yml file, but don't know how. 我读过有一种方法可以在serverless.yml文件中配置它,但是不知道如何。

How to achieve this? 如何实现呢?

Don't use environment variables. 不要使用环境变量。 Use the IAM role that is attached to your lambda function. 使用附加到lambda函数的IAM角色。 AWS Lambda assumes the role on your behalf and sets the credentials as environment variables when your function runs. 当您的函数运行时,AWS Lambda代表您担任角色,并将凭据设置为环境变量。 You don't even need to read these variables yourself. 您甚至不需要自己阅读这些变量。 All of the AWS SDKs will read these environment variables automatically. 所有AWS开发工具包都将自动读取这些环境变量。

There's a good guide on serverless security, which among other topics, cover this one as well. 关于无服务器安全性有一本很好的指南 ,除其他主题外,它也涵盖了这一方面。 It's similar to the OWASP top 10: 它类似于OWASP的前10名:

In general, the best practice would be to use the AWS Secrets Manager, together with SSM parameter store. 通常,最佳实践是将AWS Secrets Manager与SSM参数存储一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 AWS 保护无服务器后端 Lambda - Secure a serverless backend with AWS Lambda 如何在使用无服务器框架时从AWS Lambda访问DynamoDB? - How to access DynamoDB from AWS Lambda when using the Serverless Framework? 如何使用无服务器使 AWS lambda function 具有公共访问权限 - How to make a AWS lambda function with public access using serverless 无服务器 - 如何将 Aws 秘密管理器作为环境变量访问 - Serverless - How to access Aws secret manager as environment variable 来自AWS无服务器反应应用程序的多个安全休息电话 - multiple secure rest call from aws serverless react app 在AWS中使用现有的API密钥和无服务器框架 - Using an existing API key with the Serverless Framework in AWS 如何构建 AWS Serverless 应用程序? - how to structurize AWS Serverless application? 如何使用CloudFormation中的访问和秘密密钥保护AWS API Gateway? - How to secure AWS API Gateway with Access and Secret Keys in CloudFormation? 如何获得从AWS Lambda到Redis的安全访问? 是否需要VPC? - How to get secure access from AWS Lambda to Redis? Is VPC required? 如何保护 AWS REST 后端以进行移动访问 - How to secure AWS REST back end for mobile access
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM