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

Completely removing a Ktor route fails when attempting to deploy via Terraform [Kotless 0.2.0, Ktor 1.50, AWS] #110

Open
v79 opened this issue Aug 20, 2021 · 2 comments

Comments

@v79
Copy link

v79 commented Aug 20, 2021

If I create a simple Ktor route in a Kotless project, e.g.:

get("/test-delete") {
call.respondText("This function needs to be deleted")
}

This deploys successfully to AWS and appears in the API gateway as expected.

But if I then delete the route entirely, and redeploy, the deployment fails. The stacktrace isn't particularly helpful:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':deploy'.
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:188)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$$Lambda$481/0x0000000000000000.accept(Unknown Source)
...
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.IllegalStateException: Command failed: 'D:\Development\Experiments\Kotless\KotlessTestBeta\build\kotless-bin\terraform [apply, -auto-approve]'
	at io.kotless.plugin.gradle.utils.CommandLine.executeOrFail(CommandLine.kt:51)
	at io.kotless.plugin.gradle.tasks.terraform.TerraformOperationTask.act(TerraformOperationTask.kt:43)

To get more information, I tried executing terraform apply manually, which returned the following errors:

build\kotless-gen\deploy> ..\..\kotless-bin\terraform.exe apply
...
Plan: 1 to add, 10 to change, 12 to destroy.
Do you want to perform these actions? yes

Error: Cycle: aws_s3_bucket_object.test_delete_get (destroy), aws_api_gateway_resource.test_delete (destroy), aws_iam_role.test_delete_get (destroy), aws_api_gateway_deployment.root, aws_api_gateway_deployment.root (destroy deposed 8be2616a), aws_api_gateway_integration.test_delete_get (destroy), aws_lambda_function.test_delete_get (destroy)

Perhaps some sort of circular depedency?

Kotless 0.2.0, Ktor 1.5.0, AWS, Windows 10 x64.

@v79
Copy link
Author

v79 commented Aug 20, 2021

The workaround is to manually delete the test_delete method from the API gateway manually, then redeploy.

@graesj
Copy link

graesj commented Feb 4, 2022

I just encountered the same problem with the same technologies: Kotless 0.2.0, Ktor 1.5.0, AWS, Windows 10x64

Perhaps this can be of use: hashicorp/terraform-provider-aws#11344

@v79 Thanks for the workaround suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants