lemon-church-28946
11/23/2022, 3:00 PMLocalWorkspace
◦ Stack
◦ pulumi.automation
• I've tried pulumi.automation.create_stack
and importing an export via stack.new_stack
, but it errors out because it requires a --force
flag due to the fact that the exported stack is still deployed.
pulumi.automation.errors.CommandError:
code: 255
stdout:
stderr: warning: A new version of Pulumi is available. To upgrade from version '3.44.2' to '3.47.2', visit <https://pulumi.com/docs/reference/install/> for manual instructions and release notes.
error: 'stack-name-redactified' still has resources; removal rejected. Possible actions:
- Make sure that 'stack-name-redactified' is the stack that you want to destroy
- Run `pulumi destroy` to delete the resources, then run `pulumi stack rm`
- Run `pulumi stack rm --force` to override this error
Am I making this more complicated than necessary? Is there a way of passing the --force
flag such that the methods will acknowledge it?force
parameter isn't available.LocalWorkspace does not utilize this extensibility point.
many-telephone-49025
11/23/2022, 4:22 PMlemon-church-28946
11/23/2022, 4:31 PMfrom pulumi import automation as auto
class LocalWorkspace(auto.LocalWorkspace):
def _run_pulumi_cmd_sync(self, args:list, *aargs, **kwargs):
args.append('--force')
try:
return super()._run_pulumi_cmd_sync(args, *aargs, **kwargs)
except:
args.pop(args.index('--force'))
return super()._run_pulumi_cmd_sync(args, *aargs, **kwargs)
auto._local_workspace.LocalWorkspace = LocalWorkspace
Warning:
• ^ above block of code blindly pass the --force
flag to all commands.
• I just needed this as a one-off solution, and it shouldn't be considered....for anything ever.