The service configuration is `nil` when instantiating AWSLambdaInvoker on Swift

Viewed 1594

I'm trying to implement a lambda function with an iOS app. I follow all the steps on this tutorial form AWS: https://docs.aws.amazon.com/aws-mobile/latest/developerguide/how-to-ios-lambda.html.

But when I add the following line:

let lambdaInvoker = AWSLambdaInvoker.default()

it throws this error:

*** 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.'

I added the awsconfiguration.json file to the project with this content:

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

  }
}
}

The app runs well importing AWSLambda and the mobileClient, and I'm able to validate credentials with Cognito (I get the "welcome to AWS" message)

Any ideas??

1 Answers

You will have to update your awsconfiguraiton.json file to have information about LambdaInvoker so that it can load the configuration for default service configuration. Your updated file should look like:

{
  "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"
    }
  }
}

Related