Open2

LambdaとDynamoDBでGraphQL

yDog-1yDog-1

まずは初期設定

ライブラリなど

go mod init lambda-dynamodb
go get github.com/99designs/gqlgen
go run github.com/99designs/gqlgen init
go run github.com/99designs/gqlgen generate
go get github.com/aws/aws-sdk-go-v2
go get github.com/aws/aws-sdk-go-v2/config
go get github.com/aws/aws-sdk-go-v2/service/dynamodb
go get github.com/aws/aws-sdk-go-v2/service/lambda

権限

IAMロールを作成して、アクセスキーを環境変数へ
今回は簡単のためAmazonDynamoDBFullAccessAWSLambda_FullAccessを付与。

export AWS_ACCESS_KEY_ID=****
export AWS_SECRET_ACCESS_KEY=****