Terraform cycle - Error: Cycle: aws_api_gateway_resource.hello (destroy), aws_api_gateway_rest_api.kotless_app (destroy)
See original GitHub issueI’m experiencing this error when using Kotless with Ktor during Gradle deploy.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
> Task :initialize
aws_iam_role.say_hello: Refreshing state... [id=say-hello]
aws_iam_role_policy.say_hello: Refreshing state... [id=say-hello:terraform-20210309090955288800000001]
aws_lambda_permission.autowarm_say_hello: Refreshing state... [id=autowarm-say-hello]
aws_api_gateway_method.hello_get: Refreshing state... [id=agm-yman4njgzc-lyluof-GET]
aws_cloudwatch_event_rule.autowarm_say_hello: Refreshing state... [id=autowarm-say-hello]
aws_s3_bucket_object.say_hello: Refreshing state... [id=kotless-lambdas/say-hello.jar]
aws_api_gateway_rest_api.kotless_app: Refreshing state... [id=yman4njgzc]
aws_lambda_permission.hello_get: Refreshing state... [id=hello-get]
aws_api_gateway_resource.hello: Refreshing state... [id=lyluof]
aws_api_gateway_integration.hello_get: Refreshing state... [id=agi-yman4njgzc-lyluof-GET]
aws_lambda_function.say_hello: Refreshing state... [id=say-hello]
data.aws_region.current: Refreshing state...
aws_cloudwatch_event_target.autowarm_say_hello: Refreshing state... [id=autowarm-say-hello-terraform-20210309091106001500000003]
data.aws_iam_policy_document.good_get_assume: Refreshing state...
data.aws_s3_bucket.kotless_bucket: Refreshing state...
data.aws_caller_identity.current: Refreshing state...
data.aws_iam_policy_document.kotless_static_assume: Refreshing state...
aws_iam_role.kotless_static_role: Refreshing state... [id=kotless-static-role]
aws_api_gateway_deployment.root: Refreshing state... [id=2dy1bq]
data.aws_iam_policy_document.good_get: Refreshing state...
data.aws_iam_policy_document.kotless_static_policy: Refreshing state...
aws_iam_role_policy.kotless_static_policy: Refreshing state... [id=kotless-static-role:terraform-20210309090955291500000002]
Error: Cycle: aws_api_gateway_resource.hello (destroy), aws_api_gateway_rest_api.kotless_app (destroy), aws_api_gateway_deployment.root, aws_api_gateway_deployment.root (destroy deposed ce7d4b13), aws_api_gateway_integration.hello_get (destroy)
My gradle configurations.
// build.gradle.kts
import io.kotless.plugin.gradle.dsl.kotless
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.3.61"
id("io.kotless") version "0.1.6" apply true
}
group = "com.dariopellegrini.ktorkotless"
version = "0.1"
repositories {
mavenCentral()
jcenter()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
testImplementation(kotlin("test-junit"))
implementation(kotlin("stdlib"))
implementation("io.kotless", "ktor-lang", "0.1.6")
}
tasks.test {
useJUnit()
}
tasks.withType<KotlinCompile>() {
kotlinOptions {
jvmTarget = "1.8"
languageVersion = "1.3"
apiVersion = "1.3"
}
}
kotless {
config {
bucket = "my.bucket"
terraform {
profile = "dario.pellegrini.dev"
region = "eu-west-1"
}
}
webapp {
lambda {
memoryMb = 128
kotless {
packages = setOf("com.dariopellegrini.ktorkotless")
}
}
}
}
// settings.gradle.kts
rootProject.name = "KtorKotless"
pluginManagement {
repositories {
gradlePluginPortal()
}
}
Before doing this I deployed correctly using Kotless DSL on that bucket. It seems there is some kind of conflict. Everything is working well using gradle local with Ktor.
Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Cycle error when removing a resource along with ...
Terraform fails to apply a plan, citing a dependency cycle, but I think that is wrong. I am not positive, because I do...
Read more >Terraform cycle error with AWS API Gateway Rest API
I notice that your cycle message includes a aws_api_gateway_deployment.isu-adapter (destroy deposed d32dac59) entry, which suggests that a ...
Read more >How to troubleshoot 5 common Terraform errors
Terraform may destroy or change existing resources if your state is ... A cycle error is considered to be an instance of circular...
Read more >How to handle issues due to create_before_destroy and " ...
By default, Terraform will first destroy a resource prior to recreating it when the ... Error: Cycle: errors containing the deposed resource.
Read more >Terraform Cycle Error
The deployment works fine, but when trying to destroy it, the error below appears. I tried with Terraform Graph to determine if there's...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As mentioned by @djohnsson the problem disappears after deleting lambdas created by Kotless on S3. I have to do that every time I redeploy. Not a solution in my opinion.
@TanVD I found one situation where the Cycle-error appeared which is when I changed the
mergeLambda
-optimization parameter. When I changed it back to the previous value the error disappeared. So:None
->All
(Cycle-error)All
->None
(Error is gone again)As one might expect there was a large difference between what the plan stages (None vs All) were reporting before I attempted the deploys. Hope that helps.
Edit: Also, it seems to appear when I remove a route from
app.routing { }