# Drift Detection Source: https://docs.anyshift.io/pages/iac/drift_detection Find the gap between what you declared in Terraform and what is actually running in your cloud and Kubernetes clusters. ## Overview Drift happens. Someone edits a security group in the AWS console, an engineer scales a deployment manually, a failed `terraform apply` leaves state out of sync. Annie continuously correlates your **declared** infrastructure (Terraform code + state) with your **actual** infrastructure (live cloud, live Kubernetes) and surfaces the gaps. What your Terraform modules and manifests say should exist. What your Terraform state believes it's tracking. What's really running in AWS, GCP, and Kubernetes right now. ## What You Can Ask Annie * *"What resources were modified outside of Terraform this week?"* * *"Show me security groups changed via the AWS console in the last 24 hours"* * *"Which IAM roles had policies attached manually?"* * *"Which live resources are not in any Terraform state file?"* * *"Show me EC2 instances with no Terraform backing"* * *"Which S3 buckets exist in AWS but aren't declared anywhere?"* * *"Are my declared replica counts matching the pods actually running?"* * *"Show me deployments where ready replicas differ from desired"* * *"Which ConfigMaps were edited directly in the cluster?"* * *"Which Terraform resources reference dependencies that no longer exist?"* * *"Show me state entries pointing to deleted cloud resources"* ## Real-World Examples PagerDuty alerted on an unexpected SSH attempt against a dev box. *"Has any security group been changed outside Terraform this week?"* > I found 2 manual changes: > > * `sg-dev-debug`: Port 22 opened to `0.0.0.0/0` via AWS console on Tuesday 14:03 by user `alice@...` > * `sg-prod-db`: Inbound rule for `10.0.5.0/24` added via CLI on Wednesday 09:17 > > Neither change is reflected in the Terraform code or state. The checkout service is flaky. I suspect a partial rollout. *"Which deployments have fewer ready replicas than declared?"* > 3 deployments have drift: > > * `checkout`: declared 8, ready: 5 (3 pods in `ImagePullBackOff`) > * `billing-worker`: declared 4, ready: 4 ✓ (no drift) > * `search-indexer`: declared 2, ready: 0 (OOMKilled, CrashLoopBackOff) > > The `checkout` image tag in your Helm values doesn't exist in the registry. I suspect the cloud bill has resources nobody remembers. *"Show me EC2 instances and RDS databases not backed by any Terraform state"* > I found 7 unmanaged resources across your AWS accounts: > > * 4 EC2 instances in `us-east-1` (tagged `env=experiment`, launched 2024) > * 2 RDS snapshots in `eu-west-1` (no source instance exists) > * 1 NAT Gateway in `us-west-2` (no route table references it) ## Best Practices Ask Annie for drift in the target environment before running `terraform plan`. It often explains surprising diffs. Drift queries are more useful when narrowed: *"...in the `prod` workspace"*, *"...in the `networking` module"*. Pair drift queries with [Change Management](/pages/product/time_travel) to see *who* made the change and *when*. Unmanaged resources are both a cost and a security concern. Ask Annie monthly. ## Get Started You need code + state connected for drift detection to work. Install the agent to get declared-vs-actual drift inside your clusters. # Kubernetes (Live) Source: https://docs.anyshift.io/pages/iac/kubernetes_live Anyshift streams live Kubernetes cluster state via an in-cluster agent and correlates it with your Terraform and application code. ## Overview The Anyshift Kubernetes agent runs in your cluster and streams **live resource state** to Annie's knowledge graph in near real-time. That live state is linked back to your Terraform declarations (for resources Terraform manages) and your application code, giving Annie a full picture from *declared* to *actually running*. For installation and setup, see the [Kubernetes integration page](/pages/integration/kubernetes). This page focuses on **what Annie does** with the data. ## What the Agent Captures * Pods, Deployments, ReplicaSets, StatefulSets, DaemonSets * Services, Ingresses * ConfigMaps, Secrets * PersistentVolumeClaims, PersistentVolumes * Namespaces, Nodes * RBAC (Roles, RoleBindings, ClusterRoles, ClusterRoleBindings) * HorizontalPodAutoscalers, PodDisruptionBudgets * Jobs, CronJobs * KEDA ScaledObjects / ScaledJobs * ... **Helm-deployed workloads** are visible too: Annie sees the Kubernetes resources that Helm created. Release-level metadata (chart version, revision history) isn't modeled as a first-class entity today. ## What You Can Ask Annie * *"How many pods are running in the `payments` namespace?"* * *"Which deployments have zero available replicas?"* * *"Show me all pods in CrashLoopBackOff"* * *"Which services expose port 443?"* * *"Are my declared replica counts matching what's actually running?"* * *"Which workloads have fewer ready pods than desired?"* * *"Show me resources in the cluster that weren't deployed by Helm or Terraform"* * *"Which Terraform module provisioned this cluster?"* * *"What application code runs in this pod?"* * *"Which RDS instance does this deployment connect to?"* ## Real-World Example Checkout service is slow. I want to know if it's a scaling issue. *"Is the checkout service scaled correctly?"* > The `checkout` deployment is declared with `replicas: 8`. > > * 8 ReplicaSet replicas scheduled > * **Only 5 pods Ready** (3 are `ImagePullBackOff` on `checkout:v2.3.1`) > * HPA is at max (`target: 80% CPU`, `current: 94%`) > > The underlying image pull is failing, likely a registry auth issue introduced by the latest deploy. ## Get Started Deploy the Anyshift Kubernetes agent via Helm. See how live K8s state fits into the three-universe model. # Infrastructure as Code Source: https://docs.anyshift.io/pages/iac/overview Anyshift is built on IaC. Annie correlates your Terraform code, Terraform state, and live infrastructure so you always know what you declared, what you stored, and what is actually running. ## Built on Infrastructure as Code Anyshift doesn't just read your cloud. It reads your **code**, your **state**, and your **live infrastructure**, then correlates the three so you can see where they agree and where they've drifted. Terraform code instantiates Terraform state, which manages live infrastructure Declared resources are linked to the state that instantiated them, and state entries are linked to the live resources they manage. That's how Annie answers questions that span layers: *"Which module deployed this pod?"*, *"What code manages this RDS instance?"*, *"Which resources are running without any Terraform backing?"* The same model applies to Kubernetes: declared manifests (or Helm charts) → live cluster state, streamed by the Anyshift agent. ## See the graph Annie can also draw the graph. Ask *"map our cluster"* or *"diagram the dependencies of the payment service"* and she renders the live topology from the [knowledge graph](/pages/overview/knowledge_graph) as a diagram you can read at a glance. Annie-generated Mermaid diagram of a Kubernetes production cluster topology The diagram comes from the same graph that powers [Annie Knowledge](/pages/product/annie_knowledge), so it shows what is *actually running* right now: real resource names, live dependencies, and gaps like a missing config or an unmanaged instance. No stale wiki sketch. ### Working with diagrams Zoom, pan, and open any diagram fullscreen to follow a dependency chain across layers. Every diagram lands in [**Artifacts → Diagrams**](https://app.anyshift.io/artifacts), so you can reopen and share it later. Diagrams are plain [Mermaid](https://mermaid.js.org). Copy the source and paste it into GitHub, Notion, or any Mermaid-compatible tool. Ask for a diagram in a [conversation](/pages/product/annie_knowledge), and dig deeper with a follow-up question right where you are. ## What You Can Ask Annie * *"Which Terraform module created this EC2 instance?"* * *"Show me all resources defined in the networking module"* * *"What variables does this state file use?"* * *"What resources were modified outside of Terraform this week?"* * *"Which live resources have no Terraform backing?"* * *"Are my declared replicas matching the pods actually running?"* See the [Drift Detection](/pages/iac/drift_detection) page for more. * *"What breaks if I destroy this module?"* * *"Which services depend on this security group?"* * *"If I change this variable, what resources are affected?"* ## Explore the IaC Section How Annie ingests Terraform code and state, and what she does with them. How Annie streams live cluster state and ties it to your declared K8s manifests. Find the gap between what you declared and what's actually running. How all of this connects under the hood. # Terraform Source: https://docs.anyshift.io/pages/iac/terraform Anyshift ingests your Terraform code and state, then correlates them against live cloud infrastructure to power drift detection, impact analysis, and code-to-infra queries. ## Overview Anyshift treats Terraform as a first-class citizen. Annie reads your **code** (modules, resources, variables) and your **state** (`.tfstate` files from S3 or HCP Terraform Cloud), and links both to the actual cloud resources they manage. HCL parsed from your connected Git repositories: modules, resources, data sources, variables, outputs, and inter-module references. `.tfstate` ingested from S3 buckets and HCP Terraform Cloud workspaces. Managed instances are linked back to their declarations and forward to the live cloud resources they manage. ## How It Connects Once your Terraform code and state are both connected, Annie builds this chain in her knowledge graph: A Terraform module declaration is instantiated as a state entry, which manages a live AWS VPC That chain is what lets you ask questions across layers, from code, to state, to the running resource, without leaving the chat. ## Connecting Your Terraform Connect GitHub or GitLab to ingest your Terraform modules, resources, and references. Connect HashiCorp Cloud Platform workspaces to ingest state from HCP Terraform Cloud. **S3 state buckets are auto-discovered.** If your Terraform state lives in S3, there's nothing extra to configure. Once your AWS account is connected, Annie detects state buckets automatically from your ingested Terraform backend blocks and from AWS API extraction. You'll see them in the Anyshift app under Integrations → Terraform Backends. ## What You Can Ask Annie * *"Which resources are managed by Terraform vs. manually?"* * *"Show me all modules that use the `aws_instance` resource"* * *"Which workspaces deploy to the `prod` environment?"* * *"What variables does the networking module expose?"* * *"What resources depend on this module?"* * *"If I destroy this VPC, what breaks?"* * *"Which services will be affected by changing this security group rule?"* * *"What resources were modified outside of Terraform?"* * *"Which live resources are not in any state file?"* See the [Drift Detection](/pages/iac/drift_detection) page for more. ## Real-World Examples I just ran `terraform apply` and want to verify what actually changed. *"What changed in the last 30 minutes?"* > I found 5 resources updated: > > * `aws_instance.prod-api-1`: instance\_type → t3.large > * `aws_instance.prod-api-2`: instance\_type → t3.large > * `aws_autoscaling_group.prod-api-asg`: desired\_capacity → 4 > * `aws_lb_target_group.prod-api-tg`: 2 new targets > * `aws_cloudwatch_metric_alarm.prod-api-cpu`: threshold → 80 > > All changes match your most recent plan. I'm about to refactor a shared module and want to know what depends on it. *"What uses the `shared-networking` module?"* > 14 workspaces reference `shared-networking`: > > * `platform-prod` (3 VPCs, 12 subnets) > * `data-prod` (1 VPC, 6 subnets) > * `security-prod` (consumes outputs: vpc\_id, private\_subnets) > * ... > > Breaking changes to the outputs will require coordinated updates. ## Get Started Ingest your Terraform code. Ingest your Terraform state from HCP (S3 is auto-detected). # AWS Integration Source: https://docs.anyshift.io/pages/integration/aws Connect Annie to your AWS account for real-time infrastructure mapping and monitoring.