public void DeployTemplate(string resourceName, string templateFilePath, IVariables variables) { var variablesFile = Path.GetTempFileName(); variables.Set("Octopus.Action.AwsAccount.Variable", "AWSAccount"); variables.Set("AWSAccount.AccessKey", ExternalVariables.Get(ExternalVariable.AwsAcessKey)); variables.Set("AWSAccount.SecretKey", ExternalVariables.Get(ExternalVariable.AwsSecretKey)); variables.Set("Octopus.Action.Aws.Region", region); variables.Save(variablesFile); using (var templateFile = new TemporaryFile(templateFilePath)) using (new TemporaryFile(variablesFile)) { var log = new InMemoryLog(); var fileSystem = CalamariPhysicalFileSystem.GetPhysicalFileSystem(); var command = new DeployCloudFormationCommand( log, variables, fileSystem, new ExtractPackage(new CombinedPackageExtractor(log, variables, new CommandLineRunner(log, variables)), fileSystem, variables, log), new StructuredConfigVariablesService(new PrioritisedList <IFileFormatVariableReplacer> { new JsonFormatVariableReplacer(fileSystem, log), new XmlFormatVariableReplacer(fileSystem, log), new YamlFormatVariableReplacer(fileSystem, log), new PropertiesFormatVariableReplacer(fileSystem, log), }, variables, fileSystem, log) ); var result = command.Execute(new[] { "--template", $"{templateFile.FilePath}", "--variables", $"{variablesFile}", "--stackName", resourceName, "--waitForCompletion", "true" }); result.Should().Be(0); } }