AWS AppSync list query erring out with 504 in console and code

335 Views Asked by At

Given the following schema:

input CreateSurveysInput {
    uuid: String!
    year: Int!
    geocode: AWSJSON!
    metadata: AWSJSON!
    observations: AWSJSON!
    report_url: String
    survey_date: String!
    video_url: String!
}

input CreateWaterQualityInput {
    uuid: String!
}

input DeleteSurveysInput {
    uuid: String!
    year: Int!
}

input DeleteWaterQualityInput {
    uuid: String!
}

type Mutation {
    createSurveys(input: CreateSurveysInput!): Surveys
    updateSurveys(input: UpdateSurveysInput!): Surveys
    deleteSurveys(input: DeleteSurveysInput!): Surveys
    createWaterQuality(input: CreateWaterQualityInput!): WaterQuality
    updateWaterQuality(input: UpdateWaterQualityInput!): WaterQuality
    deleteWaterQuality(input: DeleteWaterQualityInput!): WaterQuality
}

type Query {
    getSurveys(year: Int!, uuid: String!): Surveys
    listSurveys(filter: TableSurveysFilterInput, limit: Int, nextToken: String): SurveysConnection
    getWaterQuality(uuid: String!): WaterQuality
    listWaterQualities(filter: TableWaterQualityFilterInput, limit: Int, nextToken: String): WaterQualityConnection
}

type Subscription {
    onCreateSurveys(
        uuid: String,
        year: Int,
        geocode: AWSJSON,
        metadata: AWSJSON,
        observations: AWSJSON
    ): Surveys
        @aws_subscribe(mutations: ["createSurveys"])
    onUpdateSurveys(
        uuid: String,
        year: Int,
        geocode: AWSJSON,
        metadata: AWSJSON,
        observations: AWSJSON
    ): Surveys
        @aws_subscribe(mutations: ["updateSurveys"])
    onDeleteSurveys(
        uuid: String,
        year: Int,
        geocode: AWSJSON,
        metadata: AWSJSON,
        observations: AWSJSON
    ): Surveys
        @aws_subscribe(mutations: ["deleteSurveys"])
    onCreateWaterQuality(uuid: String): WaterQuality
        @aws_subscribe(mutations: ["createWaterQuality"])
    onUpdateWaterQuality(uuid: String): WaterQuality
        @aws_subscribe(mutations: ["updateWaterQuality"])
    onDeleteWaterQuality(uuid: String): WaterQuality
        @aws_subscribe(mutations: ["deleteWaterQuality"])
}

type Surveys {
    uuid: String!
    year: Int!
    geocode: AWSJSON!
    metadata: AWSJSON!
    observations: AWSJSON!
    report_url: String
    survey_date: String!
    video_url: String!
}

type SurveysConnection {
    items: [Surveys]
    nextToken: String
}

input TableBooleanFilterInput {
    ne: Boolean
    eq: Boolean
}

input TableFloatFilterInput {
    ne: Float
    eq: Float
    le: Float
    lt: Float
    ge: Float
    gt: Float
    contains: Float
    notContains: Float
    between: [Float]
}

input TableIDFilterInput {
    ne: ID
    eq: ID
    le: ID
    lt: ID
    ge: ID
    gt: ID
    contains: ID
    notContains: ID
    between: [ID]
    beginsWith: ID
}

input TableIntFilterInput {
    ne: Int
    eq: Int
    le: Int
    lt: Int
    ge: Int
    gt: Int
    contains: Int
    notContains: Int
    between: [Int]
}

input TableStringFilterInput {
    ne: String
    eq: String
    le: String
    lt: String
    ge: String
    gt: String
    contains: String
    notContains: String
    between: [String]
    beginsWith: String
}

input TableSurveysFilterInput {
    uuid: TableStringFilterInput
    year: TableIntFilterInput
    report_url: TableStringFilterInput
    survey_date: TableStringFilterInput
    video_url: TableStringFilterInput
}

input TableWaterQualityFilterInput {
    uuid: TableStringFilterInput
}

input UpdateSurveysInput {
    uuid: String!
    year: Int!
    geocode: AWSJSON
    metadata: AWSJSON
    observations: AWSJSON
    report_url: String
    survey_date: String
    video_url: String
}

input UpdateWaterQualityInput {
    uuid: String!
}

type WaterQuality {
    uuid: String!
    flow: AWSJSON!
    free_chlorine: AWSJSON!
    location: String!
    ph: AWSJSON!
    pressure: AWSJSON!
    temperature: AWSJSON!
    timestamp: Int!
}

type WaterQualityConnection {
    items: [WaterQuality]
    nextToken: String
}

...and the following resolver attached to the list query listWaterQualities:

{
  "version": "2017-02-28",
  "operation": "Scan",
  "filter": #if($context.args.filter) $util.transform.toDynamoDBFilterExpression($ctx.args.filter) #else null #end,
  "limit": $util.defaultIfNull($ctx.args.limit, 20),
  "nextToken": $util.toJson($util.defaultIfNullOrEmpty($ctx.args.nextToken, null)),
}

$util.toJson($context.result.items)

...and the following db table structure (primary key uuid):

{
  "flow": {
    "raw": 7.1148501551630785,
    "value": 113.83760248260926
  },
  "free_chlorine": {
    "raw": 0.35,
    "value": 0.35
  },
  "location": "mars",
  "ph": {
    "raw": 0.2,
    "value": -6.15152
  },
  "pressure": {
    "raw": 13248.528910641011,
    "value": 86.19716484615098
  },
  "temperature": {
    "raw": 684.7506156784981,
    "value": 16.883287645632485
  },
  "timestamp": 1602381709752,
  "uuid": "008b5a2ad27b42b8a311f021510fca87"
}

...and running the query in both the AppSync Console and via code. I'm getting a timeout.

content-length: 1033
content-type: text/html
date: Sun, 11 Oct 2020 15:09:06 GMT
server: CloudFront
status: 504
via: 1.1 xxxxxxx.cloudfront.net (CloudFront)
x-amz-cf-id: xxxxxxx_2whgDivdLvdgGMRHz7O6g1d-5CSiBX0xVLXhIvfhQA==
x-amz-cf-pop: DFW3-C1
x-cache: Error from cloudfront

I couldn't find a relevant solution, what is my error? Something I am overlooking?

1

There are 1 best solutions below

0
On

My issue ended up being the user role I had selected in the api data source:

Create or use an existing role
Allow AWS AppSync to securely interact with your data source.

I selected use existing and selected an IAM user associated with a different ddb table and thus the connection was never being made to the correct table and thus no data/timeout...