Skip to content

Commit 4bf1f77

Browse files
author
Yuriy Bezsonov
committed
before code-editor refactoring
1 parent 43f76ee commit 4bf1f77

10 files changed

Lines changed: 1613 additions & 2184 deletions

File tree

.kiro/specs/arm64-code-editor-support/design.md

Lines changed: 534 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Requirements Document
2+
3+
## Introduction
4+
5+
This feature adds ARM64 (Graviton) architecture support to the workshop IDE infrastructure, introduces AWS Code Editor as an alternative to code-server, enhances the extension installation with a comprehensive set for Java workshops, adds Kiro CLI installation, and implements token-based URL access for Workshop Studio integration.
6+
7+
## Glossary
8+
9+
- **ARM64/Graviton**: AWS's ARM-based processors offering better price-performance for many workloads
10+
- **Code Editor**: AWS's VS Code-based IDE for Workshop Studio
11+
- **code-server**: Open-source VS Code server implementation currently used
12+
- **Kiro CLI**: AWS's AI-powered CLI tool for development assistance
13+
- **Workshop Studio**: AWS's platform for hosting interactive workshops
14+
- **Architecture Parameter**: CDK construct parameter that determines whether to use ARM64 or x86_64 instances and binaries
15+
16+
## Requirements
17+
18+
### Requirement 1: Architecture Parameter in CDK
19+
20+
**User Story:** As a workshop administrator, I want to specify the architecture (ARM64 or x86_64) as a CDK parameter, so that instance types and script behavior are automatically derived from this single setting.
21+
22+
#### Acceptance Criteria
23+
24+
1. WHEN the Ide construct is instantiated THEN the System SHALL accept an architecture parameter (ARM64 or X86_64)
25+
2. WHEN architecture is set to ARM64 THEN the System SHALL use Graviton instance types (m7g, m6g families)
26+
3. WHEN architecture is set to X86_64 THEN the System SHALL use Intel/AMD instance types (m7i-flex, m6i, m5 families)
27+
4. WHEN architecture is set THEN the System SHALL pass the architecture value to UserData for script consumption
28+
5. WHEN architecture parameter is not specified THEN the System SHALL default to ARM64
29+
30+
### Requirement 2: Architecture-Aware Script Downloads
31+
32+
**User Story:** As a workshop administrator, I want the IDE scripts to use the architecture from CDK parameter, so that the correct binary versions are downloaded.
33+
34+
#### Acceptance Criteria
35+
36+
1. WHEN the bootstrap scripts execute THEN the System SHALL read the architecture from environment variable set by UserData
37+
2. WHEN downloading kubectl THEN the System SHALL use the architecture-appropriate binary URL (arm64 or amd64)
38+
3. WHEN downloading SAM CLI THEN the System SHALL use the architecture-appropriate zip file (arm64 or x86_64)
39+
4. WHEN downloading eks-node-viewer THEN the System SHALL use the architecture-appropriate binary (arm64 or x86_64)
40+
5. WHEN downloading SOCI snapshotter THEN the System SHALL use the architecture-appropriate tarball (arm64 or amd64)
41+
6. WHEN downloading yq THEN the System SHALL use the architecture-appropriate binary (arm64 or amd64)
42+
7. WHEN downloading Helm THEN the System SHALL use the architecture-appropriate installation
43+
44+
### Requirement 3: AWS Code Editor Installation
45+
46+
**User Story:** As a workshop administrator, I want to install AWS Code Editor alongside code-server, so that I can choose the best IDE option for Workshop Studio integration.
47+
48+
#### Acceptance Criteria
49+
50+
1. WHEN the code-editor.sh script executes THEN the System SHALL download AWS Code Editor from code-editor.amazonaws.com
51+
2. WHEN downloading AWS Code Editor THEN the System SHALL verify the SHA256 checksum against the manifest
52+
3. WHEN installing AWS Code Editor THEN the System SHALL install to the user's ~/.local directory
53+
4. WHEN configuring AWS Code Editor THEN the System SHALL create a systemd service on port 8889 (same as code-server)
54+
5. WHEN configuring AWS Code Editor THEN the System SHALL accept the server license terms automatically
55+
6. WHEN the code-editor.sh script completes THEN the System SHALL configure Caddy to proxy port 8889
56+
57+
### Requirement 4: Extension Installation Enhancement
58+
59+
**User Story:** As a workshop participant, I want the IDE to have all necessary extensions pre-installed, so that I can start coding immediately without manual setup.
60+
61+
#### Acceptance Criteria
62+
63+
1. WHEN installing extensions THEN the System SHALL install AWS Toolkit extension (AmazonWebServices.aws-toolkit-vscode)
64+
2. WHEN installing extensions THEN the System SHALL install Java Extension Pack (vscjava.vscode-java-pack)
65+
3. WHEN installing extensions THEN the System SHALL install Docker extension (ms-azuretools.vscode-docker)
66+
4. WHEN installing extensions THEN the System SHALL install Kubernetes extension (ms-kubernetes-tools.vscode-kubernetes-tools)
67+
5. WHEN installing extensions THEN the System SHALL install Prettier extension (esbenp.prettier-vscode)
68+
6. WHEN installing extensions THEN the System SHALL install Trailing Spaces extension (shardulm94.trailing-spaces)
69+
7. WHEN extension installation fails THEN the System SHALL log the failure and continue with remaining extensions
70+
71+
### Requirement 5: Kiro CLI Installation
72+
73+
**User Story:** As a workshop participant, I want Kiro CLI pre-installed, so that I can use AI-assisted development features.
74+
75+
#### Acceptance Criteria
76+
77+
1. WHEN the bootstrap scripts execute THEN the System SHALL download and install Kiro CLI
78+
2. WHEN Kiro CLI installation completes THEN the System SHALL verify the installation by checking the version
79+
3. IF Kiro CLI installation fails THEN the System SHALL log the error and continue bootstrap
80+
81+
### Requirement 6: Token-Based URL Access
82+
83+
**User Story:** As a workshop administrator, I want the IDE URL to include an authentication token, so that Workshop Studio can provide seamless access.
84+
85+
#### Acceptance Criteria
86+
87+
1. WHEN AWS Code Editor is configured THEN the System SHALL create a token file at ~/.code-editor-server/data/token
88+
2. WHEN the CloudFormation stack outputs the URL THEN the System SHALL include the token parameter (?tkn=xxx)
89+
3. WHEN a user accesses the URL with valid token THEN the System SHALL authenticate automatically
90+
91+
### Requirement 7: CDK Instance Type Lists
92+
93+
**User Story:** As a workshop administrator, I want the CDK to have predefined instance type lists for each architecture, so that the correct instances are used based on the architecture parameter.
94+
95+
#### Acceptance Criteria
96+
97+
1. WHEN architecture is ARM64 THEN the System SHALL use instance types from the ARM64 list (m7g.xlarge, m6g.xlarge, t4g.xlarge)
98+
2. WHEN architecture is X86_64 THEN the System SHALL use instance types from the x86_64 list (m7i-flex.xlarge, m6i.xlarge, m5.xlarge, t3.xlarge)
99+
3. WHEN the CDK code is updated THEN the System SHALL preserve the old instance list as comments for reference
100+
4. WHEN instance launch fails THEN the System SHALL try the next instance type in the architecture-specific list
101+
102+
### Requirement 8: Shared Extension Installation Logic
103+
104+
**User Story:** As a maintainer, I want extension installation logic to be reusable, so that both code-server and AWS Code Editor can use the same code.
105+
106+
#### Acceptance Criteria
107+
108+
1. WHEN installing extensions THEN the System SHALL use a shared function that accepts the IDE binary path as parameter
109+
2. WHEN the shared function is called THEN the System SHALL use retry logic for resilience
110+
3. WHEN the shared function is called THEN the System SHALL support both code-server and code-editor-server binaries
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Implementation Plan
2+
3+
- [ ] 1. Add IdeArch and IdeType support to CDK Ide construct
4+
- [ ] 1.1 Create IdeArch enum in Ide.java
5+
- Add enum with ARM64 and X86_64 values
6+
- Include helper methods for AWS and uname values
7+
- _Requirements: 1.1_
8+
- [ ] 1.2 Create IdeType enum in Ide.java
9+
- Add enum with CODE_EDITOR and VSCODE values
10+
- Include scriptName helper method
11+
- _Requirements: 3.1_
12+
- [ ] 1.3 Add ideArch and ideType properties to IdeProps
13+
- Add ideArch field with ARM64 default
14+
- Add ideType field with CODE_EDITOR default
15+
- Create static instance type lists for each architecture
16+
- Update getInstanceTypes() to return ideArch-specific list
17+
- Update getMachineImage() to return ideArch-specific AMI
18+
- Add builder methods for ideArch and ideType
19+
- Comment out old instance type list for reference
20+
- _Requirements: 1.2, 1.3, 1.5, 7.1, 7.2_
21+
- [ ] 1.4 Update UserData to export ARCH and IDE_TYPE
22+
- Modify userdata.sh template to include ARCH and IDE_TYPE exports
23+
- Pass ideArch and ideType values from CDK to UserData
24+
- _Requirements: 1.4, 2.1_
25+
- [ ] 1.5 Write property test for ideArch → instance types mapping
26+
- **Property 1: Architecture determines instance types**
27+
- **Validates: Requirements 1.2, 1.3, 7.1, 7.2**
28+
29+
- [ ] 2. Add architecture detection to base.sh
30+
- [ ] 2.1 Add architecture detection and normalization
31+
- Read ARCH from environment or detect via uname
32+
- Create ARCH_K8S, ARCH_SAM, ARCH_GENERIC, ARCH_YQ variables
33+
- _Requirements: 2.1_
34+
- [ ] 2.2 Update kubectl download URL
35+
- Use ARCH_K8S variable in download URL
36+
- _Requirements: 2.2_
37+
- [ ] 2.3 Update SAM CLI download URL
38+
- Use ARCH_SAM variable in download URL
39+
- _Requirements: 2.3_
40+
- [ ] 2.4 Update eks-node-viewer download URL
41+
- Use ARCH_GENERIC variable in download URL
42+
- _Requirements: 2.4_
43+
- [ ] 2.5 Update SOCI snapshotter download URL
44+
- Use ARCH_K8S variable (amd64/arm64) in download URL
45+
- _Requirements: 2.5_
46+
- [ ] 2.6 Update yq download URL
47+
- Use ARCH_YQ variable in download URL
48+
- _Requirements: 2.6_
49+
- [ ] 2.7 Update Java path for ARM64
50+
- Handle different Java paths for aarch64 vs x86_64
51+
- _Requirements: 2.1_
52+
53+
- [ ] 3. Checkpoint - Verify architecture detection works
54+
- Ensure all tests pass, ask the user if questions arise.
55+
56+
- [ ] 4. Create ide-settings.sh with common IDE configuration
57+
- [ ] 4.1 Create ide-settings.sh file
58+
- Define EXTENSIONS variable with full list
59+
- Define DEFAULT_WORKSPACE variable
60+
- _Requirements: 4.1-4.6_
61+
- [ ] 4.2 Add install_ide_extensions function
62+
- Accept binary command and user as parameters
63+
- Loop through extensions with retry logic
64+
- _Requirements: 4.7, 8.1, 8.2, 8.3_
65+
- [ ] 4.3 Add configure_default_workspace function
66+
- Accept coder.json path and user as parameters
67+
- Create workspace config if not exists
68+
- _Requirements: 4.1_
69+
70+
- [ ] 5. Create code-editor.sh for AWS Code Editor
71+
- [ ] 5.1 Add code-editor installation function
72+
- Download manifest from code-editor.amazonaws.com
73+
- Support ARM64 and x64 architectures
74+
- _Requirements: 3.1_
75+
- [ ] 5.2 Add checksum verification
76+
- Verify SHA256 checksum against manifest
77+
- Fail with clear error on mismatch
78+
- _Requirements: 3.2_
79+
- [ ] 5.3 Add installation to user's .local directory
80+
- Extract to ~/.local/lib/code-editor-VERSION/
81+
- Create symlink in ~/.local/bin/
82+
- _Requirements: 3.3_
83+
- [ ] 5.4 Add systemd service configuration
84+
- Create code-editor@.service unit file
85+
- Configure for port 8889
86+
- Accept server license terms
87+
- _Requirements: 3.4, 3.5_
88+
- [ ] 5.5 Add token authentication setup
89+
- Create ~/.code-editor-server/data/token file
90+
- Write IDE_PASSWORD to token file
91+
- _Requirements: 6.1_
92+
- [ ] 5.6 Add Caddy proxy configuration
93+
- Configure Caddy to proxy port 8889
94+
- Same config as vscode.sh
95+
- _Requirements: 3.6_
96+
- [ ] 5.7 Source ide-settings.sh and call shared functions
97+
- Call install_ide_extensions with code-editor-server
98+
- Call configure_default_workspace
99+
- _Requirements: 4.1-4.7_
100+
101+
- [ ] 6. Update vscode.sh to use shared settings
102+
- [ ] 6.1 Source ide-settings.sh
103+
- Remove inline EXTENSIONS variable
104+
- Source ide-settings.sh at top of file
105+
- _Requirements: 4.1-4.6_
106+
- [ ] 6.2 Use install_ide_extensions function
107+
- Replace inline extension loop with function call
108+
- Pass "code-server" and "ec2-user"
109+
- _Requirements: 4.7_
110+
- [ ] 6.3 Use configure_default_workspace function
111+
- Replace inline coder.json creation with function call
112+
- _Requirements: 4.1_
113+
114+
- [ ] 7. Update bootstrap.sh for IDE selection
115+
- [ ] 7.1 Read IDE_TYPE from environment
116+
- Use IDE_TYPE from UserData (set by CDK)
117+
- Default to "code-editor" if not set
118+
- _Requirements: 3.1_
119+
- [ ] 7.2 Add dynamic code alias to workshop.sh
120+
- Set alias based on IDE_TYPE
121+
- code-editor: /home/ec2-user/.local/bin/code-editor-server
122+
- vscode: code-server
123+
- _Requirements: 3.4_
124+
- [ ] 7.3 Update IDE setup call
125+
- Change from hardcoded vscode.sh to ${IDE_TYPE}.sh
126+
- _Requirements: 3.1_
127+
128+
- [ ] 8. Update shell.sh for both IDEs
129+
- [ ] 8.1 Update .zshrc code alias
130+
- Add dynamic alias that detects installed IDE
131+
- Check for code-editor-server first, then code-server
132+
- _Requirements: 3.4_
133+
- [ ] 8.2 Update settings.json zsh configuration
134+
- Check both code-server and code-editor settings.json paths
135+
- Update whichever exists
136+
- _Requirements: 3.4_
137+
138+
- [ ] 9. Add Kiro CLI installation to base.sh
139+
- [ ] 9.1 Add install_kiro_cli function
140+
- Download and run Kiro CLI installer
141+
- Use retry_optional for resilience
142+
- _Requirements: 5.1_
143+
- [ ] 9.2 Add version verification
144+
- Check kiro-cli --version after install
145+
- Log warning if verification fails
146+
- _Requirements: 5.2, 5.3_
147+
- [ ] 9.3 Call install_kiro_cli in base.sh
148+
- Add to end of base.sh before shell setup
149+
- _Requirements: 5.1_
150+
151+
- [ ] 10. Checkpoint - Test full bootstrap
152+
- Ensure all tests pass, ask the user if questions arise.
153+
154+
- [ ] 11. Update CDK URL output for conditional token-based access
155+
- [ ] 11.1 Modify Ide.java URL output based on IdeType
156+
- For CODE_EDITOR: Include ?folder= and ?tkn= parameters
157+
- Format: https://domain/?folder=/home/ec2-user/environment&tkn=PASSWORD
158+
- For VSCODE: Standard URL without token (password via login page)
159+
- Format: https://domain/
160+
- _Requirements: 6.2, 6.3_
161+
162+
- [ ] 12. Final Checkpoint - Verify complete setup
163+
- Ensure all tests pass, ask the user if questions arise.

0 commit comments

Comments
 (0)