I am trying to set up GraphQL api with AWS Amplify. The docs provide the solution to call a DynamoDB from a Lambda function in Python:
import json
import boto3
client = boto3.client('dynamodb')
def handler(event, context):
data = client.scan(
TableName='your-table-name'
)
response = {
'statusCode': 200,
'body': json.dumps(data),
'headers': {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
}
return response
What I can't figure out is how to reference the name of the table used by GraphQL models in Amplify to put it in TableName='your-table-name'
(so that it works both for cloud version and mock). Any ideas?
Edit: solved by updating the function with the permissions to read/edit the table. The table could then be referenced using an environmental variable.
I solved it by updating the function with the permissions to read/edit the table. The table could then be referenced using an environmental variable.