Skip to content

Commit

Permalink
Add lifecycle hint to integration example.
Browse files Browse the repository at this point in the history
While testing update of an application resource with integrations where
RequiresReplace is hit, found an issue with integrations. Removal of an
application, also removes any integrations used by the application. This
causes state confusion for terraform. Adding the replaced_triggered_by
lifecycle info, allows for the integration to also be replaced if the
related application resources are.

List specific schema attributes so that no any change to the application
will trigger the integration as well.
  • Loading branch information
hmlanigan committed Oct 24, 2023
1 parent 35af322 commit f82a5d1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/resources/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ resource "juju_integration" "this" {
name = juju_application.percona-cluster.name
endpoint = "server"
}
# Add any RequiresReplace schema attributes of
# an application in this integration to ensure
# it is recreated if one of the applications
# is Destroyed and Recreated by terraform. E.G.:
lifecycle {
replace_triggered_by = [
juju_application.wordpress.name,
juju_application.wordpress.model,
juju_application.wordpress.constraints,
juju_application.wordpress.placement,
juju_application.wordpress.charm.name,
juju_application.percona-cluster.name,
juju_application.percona-cluster.model,
juju_application.percona-cluster.constraints,
juju_application.percona-cluster.placement,
juju_application.percona-cluster.charm.name,
]
}
}
```

Expand Down
19 changes: 19 additions & 0 deletions examples/resources/juju_integration/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,23 @@ resource "juju_integration" "this" {
name = juju_application.percona-cluster.name
endpoint = "server"
}

# Add any RequiresReplace schema attributes of
# an application in this integration to ensure
# it is recreated if one of the applications
# is Destroyed and Recreated by terraform. E.G.:
lifecycle {
replace_triggered_by = [
juju_application.wordpress.name,
juju_application.wordpress.model,
juju_application.wordpress.constraints,
juju_application.wordpress.placement,
juju_application.wordpress.charm.name,
juju_application.percona-cluster.name,
juju_application.percona-cluster.model,
juju_application.percona-cluster.constraints,
juju_application.percona-cluster.placement,
juju_application.percona-cluster.charm.name,
]
}
}

0 comments on commit f82a5d1

Please sign in to comment.