【问题标题】:The service configuration is `nil` when instantiating AWSLambdaInvoker on Swift在 Swift 上实例化 AWSLambdaInvoker 时服务配置为“nil”
【发布时间】:2019-02-11 20:16:57
【问题描述】:

我正在尝试使用 iOS 应用程序实现 lambda 函数。我按照 AWS 上本教程中的所有步骤操作:https://docs.aws.amazon.com/aws-mobile/latest/developerguide/how-to-ios-lambda.html

但是当我添加以下行时:

let lambdaInvoker = AWSLambdaInvoker.default()

它会抛出这个错误:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The service configuration is `nil`. You need to configure `Info.plist` or set `defaultServiceConfiguration` before using this method.'

我将 awsconfiguration.json 文件添加到项目中,内容如下:

{
"Version": "1.0",
"CredentialsProvider": {
    "CognitoIdentity": {
        "Default": {
            "PoolId": "us-east-1:05aab771-99b5-4a9b-8448-de92fe86ba56",
            "Region": "us-east-1"
        }
    }
},
"IdentityManager" : {
  "Default" : {

  }
}
}

应用程序在导入 AWSLambda 和 mobileClient 时运行良好,我可以使用 Cognito 验证凭证(我收到“欢迎使用 AWS”消息)

有什么想法吗??

【问题讨论】:

    标签: ios swift amazon-web-services aws-lambda


    【解决方案1】:

    您必须更新您的awsconfiguraiton.json 文件以获取有关LambdaInvoker 的信息,以便它可以加载默认服务配置的配置。您更新后的文件应如下所示:

    {
      "Version": "1.0",
      "CredentialsProvider": {
        "CognitoIdentity": {
            "Default": {
                "PoolId": "us-east-1:05aab771-99b5-4a9b-8448-de92fe86ba56",
                "Region": "us-east-1"
            }
        }
      },
      "IdentityManager" : {
        "Default" : {
    
        }
      },
      "LambdaInvoker" : {
        "Default" : {
             "Region": "us-east-1"
        }
      }
    }

    【讨论】:

    • 谢谢!这解决了我的问题。我以为是这个问题,但是找不到如何更新json...
    • 正如我所提到的,我解决了这个问题,但后来我用凭据遇到了另一个问题!如果可以看一下,我将非常感激,我没有任何答案...stackoverflow.com/questions/52214407/…
    猜你喜欢
    • 1970-01-01
    • 2018-04-11
    • 2017-07-10
    • 2015-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-30
    相关资源
    最近更新 更多