From 4f89c179f32b66bb0aa2269c9ac93cc44f234bbe Mon Sep 17 00:00:00 2001 From: bra-fsn Date: Wed, 15 May 2024 23:36:52 +0200 Subject: [PATCH] Fix overwrites --- src/sc_runner/resources/aws.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sc_runner/resources/aws.py b/src/sc_runner/resources/aws.py index 9b5dd82..bea0838 100644 --- a/src/sc_runner/resources/aws.py +++ b/src/sc_runner/resources/aws.py @@ -3,6 +3,7 @@ from .base import StackName, default, defaults from typing import Annotated import click +import copy import os import pulumi import pulumi_aws as aws @@ -50,6 +51,11 @@ def resources_aws( ingress_rules: Annotated[str, DefaultOpt(["--ingress-rules"], type=JSON, default=defaults(DEFAULTS, "ingress_rules"), help="List of Pulumi aws.ec2.SecurityGroupIngressRule options")] = default(DEFAULTS, "ingress_rules"), egress_rules: Annotated[str, DefaultOpt(["--egress-rules"], type=JSON, default=defaults(DEFAULTS, "egress_rules"), help="List of Pulumi aws.ec2.SecurityGroupEgressRule options")] = default(DEFAULTS, "egress_rules"), ): + # as this function might be called multiple times, and we change the values below, we must make sure we work on copies + instance_opts = copy.deepcopy(instance_opts) + vpc_opts = copy.deepcopy(vpc_opts) + subnet_opts = copy.deepcopy(subnet_opts) + sg_opts = copy.deepcopy(sg_opts) prov_kwargs = {} if assume_role_arn: prov_kwargs["assume_role"] = aws.ProviderAssumeRoleArgs(role_arn=assume_role_arn)