我正在尝试使用 Terraform 创建一个 AWS ECS 任务,它将日志放入 CloudWatch 上的特定日志组中。问题是容器定义位于 JSON 文件中,我无法将 CloudWatch 组名称从 .tf 文件映射到该 .json 文件。
容器_定义.json:
[
{
"name": "supreme-task",
"image": "xxxx50690yyyy.dkr.ecr.eu-central-1.amazonaws.com/supreme-task",
"essential": true,
"portMappings": [
{
"containerPort": 5000,
"hostPort": 5000
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "supreme-task-group", <- This needs to be taken from variable.tf file.
"awslogs-region": "eu-central-1",
"awslogs-stream-prefix": "streaming"
}
}
}
]
Run Code Online (Sandbox Code Playgroud)
变量.tf:
variable "ecs_task_definition_name" {
description = "Task definition name."
type = string
default = "supreme-task-def"
}
variable "task_role" {
description = …Run Code Online (Sandbox Code Playgroud) amazon-ecs amazon-cloudwatch terraform terraform-provider-aws
有没有办法根据给定的条件提供自定义错误消息?我正在使用https://github.com/networknt/json-schema-validator,版本 1.0.43
这是我的 JSON 架构:
{
"$id": "https://configurations/provider.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Configuration",
"type": "object",
"properties": {
"provider": {
"description": "Name of the provider.",
"enum": [
"Provider #1",
"Provider #2"
]
},
"configuration": {
"$schema": "json-schema/configurations/configuration.json"
}
},
"if": {
"properties": {
"parcsProvider": {
"const": "Provider #1"
}
}
},
"then": {
"required": [
"configuration"
]
},
"else": {
"not": {
"required": [
"configuration"
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果提供程序的值为“Provider #1”,则需要配置对象,如果是“Provider #2”并且传递配置,则会发生错误。我想自定义该错误,以便响应与现在相同,但带有诸如“提供商 2 无法进行配置”之类的自定义消息。
当前错误消息/响应:
{
"timestamp": "2020-11-23T12:50:56.20658+01:00",
"message": "invalid.json.input", …Run Code Online (Sandbox Code Playgroud)