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

[Feature Request] Implementing Target Local-Previewes #263

Open
talqwe opened this issue Sep 23, 2024 · 6 comments
Open

[Feature Request] Implementing Target Local-Previewes #263

talqwe opened this issue Sep 23, 2024 · 6 comments
Labels
feature A new feature request needs-investigation This issue requires further examination to determine its validity or scope

Comments

@talqwe
Copy link

talqwe commented Sep 23, 2024

terraform plan -target=’resource’

provides a way to run plan only on specific resources

When running local-preview, the plan runs on all resources (our env has 1500 resources each) which can be very time consuming (4 envs with with 1500-2000 resources for example)

Can this be implemented with local-preview?
Something like:

spacectl stack local-preview --target='resource1' --target='resource2'
@tomasmik tomasmik added feature A new feature request needs-investigation This issue requires further examination to determine its validity or scope labels Sep 23, 2024
@tomasmik
Copy link
Contributor

Hey, this needs investigation, however my first impression is that this is quite complicated and would require a lot of work in the backend to actually make this happen. We tend to add features to spacectl that already exist in spacelift, however this doesn't really exist, so adding this is complicated and time consuming.

@talqwe
Copy link
Author

talqwe commented Sep 23, 2024

Hey, this needs investigation, however my first impression is that this is quite complicated and would require a lot of work in the backend to actually make this happen. We tend to add features to spacectl that already exist in spacelift, however this doesn't really exist, so adding this is complicated and time consuming.

Well, local-preview is a feature that doesn't exist in the UI of Spacelift, so adding this feature will be entirely in the spacectl scope, and won't be needed in Spacelift itself

@tomasmik
Copy link
Contributor

@talqwe that totally makes sense, however developers time is limited and the backend doesn't support picking resources before planning at least once no matter if it's a normal or a local preview run.

@moshevayner
Copy link

Hey @tomasmik !
I'm also following this issue, and I'm a bit curious.. In Spacelift UI, once I trigger a run, before I confirm it, I can actually mark a subset of the resources from the plan, and then trigger a re-plan with only the selected resources (which under the hood translates to a targeted plan on terraform, I presume):
image

With that in mind- is this not done via the same API that spacectl uses?

@tomasmik
Copy link
Contributor

With that in mind- is this not done via the same API that spacectl uses?

Hey, @moshevayner, you're correct but these runs work slightly differently. Also the request here as far as I understand is "plan specific resources only":

When running local-preview, the plan runs on all resources (our env has 1500 resources each) which can be very time consuming (4 envs with with 1500-2000 resources for example)

So using that API still forces us to plan all resources first and then replan only the selected ones (planning two times). This wouldn't save that much time. :(

@jeremyhager
Copy link

FWIW, a workaround that was discovered recently was to use --env-var-override the TF_CLI_ARGS_plan variable.
Example:

spacectl stack local-preview --env-var-override 'TF_CLI_ARGS_plan="-target=module.some_module_name"'
# or potentially
spacectl stack local-preview --env-var-override 'TF_CLI_ARGS_plan="-target=resource.resource_name"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature request needs-investigation This issue requires further examination to determine its validity or scope
Projects
None yet
Development

No branches or pull requests

4 participants