amazon-web-services - 创建 AWS Lambda 函数时使用现有 IAM 角色
问题描述
我正在使用 CloudFormation 创建一个 lambda 函数。大多数文档都假定角色将在模板中创建。有没有办法指定已经通过控制台创建的角色?这个问题解决了一个类似的问题,但对于 EC2 实例创建:Associate existing IAM role with EC2 instance in CloudFormation
我正在寻找类似的东西:
"LambdaFunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"FunctionName": "My Function"
"Runtime": "netcoreapp2.0",
"Handler": "handler.location",
"Role": "Existing_Role"
解决方案
如果您参考云形成文档,
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html
您可以找到 Role 属性来替换您的角色。
它需要 arn 格式,而不仅仅是角色名。
arn:aws:iam::554668579590:role/ProdAdmin
"FunctionName": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Handler": "index.handler",
"Role": "arn:aws:iam::AccountID:role/RoleName",
"Code": {
"S3Bucket": "lambda-functions",
"S3Key": "amilookup.zip"
},
"Runtime": "nodejs4.3",
"Timeout": 25,
"TracingConfig": {
"Mode": "Active"
}
}
}
推荐阅读
- java - 是否可以在 Cloudsim 中计算动态阈值?
- c# - 第三者名单变更通知
- primefaces - 尽管在 primefaces p:cellEditor 中具有相同的表达式,但 h:outputText 中的 JSF2 ValueExpression 不会评估为 true
- sql-server - 如何将二进制列数据读入火花数据帧?
- c# - 将 retryPolicy 与 SqlAzureExecutionStrategy 一起使用时,避免“SqlParameter 已被另一个 SqlParameterCollection 包含”异常
- mysql - 带有'n'个条件的Mysql查询用NOT括起来
- arrays - 在 Tableview (Swaft) 上获取重复的 Firestore 文档
- typescript - TypeScript 的 Visual Studio Code 自动导入行为不一致
- azure - 增加 Kubernetes 中状态集的 PVC 大小
- amazon-web-services - 如果key为空,则只允许一个ApiMapping