# API Gateway

# Lambda

# ARN

arn:aws:iam::{계정명}:role/apigateway-dynamodb-role

# GetItem

{
  "TableName": "table1",
  "Key": {
    "test_id": {
      "S": "$input.params('test_id')"
    }
  }
}

# PutItem

{
  "TableName": "table1",
  "Item": {
    "test_id": {
      "S": "$input.params('test_id')"
    }
  }
}

# UpdateItem

{
  "TableName": "table1",
  "Key": {
    "test_id": {
      "S": "$input.params('test_id')"
    }
  },
  "UpdateExpression": "set value = :val1",
  "ExpressionAttributeValues": {
    ":val1": { "S": "$input.path('$.value')" }
  },
  "ReturnValues": "ALL_NEW"
}

# DeleteItem

{
  "TableName": "table1",
  "Key": {
    "test_id": {
      "S": "$input.params('test_id')"
    }
  }
}

# PutItem

date=date1&epoch_uuid=epoch_uuid1
{
  "TableName": "tb_dev",
  "Item": {
    "date": {
      "S": "$input.params('date')"
    },
    "epoch_uuid": {
      "S": "$input.params('epoch_uuid')"
    }
  }
}

# PutItem

date=date1&epoch_uuid=epoch_uuid1&details=details1&epoch=epoch1
{
  "TableName": "tb_dev",
  "Item": {
    "date": {
      "S": "$input.params('date')"
    },
    "epoch_uuid": {
      "S": "$input.params('epoch_uuid')"
    },
    "details": {
      "S": "$input.params('details')"
    },
    "epoch": {
      "S": "$input.params('epoch')"
    }
  }
}

# PutItem

{
  "TableName": "tb_dev",
  "Item": {
    "date": {
      "S": "$context.requestTime.substring(0,11)"
    },
    "epoch_uuid": {
      "S": "$context.requestTimeEpoch,$context.requestId"
    },
    "details": {
        "S": "$util.base64Encode("$input.body")"
    },
    "epoch": {
        "S": "$context.requestTimeEpoch"
    }
  }
}

# AWS API, DynamoDB create

# References

https://labs.brandi.co.kr/2018/07/31/kwakjs.html
Last Updated: 4/13/2025, 11:14:44 PM