feat: handle non-existing stacks during delete gracefully, bump minimal Python to 3.9, latest Pulumi

This commit is contained in:
Stefan Reimer 2022-09-26 15:57:11 +02:00
parent 893c49bbb0
commit 611dddb062
5 changed files with 19 additions and 9 deletions

View File

@ -1,6 +1,6 @@
ARG RUNTIME_VERSION="3.10"
ARG DISTRO_VERSION="3.16"
ARG PULUMI_VERSION="3.38.0"
ARG PULUMI_VERSION="3.40.1"
FROM python:${RUNTIME_VERSION}-alpine${DISTRO_VERSION} AS builder
ARG PULUMI_VERSION

View File

@ -445,7 +445,7 @@ def _provision(cb, stacks):
for step in sort_stacks(cb, stacks):
if step:
# Pulumi is not thread safe, so for now one by one
if _anyPulumi(step):
if _anyPulumi(step) and False:
for stack in step:
if stack.mode != "pulumi":
status = stack.get_status()
@ -462,12 +462,17 @@ def _provision(cb, stacks):
with ThreadPoolExecutor(max_workers=len(step)) as group:
futures = []
for stack in step:
if stack.mode != "pulumi":
status = stack.get_status()
if not status:
futures.append(group.submit(stack.create))
else:
futures.append(group.submit(stack.update))
# Pulumi only needs "up"
else:
futures.append(group.submit(stack.create))
for future in as_completed(futures):
future.result()

View File

@ -834,7 +834,12 @@ class Stack(object):
logger.info("Deleting {0} {1}".format(self.region, self.stackname))
if self.mode == "pulumi":
try:
pulumi_stack = self._get_pulumi_stack()
except pulumi.automation.errors.StackNotFoundError:
logger.warning("Could not find Pulumi stack {}".format(self.stackname))
return
pulumi_stack.destroy(on_output=self._log_pulumi)
pulumi_stack.workspace.remove_stack(pulumi_stack.name)

View File

@ -11,7 +11,7 @@ authors = [
description = "Deploy and maintain infrastructure in automated and trackable manner"
readme = "README.md"
license = "AGPL-3.0-or-later"
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"boto3",
"mock",

View File

@ -5,7 +5,7 @@ click
pexpect
python-minifier
cfn-lint>=0.34
pulumi>=3.38.0
pulumi>=3.40.1
pulumi-aws>5.0.0
pulumi-aws-native
pulumi-policy