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

Cannot change build path of existing resource #31

Open
joshrwolf opened this issue Oct 18, 2022 · 4 comments
Open

Cannot change build path of existing resource #31

joshrwolf opened this issue Oct 18, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@joshrwolf
Copy link
Contributor

Changing the build path of an existing resource to one that doesn't exist results in an error at plan/apply time.

An example of this occurring is when we're refactoring an invocation path:

# A
|- env/
   - main.tf         # buildpath of "${path.module}/../"
|- main.go

to

# B
|- env/
   |- new/           # buildpath of "${path.module}/../../"
      - main.tf
|- main.go

if A already exists in state and we move the invocation to B, a terraform {plan,apply} will error out with a ko build error due to a non-existent path.

the desired behavior instead is for the tf provider to simply rebuild the image with the new path.

@joshrwolf joshrwolf self-assigned this Oct 18, 2022
@joshrwolf joshrwolf added the bug Something isn't working label Oct 18, 2022
@imjasonh
Copy link
Member

It's not a great answer, but ko_image resources are cheap and disposable -- can you change the name of the ko_image resource to something new, so terraform plan considers it a new resource without any preexisting state? This would also delete (no-op) the old image resource.

If that works you can rename the resource back to the old now-deleted resource name. I agree this isn't ideal though, since it requires a few manual steps.

Short of that though I'm not sure what would be better for the provider to do. It's possible there's an answer I just don't know it.

@mattmoor
Copy link
Contributor

mattmoor commented Nov 1, 2022

We just hit this in mono because of an otherwise seemingly benign import path change in one of our samples. :(

@k4leung4
Copy link
Contributor

k4leung4 commented Nov 1, 2022

got bit by with this change, chainguard-dev/platform-examples#9

@found-it
Copy link

I just hit this today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants