diff --git a/src/Cake.Terraform.Tests/TerraformApplyTests.cs b/src/Cake.Terraform.Tests/TerraformApplyTests.cs index ee5eb49..2107459 100644 --- a/src/Cake.Terraform.Tests/TerraformApplyTests.cs +++ b/src/Cake.Terraform.Tests/TerraformApplyTests.cs @@ -142,6 +142,22 @@ public void Should_Append_Auto_Approve_When_AutoApprove_Is_True() Assert.Contains("-auto-approve", result.Args); } + [Fact] + public void Should_Append_Destroy_When_AutoApprove_Is_True() + { + var fixture = new Fixture + { + Settings = new TerraformApplySettings + { + Destroy = true + } + }; + + var result = fixture.Run(); + + Assert.Contains("-destroy", result.Args); + } + [Fact] public void Should_set_plan_path() { diff --git a/src/Cake.Terraform/Apply/TerraformApplyRunner.cs b/src/Cake.Terraform/Apply/TerraformApplyRunner.cs index 813b51c..d90d077 100644 --- a/src/Cake.Terraform/Apply/TerraformApplyRunner.cs +++ b/src/Cake.Terraform/Apply/TerraformApplyRunner.cs @@ -17,6 +17,11 @@ public void Run(TerraformApplySettings settings) var builder = new ProcessArgumentBuilder() .Append("apply"); + if (settings.Destroy) + { + builder.Append("-destroy"); + } + // Order of AutoApprove and Plan are important. if (settings.AutoApprove) { diff --git a/src/Cake.Terraform/Apply/TerraformApplySettings.cs b/src/Cake.Terraform/Apply/TerraformApplySettings.cs index 9587975..0e29f9f 100644 --- a/src/Cake.Terraform/Apply/TerraformApplySettings.cs +++ b/src/Cake.Terraform/Apply/TerraformApplySettings.cs @@ -36,5 +36,11 @@ public TerraformApplySettings() /// https://www.terraform.io/docs/commands/apply.html#input-true /// public bool Input { get; set; } + + /// + /// Does destory + /// https://www.terraform.io/docs/commands/destroy.html + /// + public bool Destroy { get; set; } } } \ No newline at end of file