Skip to content

Instantly share code, notes, and snippets.

@SebStrug
Created May 17, 2022 16:06
Show Gist options
  • Save SebStrug/fc29823f081706fc58917e9d8d513f47 to your computer and use it in GitHub Desktop.
Save SebStrug/fc29823f081706fc58917e9d8d513f47 to your computer and use it in GitHub Desktop.
Terraform for blog post on Direct Lambda Resolvers on sebstrug.com
# main.tf
resource "aws_appsync_datasource" "valuations" {
api_id = aws_appsync_graphql_api.dino_api.id
name = "valuations"
service_role_arn = aws_iam_role.dino_datasource_role.arn
type = "AWS_LAMBDA"
}
resource "aws_appsync_datasource" "valuations_dr_lomax" {
api_id = aws_appsync_graphql_api.dino_api.id
name = "valuations_dr_lomax"
service_role_arn = aws_iam_role.dino_datasource_role.arn
type = "AWS_LAMBDA"
}
resource "aws_appsync_datasource" "valuations_mary_anning" {
api_id = aws_appsync_graphql_api.dino_api.id
name = "valuations_mary_anning"
service_role_arn = aws_iam_role.dino_datasource_role.arn
type = "AWS_LAMBDA"
}
resource "aws_appsync_resolver" "valuations" {
type = "Query"
api_id = aws_appsync_graphql_api.dino_api.id
field = "getDinoValuation"
data_source = aws_appsync_datasource.valuations.name
}
resource "aws_appsync_resolver" "valuations_dr_lomax" {
type = "DinoValuationReturn"
api_id = aws_appsync_graphql_api.dino_api.id
field = "drLomax"
data_source = aws_appsync_datasource.valuations_dr_lomax.name
}
resource "aws_appsync_resolver" "valuations_mary_anning" {
type = "DinoValuationReturn"
api_id = aws_appsync_graphql_api.dino_api.id
field = "maryAnning"
data_source = aws_appsync_datasource.valuations_mary_anning.name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment