- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 AWS Lambda、API Gateway 和 RDS (MySQL) 开发 REST API。我正在使用 Node.js。
为了保护数据库凭证,我访问了 AWS Web 控制台并创建了一个新 key 。
现在我需要在 Lambda 函数中访问这些。我知道我必须分配 SecretsManagerReadWrite
权限,但我不知道该怎么做。
下面是我的 CloudFormation 配置文件。
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
aaaa-restapi
Sample SAM Template for aaaa-restapi
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 100
VpcConfig:
SecurityGroupIds:
- sg-041f2455252528e
SubnetIds:
- subnet-0385252525
Resources:
GetAllAccountingTypesFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: aaaa-restapi/
Handler: accountingtypes-getall.getallaccountingtypes
Runtime: nodejs14.x
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /accountingtypes/getallaccountingtypes
Method: get
LambdaRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Policies:
- PolicyName: root
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- ec2:DescribeNetworkInterfaces
- ec2:CreateNetworkInterface
- ec2:DeleteNetworkInterface
- ec2:DescribeInstances
- ec2:AttachNetworkInterface
Resource: '*'
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for functions"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
在此文件中,我如何向我的 Lambda 函数授予权限?
最佳答案
基于评论。
通常的实现方式是访问lambda 函数中的 secret 值。这需要向 lambda 执行角色授予访问 secret 的权限。
在 CloudFormation 模板中,您可以将 key 名称(而不是其值)作为环境变量传递给 lambda 函数。
关于node.js - 如何在 CloudFormation 文件中分配 AWS SecretsManager 策略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68480060/
我正在使用 aws-cdk-lib (2.13.0)。这是我的代码片段: import { App, Stack } from 'aws-cdk-lib'; import { Secret } fro
我正在使用 AWS Secrets Manager 来保护我的 REST API 的数据库积分。我正在使用 AWS Lambda、API 网关和 RDS (MySQL)。以下是我如何获得它们。 //
我正在尝试创建一个 ListenerRule,它仅接受从 Secrets Manager 加载的某些 IP 地址。这是我的原始代码: LoadBalancerRule: Type: AWS::
在 AWS secretsmanager 中创建一个 secret ,使用 lambda 函数启用自动轮换。当我第一次从 cli 触发旋转时,它还没有完成。这是在 aws 控制台手动更新 secret
我正在使用 CloudFormation 来配置 Linux 实例。在启动过程中,我想将一个文件添加到特定文件夹中,该文件夹的内容来自驻留在 secret 管理器中的 secret 字符串。我尝试使用
我正在使用 AWS Lambda、API Gateway 和 RDS (MySQL) 开发 REST API。我正在使用 Node.js。 为了保护数据库凭证,我访问了 AWS Web 控制台并创建了
我有两个 AWS 账户:一个保存我的 secret 的账户,一个用于部署我的 cloudformation 堆栈的账户。我正在使用 cloudformation 将基础设施部署为代码,并拥有一个非常简
我正在使用 CDK 在 AWS 中设置 Fargate 服务 const albFargateService = new ecs_patterns.ApplicationLoadBalancedFar
我有一个无服务器堆栈将 API 部署到 AWS。我想使用存储在 Secrets manager 中的 API key 来保护它。这个想法是在 SSM 中拥有 key 的值,在部署时将其拉出并将其用作我
我有一个 CloudFormation 模板,可以在其中创建 RDS 实例。首先,我创建一个 AWS::SecretsManager::Secret 并保存将用作 MasterUserPassword
引自 aws cdk docs : If you need to use a pre-existing secret, the recommended way is to manually provi
我有以下 terraform 模板,它创建用户、访问 key 并存储在 secret 管理器中。 resource "aws_iam_user" "test" { name = "test" }
在 AWS 账户 A 中,我在 key 管理器 中创建了一个 key ,它是带有 key token 的键:值对。我想与我的 AWS 组织下的任何账户共享此 secret ,因此它具有以下资源策略:
在云结构中部署我的项目并尝试创建多个 key 后,显示以下错误消息: 资源 SecretsManager 的资源属性 MySecretA 无效 YAML 片段: SecretsManager: Ty
我正在使用 AWS Lambda、API Gateway、RDS (MySQL) 开发 REST API。我正在使用 Node.js。 这是我的正常 AWS Lambda 代码,调用数据库表来获取数据
有没有办法使用 aws-secretsmanager-jdbc 和 node.js 连接到 RDS 实例?我需要连接到数据源并运行一个简单的查询,但不幸的是,唯一支持的连接方式是使用 aws-secr
我试图使用AWS Secrets Manager服务来存储 key 。我可以将 key 存储在 secret 管理器中,但是在使用 key 提供的代码检索 key 时,却出现了此错误。 Unknown
创建 AWS::RDS::DBCluster 时(Aurora-Serverless)在AWS CloudFormation中,有一个属性MasterUserPassword其输入指定为 string
我是一名优秀的程序员,十分优秀!