-
-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json: cannot unmarshal string into Go struct field MountPoint.MountPoints.ReadOnly of type bool #108
Comments
I'm running into this even when I don't specify a value for |
I was able to get around this issue by overriding |
I don't see this issue. module "container" {
source = "cloudposse/ecs-container-definition/aws"
container_name = "hello"
container_image = "world"
mount_points = [
{
sourceVolume = "docker-socket"
containerPath = "/var/run/docker.sock"
readOnly = true
},
{
sourceVolume = "letsencrypt"
containerPath = "/letsencrypt"
}
]
}
output "json" {
value = module.container.json_map_encoded
} $ terraform apply
$ terraform output -raw json | jq -M .
{
"cpu": 0,
"essential": true,
"image": "world",
"mountPoints": [
{
"containerPath": "/var/run/docker.sock",
"readOnly": "true",
"sourceVolume": "docker-socket"
},
{
"containerPath": "/letsencrypt",
"readOnly": "false",
"sourceVolume": "letsencrypt"
}
],
"name": "hello",
"portMappings": [],
"readonlyRootFilesystem": false,
"volumesFrom": []
} Could either of you provide a MVRE ? |
I cannot reproduce this. Please feel free to reply if you can provide an MVRE. |
I am able to reproduce this with a minimal example: variable "foo_volumes" {
type = list(object({
name = string
container_path = string
}))
default = []
}
variable "bar_volumes" {
type = list(object({
name = string
container_path = string
read_only = bool
}))
default = [
{
name = "docker_sock"
container_path = "/var/run/docker.sock"
read_only = false
}
]
}
locals {
container_definitions = [{
mountPoints = [for volume in concat(var.foo_volumes, var.bar_volumes) : {
containerPath = volume.container_path
sourceVolume = volume.name
readOnly = try(volume.read_only, false)
}]
}]
}
resource "local_file" "container_definitions" {
filename = "container-definitions.json"
content = jsonencode(local.container_definitions)
}
output "container_definitions" {
value = local.container_definitions
}
output "json" {
value = jsonencode(local.container_definitions)
} Under Terraform 0.14.11, the plan produced by this configuration is as follows:
Using Terraform 0.15.5, the plan is different:
Note that the Terraform v1.2.9 produces a similar plan to v0.15.5. |
I filed a proper bug report with Terraform, as this issue does not appear to be related to this module or any providers. See: hashicorp/terraform#31894 |
Describe the Bug
When you provide a mount point with
readOnly = true
as a mapped item, it fails to be translated to valid JSON. The same is true ofreadOnly = "true"
.Expected Behavior
A read-only volume to be created.
Steps to Reproduce
Apply an otherwise valid container definition with this code block.
If relevant, this is one of several definitions running under one service, so the final definition is laid out as:
Screenshots
Environment (please complete the following information):
Anything that will help us triage the bug will help. Here are some ideas:
The text was updated successfully, but these errors were encountered: