-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
data.aws_ecs_task_definition: Failed getting task definition #1274
Comments
also reproduced in terraform 1.0 |
I'm also experiencing the same issue! What's curious is that when attempting the search using a vanilla state (completely empty), the plan and apply work as expected. It's only when I have an existing state file that it doesn't work. |
Even more curious, the resources don't exist in the statefile anyhow, and yet it fails? 🤔 |
Diving into debugging... I've noticed that |
This is doubly interesting to me. Based on the above docs, OP's config shouldn't be failing because
|
@radeksimko could we get your eyes on this? I don't want to spam the main repo if it's not a terraform issue. |
I'm seeing this issue as well. |
I actually don't need data and resource for the same thing in the same file. I commented out the data and now it seems to be working better. |
Related: #632 |
I was able to get around this issue by adding a "depends_on" to the data source:
Hope it helps. |
It's not really a bug, the solution from @parruda is correct. The |
@KIVagant that makes sense, as I was also experiencing the same issue. Though I would say the Terraform docs for that show the Otherwise @parruda solutions makes sense for me |
Ya I probably should of tried the fix before replying, it works but it causes continuous change detection to occur. |
@parruda's fix worked for me, but now the explicit |
@dendrochronology, I use something like this:
|
@KIVagant ahhh, I'm going to play with the |
Ah, nice, I'll play with that, too. Would that mean I'd need to manually |
It depends on your goals. In our case the template contains empty place for secrets which are filling after first install by Terraform and we don't want to allow it to change exist task definitions. And we control them manually after first install. |
@dendrochronology sorry for the lack of response. I actually never noticed the problem because we do want to update the task definition on every run. I hope you found a solution. |
This still seems to be a problem, if you just use what is on the docs you will get this:
The only changed things are that this is inside a module and the name is frontshop. Could it be related to the module? |
Actually, what I said is a lie, looks like there is a problem when you have an invalid JSON for container definitions and mine is not using the heredoc syntax but a json file with a template and it should be an array of containers and i have only one main object. |
nice one @jaysonsantos. In my case, the error came out because of json syntax error |
With a provider upgrade to 1.59 and terraform 11.11, I am still seeing this error. If terraform destroy completes with no errors, it works fine without a depends_on. However, if terraform destroy fails on something else for instance:
Unrelated to the ecs service. Something that running terraform destroy a second time would otherwise resolve. On the second pass the
error resurfaces and the state file is corrupt. |
This issue isn't very clear to me. Seems like some folks claim that we should NOT be using a depends_on in the datasource for the task definition but upon the first run it always fails because the resource doesnt exist. |
This is working around the issue of not having a task definition when the resources are initially rolled out. Background: The documetation example of directly referecing "task_family" doesn't work and exits with an error when initially applying it. See also this issue hashicorp#1274 The reason is, that data sources don't handle missing data gracefully. Unfortunately, that's not gonna be addressed, as stated here: hashicorp/terraform#16380 (comment) One of the suggested workarounds is, to add an explict `depends_on`. However, this causes a potential change in the terraform plan output, even though it's not actually going to change. Furthermore, it's discourage by the Terraform documentation itself. This thread mentions a few other workarounds, but none of them seem to be suitable hashicorp/terraform#16380 `aws_ecs_task_definition.self.revision` can only be referenced, once the resource is created (in contrast to family, which is already present in code) Apparently, this allows Terraform to correctly resolve the dependencies and makes the data source behave as expected.
FYI for everybody else stumbling over the issue: @skorfmann illustrated in this MR #10247 a better workaround using
|
@bentolor Which version of Terraform is that solution valid for? At my company we are running on 0.12 and the suggested solution with the conditional on .revision causes an error, as Terraform complains about it not being a boolean value. Since anyway both sides of the conditional end up referencing the same value, as a quick fix I used "revision >0" in the conditional just to force it to be a boolean. |
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
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. |
Terraform Version
0.9.11.
Terraform Configuration Files
Expected Behavior
if resource not exists create new aws_ecs_task_definition else use latest aws_ecs_task_definition version
this code vork fine in Terraform v0.9.2
Actual Behavior
: Failed getting task definition ClientException: Unable to describe task definition.
status code: 400, request id: "my-service"
Steps to Reproduce
terraform apply
The text was updated successfully, but these errors were encountered: