1
- # S3 Redirects Deployment System
1
+ # S3 Redirects Test
2
2
3
- This documentation explains how to deploy URL redirects for the CircleCI documentation site using AWS S3's website redirect functionality .
3
+ Simple test setup to validate AWS S3 website redirect functionality for the CircleCI documentation site.
4
4
5
5
## Overview
6
6
7
- The redirect system uses AWS S3's built-in website redirect feature by creating empty objects with redirect metadata. When a user visits an old URL, S3 automatically redirects them to the new URL with a 301 (permanent redirect) status.
7
+ This tests S3's built-in website redirect feature by creating an empty object with redirect metadata. When a user visits the old URL, S3 automatically redirects them to the new URL with a 301 (permanent redirect) status.
8
8
9
9
## Files
10
10
11
- - ` scripts/redirects_v2.yml ` - YAML file containing all redirect mappings
12
- - ` scripts/deploy-redirects-batch.sh ` - Optimized batch deployment script
11
+ - ` scripts/test-single-redirect.sh ` - Simple test script with hardcoded redirect
12
+ - ` scripts/redirects_v2.yml ` - Full redirect mappings (for future use)
13
13
14
14
## How It Works
15
15
16
- 1 . ** Redirect File Format** : The ` redirects_v2.yml ` file contains redirect mappings:
17
- ``` yaml
18
- - old : /about-circleci/
19
- new : /guides/about-circleci/about-circleci/index.html
16
+ 1 . ** Test Redirect** : Hardcoded in the script:
17
+ ```
18
+ /about-circleci/ -> /guides/about-circleci/about-circleci/index.html
20
19
```
21
20
22
21
2 . ** Deployment Process** :
23
- - Parse the YAML file
24
- - For each redirect, create an S3 object at the old path
25
- - Set the ` x-amz-website-redirect-location` metadata to the new path
22
+ - Create S3 object at ` about-circleci/index.html `
23
+ - Set ` x-amz-website-redirect-location ` metadata to new path
26
24
- S3 automatically handles the redirect
27
25
28
- 3. **URL Mapping** :
29
- - Old paths like `/about-circleci/` become S3 objects at `about-circleci/index.html`
30
- - When accessed, S3 returns a 301 redirect to the new location
31
-
32
26
## Usage
33
27
34
- # ## Deploy Redirects
28
+ ### Test Single Redirect
35
29
36
- The redirect deployment is integrated into the CircleCI pipeline and runs automatically after the main site deployment.
37
-
38
- Manual deployment :
39
30
``` bash
40
- bash scripts/deploy-redirects-batch .sh "bucket-name" "scripts/redirects_v2.yml "
31
+ bash scripts/test-single-redirect .sh " bucket-name"
41
32
```
42
33
34
+ ### Manual Testing
43
35
44
-
45
- # # Performance Considerations
46
-
47
- # ## Batch Processing
48
- The `deploy-redirects-batch.sh` script is optimized for handling redirects efficiently :
49
- - Processes redirects in batches of 50
50
- - Uses concurrent uploads (10 parallel requests)
51
- - Includes error handling and retry logic
52
- - Handles hundreds of redirects quickly
53
-
54
- # ## Rate Limiting
55
- - The deployment script includes appropriate rate limiting
56
- - Batch script uses thread pools to manage concurrency
57
-
58
- # # CircleCI Integration
59
-
60
- The redirect deployment is integrated into the `deploy-production` job :
61
-
62
- 1. **Install Dependencies** : Installs PyYAML for YAML parsing
63
- 2. **Deploy Main Site** : Syncs the Antora build to S3
64
- 3. **Deploy Redirects** : Creates redirect objects using the batch script
65
-
66
- # # Adding New Redirects
67
-
68
- 1. Edit `scripts/redirects_v2.yml`
69
- 2. Add new redirect mapping :
70
- ` ` ` yaml
71
- - old: /old-path/
72
- new: /new-path/index.html
73
- ` ` `
74
- 3. Commit and push - redirects will be deployed automatically
75
-
76
- # # Redirect Format Guidelines
77
-
78
- - **Old paths**: Should start with `/` and can end with or without `/`
79
- - **New paths**: Should be the full path to the new location
80
- - **Index files**: Old paths without file extensions automatically get `index.html` appended
81
- - **Trailing slashes**: Old paths are normalized (trailing slashes removed)
82
-
83
- # # Troubleshooting
84
-
85
- # ## Common Issues
86
-
87
- 1. **Permission Errors** : Ensure AWS credentials have S3 write permissions
88
- 2. **YAML Parse Errors** : Validate YAML syntax in redirects file
89
- 3. **S3 Bucket Errors** : Verify bucket name and region settings
90
-
91
- # ## Checking Redirect Status
92
-
93
- Use curl to test individual redirects :
36
+ Test the deployed redirect:
94
37
``` bash
95
38
curl -I " https://circleci.com/docs/about-circleci/"
96
39
```
@@ -101,19 +44,30 @@ HTTP/1.1 301 Moved Permanently
101
44
Location: /guides/about-circleci/about-circleci/index.html
102
45
```
103
46
104
- # ## Debugging
47
+ ## CircleCI Integration
48
+
49
+ The redirect test is integrated into the ` deploy-production ` job:
50
+
51
+ 1 . ** Deploy Main Site** : Syncs the Antora build to S3
52
+ 2 . ** Deploy Test Redirect** : Creates single redirect object
105
53
106
- 1. Check CircleCI logs for deployment errors
107
- 2. Test redirects manually with curl or browser
108
- 3. Manually inspect S3 objects and their metadata
54
+ ## AWS Command
55
+
56
+ The core redirect is created with:
57
+ ``` bash
58
+ aws s3api put-object \
59
+ --bucket bucket-name \
60
+ --key about-circleci/index.html \
61
+ --website-redirect-location /guides/about-circleci/about-circleci/index.html \
62
+ --content-type text/html \
63
+ --content-length 0
64
+ ```
109
65
110
- # # Best Practices
66
+ ## Next Steps
111
67
112
- 1. **Test Manually** : Use curl or browser to spot-check redirects when needed
113
- 2. **Batch Operations** : Use the batch script for large numbers of redirects
114
- 3. **Monitor Performance** : Keep an eye on deployment times and error rates
115
- 4. **Clean URLs** : Ensure redirect paths are clean and consistent
116
- 5. **Backup** : Keep backup of working redirect files before major changes
68
+ 1 . Test this single redirect works
69
+ 2 . If successful, implement batch processing for all 502 redirects in ` redirects_v2.yml `
70
+ 3 . The full redirect system can be found in previous git commits
117
71
118
72
## AWS S3 Website Configuration
119
73
0 commit comments