Destroying this resource archives the logical environment in Kosli. Archiving requires an API token with the Admin role. A Member token can create and update logical environments, but
terraform destroy fails with 403 Forbidden.Changing
name renames the logical environment in place, the same as kosli rename environment. The logical environment keeps its identity and history. The old name keeps resolving to the renamed environment until another environment is created with, or renamed to, that name. See Renaming logical environments.- Unified visibility: View compliance status across multiple environments at once
- Flexible grouping: Organize environments by region, service type, tier, or team
- Simplified reporting: Generate compliance reports for logical groupings
- Team organization: Allow different teams to focus on specific environment groups
Physical environments only
Example usage
Complete example
For a comprehensive example showing logical environments aggregating physical environments by region, service type, and tier, see the complete logical environments example.Common use cases
By environment tier
Aggregate all production or staging environments for unified compliance reporting:By geographic region
Group environments by region for regional compliance or disaster recovery:By service type
Organize environments by technology stack or service type:Empty logical environments
Logical environments can be created with emptyincluded_environments lists and populated later:
Import
Logical environments can be imported using their name:Renaming logical environments
Changingname renames the logical environment in place, the same as kosli rename environment. The logical environment keeps its identity, snapshot history, included environments and tags, and the plan shows an update rather than a replacement.
After a rename, the old name still resolves to the renamed logical environment for both reads and writes. The old name stops resolving once another environment is created with, or renamed to, that name.
Terraform has no ordering between two resources that are both renamed in one plan. If one resource takes the name another is giving up, such as a to b together with b to c, or a swap, the rename that runs first can hit a name that still exists. Apply chained renames in separate steps.
Destroying logical environments
Kosli never hard-deletes environments. When you runterraform destroy or remove a kosli_logical_environment from your configuration, the provider archives the logical environment. The physical environments it included are not affected.
Archiving an environment requires a Kosli API token with the Admin role. A token with the Member role can create and update logical environments but cannot archive them. In that case,
terraform destroy fails with 403 Forbidden and the resource stays in state. If you cannot use an Admin token and only want Terraform to stop managing the logical environment, run terraform state rm kosli_logical_environment.<name> instead. The logical environment then remains active in Kosli. See required permissions for how to set up a service account with the right permissions.Querying metadata
Schema
Required
included_environments(List of String) List of physical environment names to aggregate. Only physical environments are allowed (K8S, ECS, S3, docker, server, lambda). Can be empty.name(String) Name of the logical environment. Must be unique within the organization. Changing this renames the logical environment in place, keeping its snapshot history. The old name keeps resolving to the renamed environment until another environment is created with, or renamed to, that name.
Optional
description(String) Description of the logical environment. Explains the purpose and aggregation strategy.tags(Map of String) Key-value pairs to tag the logical environment. Tags are applied via a diff — only changed tags are sent to the API. An empty map (tags = {}) removes all tags.
Read-only
type(String) Type of the environment. Always set tological(computed by provider, not user-configurable).