diff --git a/.github/actions/constellation_iam_destroy/action.yml b/.github/actions/constellation_iam_destroy/action.yml index 05daf4c91..846001d37 100644 --- a/.github/actions/constellation_iam_destroy/action.yml +++ b/.github/actions/constellation_iam_destroy/action.yml @@ -7,11 +7,4 @@ runs: - name: Delete IAM configuration shell: bash run: | - if [[ -f constellation-iam-terraform/terraform.tfstate ]]; then - echo "IAM Terraform state file exists, deleting..." - cd constellation-iam-terraform - terraform destroy -auto-approve - else - echo "IAM Terraform state file does not exist, exiting..." - exit 0 - fi + constellation iam destroy --yes diff --git a/.github/workflows/e2e-test-manual.yml b/.github/workflows/e2e-test-manual.yml index 93c1d5aec..ff3fd98bb 100644 --- a/.github/workflows/e2e-test-manual.yml +++ b/.github/workflows/e2e-test-manual.yml @@ -307,14 +307,12 @@ jobs: - name: Always terminate cluster if: always() - continue-on-error: true uses: ./.github/actions/constellation_destroy with: kubeconfig: ${{ steps.e2e_test.outputs.kubeconfig }} - name: Always delete IAM configuration if: always() && inputs.test == 'iamcreate' && inputs.cloudProvider != 'azure' # skip for Azure, as the SP / MI does not have the required permissions - continue-on-error: true uses: ./.github/actions/constellation_iam_destroy - name: Always destroy Azure resource group diff --git a/cli/internal/cmd/iam.go b/cli/internal/cmd/iamcreate.go similarity index 97% rename from cli/internal/cmd/iam.go rename to cli/internal/cmd/iamcreate.go index 87fd4b2c5..824c29c5b 100644 --- a/cli/internal/cmd/iam.go +++ b/cli/internal/cmd/iamcreate.go @@ -564,18 +564,3 @@ func parseIDFile(serviceAccountKeyBase64 string) (map[string]string, error) { } return out, nil } - -// NewIAMDestroyCmd returns a new cobra.Command for the iam destroy subcommand. -func newIAMDestroyCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "destroy", - Short: "Destroy an IAM configuration and delete local terraform files", - Long: "Destroy an IAM configuration and delete local terraform files.", - Args: cobra.ExactArgs(0), - RunE: runIAMDestroy, - } - - cmd.Flags().BoolP("yes", "y", false, "destroy the IAM configuration without asking for confirmation") - - return cmd -} diff --git a/cli/internal/cmd/iam_test.go b/cli/internal/cmd/iamcreate_test.go similarity index 100% rename from cli/internal/cmd/iam_test.go rename to cli/internal/cmd/iamcreate_test.go diff --git a/cli/internal/cmd/iamdestroy.go b/cli/internal/cmd/iamdestroy.go index c2af0b099..ebe0dca1f 100644 --- a/cli/internal/cmd/iamdestroy.go +++ b/cli/internal/cmd/iamdestroy.go @@ -18,6 +18,21 @@ import ( "github.com/spf13/cobra" ) +// NewIAMDestroyCmd returns a new cobra.Command for the iam destroy subcommand. +func newIAMDestroyCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "destroy", + Short: "Destroy an IAM configuration and delete local Terraform files", + Long: "Destroy an IAM configuration and delete local Terraform files.", + Args: cobra.ExactArgs(0), + RunE: runIAMDestroy, + } + + cmd.Flags().BoolP("yes", "y", false, "destroy the IAM configuration without asking for confirmation") + + return cmd +} + func runIAMDestroy(cmd *cobra.Command, _args []string) error { log, err := newCLILogger(cmd) if err != nil { @@ -129,7 +144,7 @@ func (c *destroyCmd) deleteGCPServiceAccountKeyFile(cmd *cobra.Command, destroye c.log.Debugf("Checking if keys are the same") if tfSaKey != fileSaKey { - cmd.Printf("The key in %q don't match up with your terraform state. %q will not be deleted.\n", constants.GCPServiceAccountKeyFile, constants.GCPServiceAccountKeyFile) + cmd.Printf("The key in %q don't match up with your Terraform state. %q will not be deleted.\n", constants.GCPServiceAccountKeyFile, constants.GCPServiceAccountKeyFile) return true, nil }