Completely removing a Ktor route fails when attempting to deploy via Terraform [Kotless 0.2.0, Ktor 1.50, AWS]
- Dominant language
- Kotlin
- Stars
- 1.2k
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
If I create a simple Ktor route in a Kotless project, e.g.:
```kotlin
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:
```* Exception is:
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure by deploying a Ktor route through Kotless, removing it, and running Terraform again. Start with the generated Terraform deployment and the reported dependency cycle involving aws_api_gateway_resource, aws_api_gateway_deployment, aws_lambda_function, and related resources. Done means the removed route can be redeployed without a Terraform cycle.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, kotlin, terraform
- Domain
- backend, cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100