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

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??

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

OPA policy where if kustomize.toolkit.fluxcd.io/reconcile: disabled label is present in helm release yaml it should display a message

is their any OPA policy example where i can design a OPA policy like if specific label is present than it should display the message or warning
i mean i want to design an OPA policy where if kustomize.toolkit.fluxcd.io/reconcile: disabled label is present in helm release yaml it should display a message/warning that kustomize disabled label is there in helm release
can anyone please help me
It’s possible to return warning messages to clients from an admission webhook. The format is documented here.
{
"apiVersion": "admission.k8s.io/v1",
"kind": "AdmissionReview",
"response": {
"uid": "<value from request.uid>",
"allowed": true,
"warnings": [
"duplicate envvar entries specified with name MY_ENV",
"memory request less than 4MB specified for container mycontainer, which will not start successfully"
]
}
}
Let's imagine you have an input object like this:
{
"kind": "AdmissionReview",
"request": {
"kind": {
"kind": "HelmRelease",
"version": "v1"
},
"object": {
"metadata": {
"annotations": {
"kustomize.toolkit.fluxcd.io/reconcile": "disabled"
},
"name": "myapp"
}
}
}
}
Using a policy like this would return warnings to your client when called on the /v0/data API
package play
import future.keywords.contains
import future.keywords.if
warn contains msg if {
input.request.kind == "HelmRelease"
input.request.object.metadata.annotations["kustomize.toolkit.fluxcd.io/reconcile"] == "disabled"
msg := "kustomize disabled"
}
response = {
"apiVersion": "admission.k8s.io/v1",
"kind": "AdmissionReview",
"response": {
"uid": "1234",
"allowed": true,
"warnings": warn,
},
}

Request sent from Swagger UI not resulting in Postman x-www-form-urlencoded response

I'm currently configuring a Swagger file to utilize OAuth to retrieve tokens from a site. For brevity, I have removed my schemes and most of my paths as those are fine.
{
"openapi": "3.0.2",
"info": {
"title": "swagger",
"version": "1.0.0",
"description": ""
},
"servers": [
{
"url": "url"
}
],
"paths": {
"/oauth_token.do": {
"post": {
"requestBody": {
"required": true,
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "object"
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"OAuth": {
"type": "oauth2",
"flows": {
"password": {
"tokenUrl": "/oauth_token.do",
"refreshUrl": "/oauth_token.do",
"scopes": {
"useraccount": "utilize user account"
}
}
}
}
}
}
"security": [
{
"OAuth": ["useraccount"]
}
]
}
The endpoint for this API specifies that I should use x-www-form-urlencoded in the header as the Content-Type. When executing this request in Postman, it returns 200 with the desired response.
However, with https://editor.swagger.io I input the same postman request to get the fetch failed error with my Authorize button. To test for this, I created a custom path that specifies that the content should be x-www-form-urlencoded and this also fails.
So, what am I missing in this case? Any help would be appreciated.
I believe the issue was I did not fill out some portions I added on the response for path. Instead I opted to only leave description for the 200 response.
The main error I'm getting now is CORS related which is unrelated to the original question. I'll mark this answered for now.

CDK Stepfunction Fargate step that takes all json key

I wanted to create ECS task that takes all json as its environment input. But my cdk code won't deploy because of following error message, the error message is so vague and it is difficult for me to figure out why my code is wrong.
Failed to call Step Functions for request: 'com.amazonaws.services.stepfunctions.model.CreateStateMachineRequest'. (Service: null; Status Code: 500; Error Code: null; Request ID: null)
new StateMachine (/local/home/miae/Explanation/src/ForecastingDeepLearningExplanationInfrastructure/node_modules/#aws-cdk/aws-stepfunctions/lib/state-machine.ts:101:26)
My cdk code
...
const ecsFargateTask = new sfn.Task(this, 'myEcs', {
inputPath: "$",
resultPath: "$.ecs",
task: new class implements sfn.IStepFunctionsTask {
bind(): sfn.StepFunctionsTaskConfig {
return {
resourceArn: "arn:aws:states:::ecs:runTask.sync",
parameters: {
"LaunchType": "FARGATE",
"Cluster": props.cluster.clusterArn,
"TaskDefinition": taskDefinition.taskDefinitionArn,
"Overrides": {
"ContainerOverrides": [{
"Name": "myContainer",
"Environment.$": "$.envs"
}]
}
}
};
}
}
});
}
const chain = sfn.Chain.start(ecsFargateTask);
new sfn.StateMachine(this, `StateMachineCopy${props.stage}`, {
definition: chain,
timeout: cdk.Duration.seconds(3000)
});
This is the Step function I want, and I could manually create this without problem.
{
"StartAt": "ExplanationEcs",
"States": {
"ExplanationEcs": {
"End": true,
"InputPath": "$",
"Parameters": {
"LaunchType": "FARGATE",
"Cluster": "arn:aws:ecs:us-west-2:123456789:cluster/myCluster482E02CC-1VWQ5XRG4II88",
"TaskDefinition": "arn:aws:ecs:us-west-2:123456789:task-definition/myTaskDefinitionE3E6548C:3",
"Overrides": {
"ContainerOverrides": [
{
"Name": "myContainer",
"Environment.$": "$.envs"
}
]
}
},
"Type": "Task",
"Resource": "arn:aws:states:::ecs:runTask.sync",
"ResultPath": "$.ecs"
}
},
"TimeoutSeconds": 3000
}

How to fix Database Null Exception in ASP.NET-MVC

services.AddDbContext<StoreContext>(options =>
options.UseSqlServer(Configuration["Data:StoreProducts:ConnectionString"]));
In the appsettings.json:
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
and in the appsetting.development.json
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"Data": {
"StoreProducts": {
"ConnectionString": "Server=DESKTOP-I3K90LQ\\SQL2016;Database=BrooksStore;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
}
I am not sure why services threw me an exception saying options.UseSqlServer has null value in it.
Can anyone help?
Thank you!
The value is null because your connection string is in "appsetting.development.json" not "appsetting.json" so you can put your connection string in appsetting.json and it will work just fine.
EDIT
Actually you have a typo in your json file name it's "appsettings.Development.json" not "appsetting.development.json"
notice the 's'
now it should work correctly from your dev json file

Serilog Exceptionless Sink in .NET Core 1.1

How can the Serilog Exceptionless Sink be used with .NET Core 1.1?
The Serilog.Sinks.Exceptionless README isn't clear and doesn't work for .NET Core 1.1 where I have put the configuration in the appsettings.json file.
{
"Serilog": {
"Using": ["Serilog.Sinks.Literate"],
"MinimumLevel": ["Debug"],
"WriteTo": [{
"Name": "LiterateConsole"
}],
"Enrich": ["FromLogContext"],
"Properties": {
"Application": "MyAppServer"
}
}
}
Program.cs
public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(config)
.CreateLogger();
}
}
I obviously need to set up the API key somewhere, too.
Can anyone provide a clear description of how this can be configured, please?
In JSON you can add additional sinks to the "WriteTo" list and add arguments like apiKey in the "Args" block:
{
"Serilog": {
"Using": ["Serilog.Sinks.Literate"],
"MinimumLevel": ["Debug"],
"WriteTo": [{
"Name": "LiterateConsole"
}, {
"Name": "Exceptionless",
"Args": { apiKey: "12345" }
}],
"Enrich": ["FromLogContext"],
"Properties": {
"Application": "MyAppServer"
}
}
}
I think it's
Log.Logger = new LoggerConfiguration()
.WriteTo.Exceptionless(
apiKey: "yourApiKey",
additionalOperation: b => b.AddTags("ASP.NET Core Example Logger"))
.CreateLogger();

Resources