В документации aws приведен следующий пример настройки группового доступа в appsync, который предназначен для включения доступа группы Cognito к мутации.
Я не могу этого понять и хотел бы узнать, как я могу настроить конкретный пример, чтобы позволить группе Cognito, например, «пользователям», иметь доступ к мутации.
#set($expression = "")
#set($expressionValues = {})
#foreach($group in $context.identity.claims.get("cognito:groups"))
#set( $expression = "${expression} contains(groupsCanAccess, :var$foreach.count )" )
#set( $val = {})
#set( $test = $val.put("S", $group))
#set( $values = $expressionValues.put(":var$foreach.count", $val))
#if ( $foreach.hasNext )
#set( $expression = "${expression} OR" )
#end
#end
{
"version" : "2017-02-28",
"operation" : "PutItem",
"key" : {
## If your table's hash key is not named 'id', update it here. **
"id" : { "S" : "$context.arguments.id" }
## If your table has a sort key, add it as an item here. **
},
"attributeValues" : {
## Add an item for each field you would like to store to Amazon DynamoDB. **
"title" : { "S" : "${context.arguments.title}" },
"content": { "S" : "${context.arguments.content}" },
"owner": {"S": "${context.identity.username}" }
},
"condition" : {
"expression": "attribute_not_exists(id) AND $expression",
"expressionValues": $utils.toJson($expressionValues)
}
}