GraphQL endpoint in AWS AppSync (in Go)
defining an AWS AppSync endpoint from Pulumi in Golang
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-go-appsynccd pulumi-examples/aws-go-appsyncThis example shows how to setup a basic GraphQL endpoint in AWS AppSync. The endpoint contains one query and one mutation that get and put items to a Dynamo DB table.
Prerequisites#
Deploying the example#
-
Create a new stack, which is an isolated deployment target for this example:
Terminal window pulumi stack init dev -
Set the AWS region to deploy into:
Terminal window pulumi config set aws:region us-west-2 -
Install dependencies:
Terminal window go mod download -
Deploy the stack:
Terminal window pulumi up -
Check the deployed GraphQL endpoint:
Terminal window curl -XPOST -H "Content-Type:application/graphql" -H "x-api-key:$(pulumi stack output key)" -d '{ "query": "mutation AddTenant { addTenant(id: \"123\", name: \"FirstCorp\") { id name } }" }' "$(pulumi stack output endpoint)"{"data": {"addTenant": {"id": "123","name": "FirstCorp"}}}
Cleaning up#
Once you’re finished experimenting, tear down your stack’s resources by destroying and removing it:
pulumi destroypulumi stack rm