Fix Terraform Error: CloudWatch Log Group Already Exists
Fix terraform CloudWatch Log Group ResourceAlreadyExistsException. Import orphaned log groups, prevent Lambda auto-creation
DevOps
Fix ConflictException when creating AWS Transfer Family servers in Terraform. Handle duplicate SFTP servers, endpoint conflicts, and identity provider issues.
An AWS Transfer Family server with conflicting configuration already exists — usually a VPC endpoint conflict or duplicate custom hostname. Import the existing server, delete the orphan, or use a different VPC endpoint.
Error: error creating Transfer Server: ConflictException:
The VPC endpoint is already associated with a server# List Transfer servers
aws transfer list-servers --query 'Servers[*].[ServerId,EndpointType,State]' --output table
# Import
terraform import aws_transfer_server.sftp s-1234567890abcdef0resource "aws_vpc_endpoint" "transfer" {
vpc_id = aws_vpc.main.id
service_name = "com.amazonaws.${var.region}.transfer.server"
vpc_endpoint_type = "Interface"
subnet_ids = aws_subnet.private[*].id
security_group_ids = [aws_security_group.transfer.id]
}
resource "aws_transfer_server" "sftp" {
endpoint_type = "VPC"
endpoint_details {
vpc_id = aws_vpc.main.id
subnet_ids = aws_subnet.private[*].id
security_group_ids = [aws_security_group.transfer.id]
}
protocols = ["SFTP"]
identity_provider_type = "SERVICE_MANAGED"
}# Stop and delete the conflicting server
aws transfer stop-server --server-id s-1234567890abcdef0
aws transfer delete-server --server-id s-1234567890abcdef0
terraform applyTransfer Family ConflictException usually means the VPC endpoint is already in use by another server. Import the existing server, create a new endpoint, or delete the orphan. Each VPC endpoint can only serve one Transfer server.
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.