小编May*_*ank的帖子

SAM 模板内的 IAM 角色

如何在 SAM 模板中创建 IAM 角色,就像我在 SAM 包中所做的那样。我尝试了如下:

"lambdaFunctionRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "lambda.amazonaws.com",
                  "apigateway.amazonaws.com"
                ]
              },
              "Action": "sts:AssumeRole"
            }
          ]
        },
        "ManagedPolicyArns": [
          {
            "Ref": "lambdaBasePolicy"
          }
        ],
        "Policies": [
          {
            "PolicyName": "root",
            "PolicyDocument": {
              "Version": "2012-10-17",
              "Statement": [
                {
                  "Effect": "Allow",
                  "Action": [
                    "logs:CreateLogGroup",
                    "logs:CreateLogStream",
                    "logs:PutLogEvents"
                  ],
                  "Resource": "arn:aws:logs:*:*:*"
                },
                {
                  "Effect": "Allow",
                  "Action": [
                    "s3:*",
                    "dynamodb:*",
                    "iam:ListRoles",
                    "ses:*",
                    "events:*"
                  ],
                  "Resource": "*"
                }
              ] …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services serverless

8
推荐指数
1
解决办法
6503
查看次数

无法在SAM模板中添加策略

我正在研究SAM模板,用于在AWS Serverless存储库中发布我的应用程序。但是,当我尝试为lambda添加策略时,会显示错误消息:Invalid Serverless Application Specification文档。发现的错误数量:1.错误:ID为[SyncPostDataFromSfLambda]的资源无效。“策略”属性中仅支持策略模板。

以下是我的SAM模板的示例:

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Transform": "AWS::Serverless-2016-10-31",
    "Description": "Deployment",
    "Resources": {
        "SyncPostDataToSfLambda": {
            "Type": "AWS::Serverless::Function",
            "Properties": {
                "Handler": "index.handler",
                "FunctionName": "myLambdaFunction",
                "CodeUri": "s3 URL",
                "Runtime": "nodejs6.10",
                "MemorySize": 512,
                "Policies": [
                    "AmazonDynamoDBFullAccess"
                ],
                "Events": {
                    "PostResource": {
                        "Type": "Api",
                        "Properties": {
                            "RestApiId": {
                                "Ref": "API"
                            },
                            "Path": "/apipath",
                            "Method": "post"
                        }
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

aws-lambda serverless

6
推荐指数
3
解决办法
5002
查看次数

“由于路径 /price 处的集成格式错误,无法解析 API 定义。(服务:AmazonApiGateway;状态代码:400;

我为 x-amazon-apigateway-integration 添加了以下代码,如果我遗漏了某些内容,请告诉我。谢谢

  x-amazon-apigateway-integration:
    httpMethod: post
    type: aws
    uri:
      Fn::Sub: 
        - arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${FunctionArn}/invocations      
        - { FunctionArn: !GetAtt  PriceAPIFunction.Arn}
    responses:
      default:
        statusCode: '200'
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-lambda aws-serverless

3
推荐指数
1
解决办法
3606
查看次数