Fix Terraform Error: CloudWatch Log Group Already Exists
Fix terraform CloudWatch Log Group ResourceAlreadyExistsException. Import orphaned log groups, prevent Lambda auto-creation
DevOps
How to fix 'saved plan is stale' and 'plan was created with a different version' errors when using terraform plan -out files.
Error: Saved plan is stale / the given plan file can no longer be appliedThe saved plan file is outdated — someone else modified the infrastructure or state since the plan was generated. Terraform requires the real-world state to match exactly what existed when the plan was created.
# Simply re-plan and re-apply
terraform plan -out=tfplan
terraform apply tfplan# GitLab CI — plan and apply in same pipeline
stages:
- plan
- apply
plan:
stage: plan
script:
- terraform init
- terraform plan -out=tfplan
artifacts:
paths:
- tfplan
- .terraform
- .terraform.lock.hcl
apply:
stage: apply
script:
- terraform apply tfplan
dependencies:
- plan
when: manual
only:
- main# Use state locking to prevent conflicts
# S3 backend with DynamoDB — enabled by default
# For local state, only one person should apply at a time# Don't save plans for later — apply soon after planning
terraform plan -out=tfplan && terraform apply tfplan
# In CI/CD, plan and apply should be in the same pipeline runterraform plan — always review before applyingterraform validate — catches syntax errors earlyLearn to avoid these errors with interactive, project-based courses:
This error is common and fixable. Follow the solutions above, and check our Terraform course for hands-on training that covers real-world troubleshooting scenarios.
Fix terraform CloudWatch Log Group ResourceAlreadyExistsException. Import orphaned log groups, prevent Lambda auto-creation
Fix terraform import errors when a resource already exists in state. Covers state rm, state show, reimport workflow, import blocks
Fix terraform too many command line arguments errors. Correct -var syntax, quote values with spaces, and learn proper Terraform CLI argument format for plan
Fix terraform invalid escape sequence errors. Double backslashes for Windows paths, use heredocs for regex, and learn all valid HCL escape sequences.