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 ParameterNotFound when reading SSM parameters in Terraform. Handle missing parameters, wrong regions, and parameter hierarchies.
Error describing SSM parameter: ParameterNotFoundTerraform is trying to read an SSM Parameter Store parameter that doesn't exist, is in a different region, or the IAM role lacks permission to access it. This commonly happens with data sources referencing parameters that haven't been created yet.
# Check if the parameter exists
aws ssm get-parameter --name "/app/database/url" --region us-east-1
# Create it if missing
aws ssm put-parameter \
--name "/app/database/url" \
--type "SecureString" \
--value "postgresql://user:pass@host:5432/db"# SSM parameters are region-specific!
provider "aws" {
region = "us-east-1" # Must match where the parameter was created
}
data "aws_ssm_parameter" "db_url" {
name = "/app/database/url"
}# Use a default value if parameter might not exist
variable "db_url_override" {
default = ""
}
locals {
db_url = var.db_url_override != "" ? var.db_url_override : data.aws_ssm_parameter.db_url.value
}{
"Effect": "Allow",
"Action": [
"ssm:GetParameter",
"ssm:GetParameters",
"ssm:GetParametersByPath"
],
"Resource": "arn:aws:ssm:us-east-1:123456789012:parameter/app/*"
}terraform 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.