Troubleshooting¶
This page covers common issues and their solutions when using the terraform-aws-http-redirect module.
Certificate Validation Issues¶
Timeout During Certificate Validation¶
Error:
Cause: DNS validation records are not properly created or propagated.
Solution:
-
Verify your Route 53 hosted zone is publicly accessible:
-
Check that the returned nameservers match your Route 53 zone's NS records:
-
Verify the validation records were created:
-
Wait 5-10 minutes for DNS propagation and retry:
Tip
If using a newly registered domain, DNS propagation can take up to 48 hours.
Certificate in Wrong Region¶
Error:
Error: creating CloudFront Distribution: InvalidViewerCertificate:
The specified SSL certificate doesn't exist, isn't in us-east-1 region
Cause: The ACM certificate was not created in us-east-1.
Solution: Ensure you pass both providers to the module:
module "http-redirect" {
source = "registry.infrahouse.com/infrahouse/http-redirect/aws"
version = "2.0.0"
# ... other configuration ...
providers = {
aws = aws
aws.us-east-1 = aws.us-east-1 # This is required!
}
}
Provider Configuration Issues¶
Provider Configuration Not Present¶
Error:
Solution: Define both required providers:
provider "aws" {
region = "us-west-2" # Your primary region
}
provider "aws" {
alias = "us-east-1"
region = "us-east-1"
}
Module Does Not Support Provider¶
Error:
Solution: Use the correct provider block syntax:
module "http-redirect" {
# ...
providers = {
aws = aws # Default provider
aws.us-east-1 = aws.us-east-1 # Aliased provider for ACM
}
}
DNS Issues¶
Redirect Not Working¶
Symptoms: Accessing the domain shows CloudFront error or times out.
Diagnostic steps:
-
Verify DNS records point to CloudFront:
Should return CloudFront domain (format:d111111abcdef8.cloudfront.net) -
Check CloudFront distribution status:
Status should beDeployed(initial deployment takes 15-30 minutes) -
Test redirect manually:
Should return HTTP 301 with Location header
DNS Records Not Created¶
Symptoms: dig returns NXDOMAIN or wrong records.
Solution:
-
Verify the zone_id is correct:
-
Check Terraform state:
-
Ensure the hosted zone is for the correct domain
S3 Issues¶
Bucket Already Exists¶
Error:
Cause: S3 bucket names are globally unique. The bucket name derived from your hostname is already taken.
Solutions:
- If you previously created and deleted the bucket, wait 24 hours (AWS requirement)
- If another account owns the bucket, use a different hostname prefix
- Check if you have an existing bucket with the same name in another region
Bucket Already Owned By You¶
Error:
Cause: The bucket exists in your account, possibly from a previous deployment.
Solutions:
-
Import the existing bucket:
-
Or delete the existing bucket (if empty):
CloudFront Issues¶
Distribution Not Deploying¶
Symptoms: Distribution stuck in "In Progress" state for over 30 minutes.
Solution:
-
Check for CloudFront service issues: AWS Service Health Dashboard
-
Verify no conflicting distributions exist:
-
Check CloudWatch for errors:
Access Denied Errors¶
Symptoms: CloudFront returns 403 Access Denied.
Possible causes:
- S3 bucket policy not applied
- CloudFront Origin Access Identity issues
- S3 website endpoint not configured
Diagnostic:
Logging Issues¶
Logs Not Appearing¶
Symptoms: Logging bucket is empty after redirect traffic.
Solutions:
-
Verify logging is enabled:
-
CloudFront logs are delivered with ~24 hour delay
- Check bucket permissions allow CloudFront to write
Verification Commands¶
Use these commands to verify your deployment:
# Test HTTP to HTTPS redirect
curl -I http://www.example.com
# Test HTTPS redirect to target
curl -I https://www.example.com
# Test path preservation
curl -I https://www.example.com/some/path
# Test query string preservation
curl -I "https://www.example.com/page?foo=bar&baz=qux"
# Check response headers
curl -I https://www.example.com 2>&1 | grep -i "strict-transport-security\|x-frame-options"
Expected responses:
| Request | Expected Response |
|---|---|
| HTTP request | 301 redirect to HTTPS version |
| HTTPS request | 301 redirect to target domain |
| With path | Location header preserves path |
| With query | Location header preserves query params |
Getting Help¶
If you're still experiencing issues:
- Check the GitHub Issues
- Review AWS CloudFront documentation
- Contact InfraHouse for professional support