Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip confirming on auto-apply enabled tfc workspaces #2397

Merged
merged 1 commit into from Dec 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 18 additions & 2 deletions packages/@cdktf/cli-core/src/lib/models/terraform-cloud.ts
Expand Up @@ -443,10 +443,16 @@ export class TerraformCloud implements Terraform {
_parallelism?: number
): Promise<void> {
const sendLog = this.createTerraformLogHandler("deploy");
if (!this.run)
if (!this.run) {
throw new Error(
"Please create a ConfigurationVersion / Plan before deploying"
);
}

if (this.run.attributes.autoApply) {
logger.info("Auto apply is enabled, skipping confirming the deploy plan");
return;
}

const deployingStates = ["confirmed", "apply_queued", "applying"];
const runId = this.run.id;
Expand Down Expand Up @@ -480,10 +486,20 @@ export class TerraformCloud implements Terraform {

@BeautifyErrors("Destroy")
public async destroy(): Promise<void> {
if (!this.run)
if (!this.run) {
throw new Error(
"Please create a ConfigurationVersion / Plan before destroying"
);
}

// if the workspace has auto apply enabled and we attempt to confirm the plan
// it will result in 409 error
if (this.run.attributes.autoApply) {
logger.info(
"Auto apply is enabled, skipping confirming the destroy plan"
);
return;
}

const sendLog = this.createTerraformLogHandler("destroy");
const destroyingStates = ["confirmed", "apply_queued", "applying"];
Expand Down