尝试从Lambda

时间:2018-04-22 11:49:15

标签: amazon-web-services go aws-lambda serverless

我有一个Lambda,我试图通过SDK发布到IoT核心。但是我收到了错误

{
    "errorMessage": "MissingEndpoint: 'Endpoint' configuration is required for this service",
    "errorType": "baseError"
}

这是我的发布功能:

func publish() error {
    session := session.New(&aws.Config{
        Region: aws.String("eu-west-2"),
    })
    iot := iotdataplane.New(session)
    input := &iotdataplane.PublishInput{
        Payload: []byte("take picture"),
        Topic:   aws.String("take-picture"),
    }
    resp, err := iot.Publish(input)

    if err != nil {
        return err
    }
    return nil
}

以下是我作为无服务器配置的一部分添加的一些IAM /角色:

provider:
  name: aws
  runtime: go1.x
  region: eu-west-1
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - "iot:Publish"
      Resource: ["arn:aws:iot:eu-west-2:<redacted>:thing/mini-camera"]
    - Effect: "Allow"
      Action:
        - "iot:Connect"
      Resource: ["*"]

0 个答案:

没有答案