tilt-extensions icon indicating copy to clipboard operation
tilt-extensions copied to clipboard

Speedup Tilt Pulumi extension by skipping the preview

Open lukasholzer opened this issue 10 months ago • 2 comments

I would propose making the tilt-extensions pulumi faster by adding the --skip-preview flag by that it will directly start applying the necessary changes without first planning them.

https://github.com/tilt-dev/tilt-extensions/blob/master/pulumi/pulumi-apply-helper.py#L14

import os
import subprocess
import sys

stack = os.environ.get('STACK', '')
extension_dir = os.path.dirname(sys.argv[0])
image_configs = sys.argv[1:]

- apply_cmd = ['pulumi', 'up', '--refresh', '-y']
+ apply_cmd = ['pulumi', 'up', '--refresh', '--skip-preview', '-y']
for i in range(len(image_configs)):
  config = image_configs[i]
  image = os.environ['TILT_IMAGE_%s' % i]
  apply_cmd.extend(['--config', '%s=%s' % (config, image)])

get_cmd = ['python3', os.path.join(extension_dir, 'pulumi-get.py')]
if stack:
  apply_cmd.extend(['--stack', stack])
  get_cmd.extend([stack])

subprocess.check_call(apply_cmd, stdout=sys.stderr)
subprocess.check_call(get_cmd)

I think for local dev the speed benefit would be a huge improvement.

Cons

Possible downside is that it might can lead to corrupted states but this can be resolved locally really well. (invalid schema configuration can lead to resources being created)

Solution make it configureable on the pulumi resource:

  pulumi_resource(
    'infra',
    stack='dev',
    dir='_infra/',
    deps=glob("_infra/src/**"),

    # proposed setting
    skipPreview=True,
  )

By that it would not be breaking and instead just a feature that got added

I'm happy to provide a PR with the necessary changes if you folks think it's a good idea! Pinging @nicks here as the author and owner of the extension.

lukasholzer avatar Feb 17 '25 15:02 lukasholzer

seems reasonable to me!

nicks avatar Feb 17 '25 22:02 nicks

I would probably lean towards making --skip-preview the default, we can make it an option if anybody complains

nicks avatar Feb 18 '25 02:02 nicks