amazon-web-services - 如何在 AWS Api 网关映射模板中使用 IF 条件。我可以在不使用 foreach 的情况下使用 if 条件吗?

标签 amazon-web-services amazon-dynamodb aws-api-gateway

#if($inputRoot.objectType == 'Test'), "TableName": "StudentTests", #else,"TableName": "UserActions", #end

如果使用 if 条件我在 postman 链接中收到错误 ## “__type”:“com.amazon.coral.service#SerializationException” ##

最佳答案

我理解你的问题的方式:

#if($inputRoot.objectType == "Test")
    #set($tableName = "StudentTests"
#else
    #set($tableName = "UserActions"
#end

{
    "TableName": "$tableName",
    "Key": ...
}

关于amazon-web-services - 如何在 AWS Api 网关映射模板中使用 IF 条件。我可以在不使用 foreach 的情况下使用 if 条件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55546882/

相关文章:

javascript - Amazon DynamoDB DocumentClient().get() 使用函数外的值

amazon-web-services - AWS sam部署失败: Waiter ChangeSetCreateComplete failed: Max attempts exceeded

amazon-web-services - 我需要在 IAM 策略中添加什么来授予 API Gateway 资源标签处理权限?

amazon-web-services - 为 Secret Manager 配置凭证轮换时有关 Lambda 执行角色的问题

amazon-web-services - Marklogic 使用云形成模板在 EC2 中缩小规模

amazon-web-services - EC2 在亚马逊网络服务上重新安装 ubuntu

amazon-dynamodb - 部署 MoonMail 时的 DynamoDB 限制

amazon-web-services - AWS SAM 模板创建 API

json - AWS API Gateway 正文映射模板中的原始正文有效负载

amazon-s3 - 亚马逊网络服务 Apache 服务器