在Swift上实例化AWSLambdaInvoker时,服务配置为“nil”

问题描述 投票:1回答:1

我正在尝试使用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个回答
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"
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.