Wednesday, June 15, 2016

Member must not be null


Error:

Value null at 'tableName' failed to satisfy constraint: Member must not be null;
Value null at 'item' failed to satisfy constraint: Member must not be null"

When:

   While posting data to DynamoDB table through API Gateway

How I solved that error:
   By adding a Body-Mapping template in the Integration Request


In the API > whatever resource > whatever method > Integration Request > Body mapping template, added a new template "application/json" as given below


    "TableName": "yourTableName",
    "Item": {
        "inputField1": {
            "S": "$input.path('$.tableItemAttribute1')"
            },
        "inputField2": {
            "S": "$input.path('$.tableItemAttribute2')"
            },
        "inputField3": {
            "S": "$input.path('$.tableItemAttribute3')"
            }
    }
}


API Gateway does not have permission to assume the provided role

Error:

Execution failed due to configuration error: API Gateway does not have permission to assume the provided role

When:
   While executing API Gateway to update a DynamoDB table


How I solved that error:
   By adding a Trusted Entity to the IAM role that was used for the Method Execution.

Go to IAM > Roles > whateverRole > Trust Relationships > Edit Trust Relationship and add apigateway under Statements

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "ec2.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    },
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "apigateway.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

P.S: This role already had Allow sts:AssumeRole on ec2. I simply copied the same and changed ec2 to apigateway.