Skip to content
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

Better errors when resources don't get created due to invalid JSON #5157

Closed
ghost opened this issue Jul 11, 2018 · 3 comments
Closed

Better errors when resources don't get created due to invalid JSON #5157

ghost opened this issue Jul 11, 2018 · 3 comments
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service.

Comments

@ghost
Copy link

ghost commented Jul 11, 2018

This issue was originally opened by @mzhaase as hashicorp/terraform#18429. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

Terraform v0.11.7
+ provider.aws v1.26.0
+ provider.cloudflare v1.0.0
+ provider.template v1.0.0
resource "aws_ecs_task_definition" "definition" {
  family                         = "abc"
  container_definitions =<<EOF
  [
    {
     "name": "abc",
     "image": "busybox:latest",
     "essential": true,
     "portMappings": [
       {
         "containerPort": 25,
         "hostPort": 25
       }
     ]
     }, # <-- invalid comma
    }
  ]
EOF
}

resource "aws_ecs_service" "service" {
  name                = "abc"
  cluster             = "my-cluster"
  task_definition     = "${aws_ecs_task_definition.definition.arn}"
  scheduling_strategy = "DAEMON"
}

Expected Behavior

aws_ecs_task_definition.definition.container_definitions: invalid JSON

Actual Behavior

aws_ecs_service.service: Resource 'aws_ecs_task_definition.definition' not found for variable 'aws_ecs_task_definition.definition.arn'

Steps to Reproduce

  1. try to apply above code
@bflad bflad added bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service. labels Jul 11, 2018
@bflad
Copy link
Contributor

bflad commented Jul 11, 2018

Hi @mzhaase 👋 Sorry for the unexpected behavior here and that this issue got bounced over to the AWS provider (usually this is correct, but I happen have seen this particular issue before 😄 )

It turns out this is likely an issue upstream in Terraform core, rather than anything to do with the AWS provider specifically. This scenario basically occurs anytime we implement a resource attribute with a ValidateFunc and then that resource is then referenced by another resource. Terraform core, when the first resource is failing that validation, is preferring to return the invalid resource reference message instead of the resource validation error.

I'm going to close this issue out as we have a few upstream tracking issues relating to this:

I would suggest commenting on and upvoting those for the latest updates on this. 👍

@bflad bflad closed this as completed Jul 11, 2018
@mzhaase
Copy link

mzhaase commented Jul 11, 2018

@bflad will do, thanks.

@ghost
Copy link
Author

ghost commented Apr 4, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
Development

No branches or pull requests

2 participants