diff --git a/data_safe_haven/infrastructure/project_manager.py b/data_safe_haven/infrastructure/project_manager.py index c81b52b8fe..6008f26cf8 100644 --- a/data_safe_haven/infrastructure/project_manager.py +++ b/data_safe_haven/infrastructure/project_manager.py @@ -286,12 +286,22 @@ def destroy(self) -> None: raise DataSafeHavenPulumiError(msg) from exc def ensure_config(self, name: str, value: str, *, secret: bool) -> None: - """Ensure that config values have been set, setting them if they do not exist""" + """ + Ensure that config values have been set. + + Values will be set if they do not exist. + + If the value is already set and does not match the `value` argument, + `DataSafeHavenPulumiError` will be raised. + """ try: existing_value = self.stack.get_config(name).value except automation.CommandError: + # Set value if it does not already exist self.set_config(name, value, secret=secret) + # If the value does already exist, ensure it is consistent with the declared + # value if existing_value != value: msg = ( f"Unchangeable configuration option '{name}' not consistent, "