Skip to content

Commit c71d527

Browse files
author
Yuriy Bezsonov
committed
new infra
1 parent 60aa30e commit c71d527

6 files changed

Lines changed: 131 additions & 134 deletions

File tree

.kiro/specs/infra/design.md

Lines changed: 72 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,45 @@ infra/
2323
│ │ │ ├── Database.java
2424
│ │ │ ├── CodeBuild.java
2525
│ │ │ ├── Lambda.java
26-
│ │ │ └── Roles.java
26+
│ │ │ ├── PerformanceAnalysis.java
27+
│ │ │ └── Unicorn.java # ECR + IAM roles (uses unicorn* naming for workshop compatibility)
2728
│ │ ├── WorkshopStack.java # Main stack
2829
│ │ └── WorkshopApp.java # Main CDK application
2930
│ ├── src/main/resources/
30-
│ │ └── ec2-userdata.sh # Minimal UserData script (embedded in CDK)
31+
│ │ ├── userdata.sh # Minimal UserData script (embedded in CDK)
32+
│ │ └── lambda/ # Lambda function source files
33+
│ │ ├── ec2-launcher.py
34+
│ │ ├── codebuild-start.py
35+
│ │ ├── codebuild-report.py
36+
│ │ ├── password-exporter.py
37+
│ │ ├── database-setup.py
38+
│ │ ├── cloudfront-prefix-lookup.py
39+
│ │ └── thread-dump-lambda.py
3140
│ ├── pom.xml
3241
│ └── cdk.json
33-
├── workshop-template.yaml # Generated unified CloudFormation template
42+
├── cfn/ # Generated CloudFormation templates
43+
│ ├── base-stack.yaml
44+
│ └── java-on-aws-stack.yaml
3445
├── scripts/
35-
│ ├── ide/ # Modular IDE and workshop scripts
36-
│ │ ├── vscode.sh # VS Code installation and configuration
37-
│ │ ├── base.sh # Base development tools
38-
│ │ ├── java-on-aws.sh # Java-on-AWS workshop setup
39-
│ │ ├── java-on-eks.sh # Java-on-EKS workshop setup
40-
│ │ └── java-ai-agents.sh # Java AI Agents workshop setup
41-
│ ├── lib/ # Common utilities (actively used)
42-
│ │ ├── common.sh # Emoji logging, error handling (used by generate.sh, sync.sh)
43-
│ │ └── wait-for-resources.sh # EKS/RDS readiness checking (used by setup scripts)
46+
│ ├── ide/ # IDE setup scripts
47+
│ │ ├── bootstrap.sh # Full bootstrap orchestration
48+
│ │ ├── vscode.sh # VS Code Server installation
49+
│ │ ├── code-editor.sh # AWS Code Editor installation
50+
│ │ ├── tools.sh # Base development tools
51+
│ │ ├── settings.sh # IDE settings configuration
52+
│ │ ├── shell.sh # Shell UX (zsh + oh-my-zsh + p10k)
53+
│ │ └── shell-p10k.zsh # Powerlevel10k configuration
54+
│ ├── templates/ # Workshop-specific post-deploy scripts
55+
│ │ ├── base.sh # Base template (empty placeholder)
56+
│ │ └── java-on-aws.sh # Java-on-AWS workshop setup
57+
│ ├── setup/ # Infrastructure setup scripts
58+
│ │ ├── eks.sh # EKS cluster configuration
59+
│ │ ├── monitoring.sh # Prometheus + Grafana setup
60+
│ │ ├── analysis.sh # Thread dump + profiling analysis
61+
│ │ └── deploy-spring-app.sh # Spring application deployment
62+
│ ├── lib/ # Common utilities
63+
│ │ ├── common.sh # Emoji logging, error handling
64+
│ │ └── wait-for-resources.sh # EKS/RDS readiness checking
4465
│ ├── cfn/ # CloudFormation utilities
4566
│ │ ├── generate.sh
4667
│ │ └── sync.sh
@@ -86,10 +107,12 @@ public class WorkshopStack extends Stack {
86107

87108
**Vpc**: Creates VPC with appropriate subnets and networking configuration
88109
**Ide**: Creates VS Code IDE environment with necessary permissions and security groups
89-
**Eks**: Creates EKS cluster with Auto Mode, v1.34, native add-ons (Secrets Store CSI, Mountpoint S3 CSI, Pod Identity Agent), Access Entries, and IDE security group integration
110+
**Eks**: Creates EKS cluster with Auto Mode, v1.34, native add-ons (Secrets Store CSI, Mountpoint S3 CSI, Pod Identity Agent), Access Entries for IDE instance role, and IDE security group integration
90111
**Database**: Configures RDS Aurora PostgreSQL cluster with universal "workshop-" naming convention
91112
**CodeBuild**: Creates CodeBuild project for AWS service-linked role creation
92-
**Roles**: Creates IAM roles and policies for workshop resources
113+
**Lambda**: Reusable construct for consistent Lambda function creation with inline Python code
114+
**PerformanceAnalysis**: Creates S3 bucket, Lambda functions, and API Gateway for thread dump and profiling analysis
115+
**Unicorn**: Creates ECR repository and IAM roles for workshop applications (uses unicorn* naming for workshop content compatibility)
93116

94117
#### CDK Construct Naming Convention
95118

@@ -164,10 +187,16 @@ The new design uses **external files** for all complex scripts and code, loaded
164187
```
165188
infra/cdk/src/main/resources/
166189
├── lambda/
167-
│ ├── ec2-launcher.py # EC2 instance launching with multi-AZ/instance-type failover
168-
│ ├── codebuild-start.py # CodeBuild project starter for workshop setup
169-
│ └── codebuild-report.py # CodeBuild completion reporter via EventBridge
170-
└── ec2-userdata.sh # Minimal UserData script (2.4KB) with CloudWatch logging
190+
│ ├── ec2-launcher.py # EC2 instance launching with multi-AZ/instance-type failover
191+
│ ├── codebuild-start.py # CodeBuild project starter for workshop setup
192+
│ ├── codebuild-report.py # CodeBuild completion reporter via EventBridge
193+
│ ├── password-exporter.py # Custom Resource for password output
194+
│ ├── database-setup.py # Database schema initialization
195+
│ ├── cloudfront-prefix-lookup.py # CloudFront prefix list lookup
196+
│ └── thread-dump-lambda.py # Thread dump collection and AI analysis
197+
├── userdata.sh # Minimal UserData script with CloudWatch logging
198+
├── iam-policy.json # IAM policy for workshop participants
199+
└── unicorns.sql # Database schema SQL
171200
```
172201

173202
#### Reusable Lambda Construct
@@ -232,40 +261,45 @@ This integration ensures seamless access from the IDE to the EKS cluster without
232261
### Script Organization
233262

234263
#### Minimal UserData Architecture
235-
The new architecture uses minimal UserData (2.4KB) that downloads and executes a full bootstrap script, avoiding AWS UserData size limits:
264+
The new architecture uses minimal UserData that downloads and executes a full bootstrap script, avoiding AWS UserData size limits:
236265

237266
```
238267
infra/cdk/src/main/resources/
239-
└── ec2-userdata.sh # Minimal UserData script (2.4KB)
268+
└── userdata.sh # Minimal UserData script with CloudWatch logging
240269
241270
infra/scripts/ide/
242-
├── bootstrap.sh # Full bootstrap script (3.8KB)
243-
├── vscode.sh # VS Code installation and configuration
244-
├── base.sh # Base development tools (foundational for all workshops)
245-
├── java-on-aws.sh # calls base.sh + EKS/DB setup
246-
├── java-on-eks.sh # calls base.sh + EKS setup
247-
└── java-ai-agents.sh # calls base.sh + AI setup
271+
├── bootstrap.sh # Full bootstrap orchestration
272+
├── vscode.sh # VS Code Server installation and configuration
273+
├── code-editor.sh # AWS Code Editor installation
274+
├── tools.sh # Base development tools (Java, Node.js, kubectl, etc.)
275+
├── settings.sh # IDE settings configuration
276+
├── shell.sh # Shell UX (zsh + oh-my-zsh + powerlevel10k)
277+
└── shell-p10k.zsh # Powerlevel10k configuration
278+
279+
infra/scripts/templates/
280+
├── base.sh # Base template (empty placeholder)
281+
└── java-on-aws.sh # Java-on-AWS workshop post-deploy
248282
```
249283

250284
#### Bootstrap Flow
251285
```
252-
ec2-userdata.sh → bootstrap.sh → vscode.sh → {workshop}.sh
286+
userdata.sh → bootstrap.sh → {IDE_TYPE}.sh → tools.sh → templates/{TEMPLATE_TYPE}.sh
253287
```
254288

255289
Where:
256-
- `ec2-userdata.sh`: Minimal UserData script that downloads and runs bootstrap.sh with fallback URLs
257-
- `bootstrap.sh`: Full system setup, CloudWatch, environment variables, git clone, calls vscode.sh and template script
258-
- `vscode.sh`: Complete VS Code IDE setup (code-server, Caddy, configuration)
259-
- `base.sh`: Base development tools (for base template type)
260-
- `java-on-aws.sh`: Calls base.sh + EKS implementation (cluster setup, add-ons, storage classes)
261-
- Future template scripts will be added to `/ide` folder as needed
290+
- `userdata.sh`: Minimal UserData script that clones repo and runs bootstrap.sh with CloudWatch logging
291+
- `bootstrap.sh`: Full system setup, environment variables, calls IDE setup and template script
292+
- `{IDE_TYPE}.sh`: IDE-specific setup (vscode.sh or code-editor.sh)
293+
- `tools.sh`: Base development tools installation (Java, Node.js, kubectl, Helm, etc.)
294+
- `templates/{TEMPLATE_TYPE}.sh`: Workshop-specific post-deploy (EKS setup, monitoring, analysis)
262295

263296
#### Workshop Orchestration Pattern
264297
Workshop scripts follow a layered approach:
265-
1. **Base Layer**: `base.sh` provides foundational development tools (Java, Node.js, kubectl, Helm, etc.)
266-
2. **Workshop Layer**: Workshop-specific scripts (e.g., `java-on-aws.sh`) call base.sh then add specialized setup
267-
3. **Error Handling**: Each layer implements proper error handling and progress feedback
268-
4. **Verification**: Final verification ensures all tools and services are operational
298+
1. **IDE Layer**: `bootstrap.sh` calls IDE setup (`vscode.sh` or `code-editor.sh`) and `tools.sh`
299+
2. **Tools Layer**: `tools.sh` provides foundational development tools (Java, Node.js, kubectl, Helm, etc.)
300+
3. **Workshop Layer**: Template scripts in `templates/` folder add workshop-specific setup (EKS, monitoring, analysis)
301+
4. **Error Handling**: Each layer implements proper error handling and progress feedback
302+
5. **Verification**: Final verification ensures all tools and services are operational
269303

270304
#### Configuration
271305
- **Template Type**: Configurable via `TEMPLATE_TYPE` environment variable (defaults to `base`)
@@ -503,7 +537,7 @@ public class BuildConfig {
503537
**Validates: Requirements 12.1, 12.2, 12.3, 12.4, 12.5, 12.6**
504538

505539
### Property 19: EKS Access Entry Configuration
506-
*For any* EKS cluster created, it should include Access Entry for WSParticipantRole with cluster admin permissions
540+
*For any* EKS cluster created, it should include Access Entry for IDE instance role with cluster admin permissions
507541
**Validates: Requirements 13.8**
508542

509543
### Property 20: Workshop Script Orchestration

.kiro/specs/infra/requirements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ This document specifies the requirements for creating a new AWS workshop infrast
193193
5. WHEN EKS cluster networking is configured, THE system SHALL place cluster in private subnets with public and private API access for security and flexibility
194194
6. WHEN EKS cluster logging is enabled, THE system SHALL activate all log types (api, audit, authenticator, controllerManager, scheduler) for comprehensive monitoring
195195
7. WHEN EKS cluster permissions are configured, THE system SHALL use Access Entries authentication mode instead of deprecated ConfigMap-based authentication
196-
8. WHEN EKS cluster access is configured, THE system SHALL create Access Entry for WSParticipantRole and IDE instance role with cluster admin permissions for workshop participant access
196+
8. WHEN EKS cluster access is configured, THE system SHALL create Access Entry for IDE instance role with cluster admin permissions for workshop participant access
197197

198198
### Requirement 14
199199

@@ -219,7 +219,7 @@ This document specifies the requirements for creating a new AWS workshop infrast
219219
3. WHEN EKS cluster is configured for secrets management, THE system SHALL install AWS Secrets Store CSI Driver add-on for mounting database secrets as environment variables
220220
4. WHEN EKS cluster is configured for S3 access, THE system SHALL install AWS Mountpoint S3 CSI driver add-on for S3 bucket mounting capabilities
221221
5. WHEN EKS cluster is configured for authentication, THE system SHALL install EKS Pod Identity Agent add-on for modern IAM authentication with AWS services
222-
6. WHEN EKS cluster is configured for workshop access, THE system SHALL grant WSParticipantRole cluster admin permissions via Access Entries for workshop participant access
222+
6. WHEN EKS cluster is configured for workshop access, THE system SHALL grant IDE instance role cluster admin permissions via Access Entries for workshop participant access
223223
7. WHEN EKS cluster setup is complete, THE system SHALL verify all three add-ons (Secrets Store CSI Driver, Mountpoint S3 CSI Driver, Pod Identity Agent) are installed and functional before marking deployment as successful
224224

225225
### Requirement 16

.kiro/specs/infra/tasks.md

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@
4949
## Base IDE Stack (10.x)
5050

5151
- [x] 10.1 Create core CDK constructs
52-
- Create infra/cdk/src/main/java/sample/com/constructs/Roles.java for IAM roles and policies
53-
- Create infra/cdk/src/main/java/sample/com/constructs/Vpc.java for VPC with 2 AZs and 1 NAT gateway
54-
- Create infra/cdk/src/main/java/sample/com/constructs/Ide.java for VS Code IDE environment
55-
- Create infra/cdk/src/main/java/sample/com/constructs/CodeBuild.java for workshop setup automation
52+
- Created infra/cdk/src/main/java/sample/com/constructs/Vpc.java for VPC with 2 AZs and 1 NAT gateway ✅
53+
- Created infra/cdk/src/main/java/sample/com/constructs/Ide.java for VS Code IDE environment ✅
54+
- Created infra/cdk/src/main/java/sample/com/constructs/CodeBuild.java for workshop setup automation ✅
55+
- Created infra/cdk/src/main/java/sample/com/constructs/Lambda.java for reusable Lambda function creation ✅
5656
- _Requirements: 1.1, 5.6_
5757

58-
- [x] 10.2 Migrate and refactor Roles construct
59-
- Copy infrastructure/cdk/src/main/java/com/unicorn/constructs/WorkshopFunction.java patterns for IAM setup
60-
- Update package names from com.unicorn to sample.com
61-
- Consolidate all IAM roles and policies into single Roles construct
62-
- Include Bedrock permissions for AI workshops in the unified roles
58+
- [x] 10.2 Migrate and refactor IAM roles into Unicorn construct
59+
- Replaced standalone Roles.java with Unicorn.java that combines ECR + IAM roles ✅
60+
- IAM roles embedded in Unicorn construct for workshop content compatibility ✅
61+
- Uses unicorn* naming convention for workshop application compatibility ✅
62+
- Include Bedrock permissions for AI workshops in the unified roles
6363
- _Requirements: 5.6_
6464

6565
- [x] 10.3 Migrate and refactor Vpc construct
@@ -397,9 +397,9 @@
397397
- Created infra/cdk/src/main/java/sample/com/constructs/Eks.java using software.amazon.awscdk.services.eks.v2.alpha ✅
398398
- Configured workshop-eks with Auto Mode, version 1.34, system+general-purpose node pools ✅
399399
- Added 3 EKS add-ons: AWS Secrets Store CSI Driver, AWS Mountpoint S3 CSI Driver, EKS Pod Identity Agent ✅
400-
- Created Access Entry for WSParticipantRole AND IDE instance role with cluster admin permissions ✅
400+
- Created Access Entry for IDE instance role with cluster admin permissions ✅
401+
- WSParticipantRole Access Entry removed after testing showed it's not needed ✅
401402
- Used Access Entries authentication mode instead of ConfigMap-based authentication ✅
402-
- Enabled all log types (api, audit, authenticator, controllerManager, scheduler) for comprehensive monitoring ✅
403403
- EKS cluster depends only on VPC for parallel deployment with Database ✅
404404
- _Requirements: 13.1, 13.2, 13.3, 13.4, 13.7, 13.8, 15.3, 15.5, 15.6, 19.1_
405405

@@ -507,21 +507,7 @@
507507
- java-on-aws.sh: "✅ Success: Java-on-AWS workshop template" ✅
508508
- _Requirements: 3.3, 3.7, 6.6_
509509

510-
- [ ]* 100.7 Write property test for EKS Access Entry configuration
511-
- **Property 19: EKS Access Entry Configuration**
512-
- **Validates: Requirements 13.8**
513510

514-
- [ ]* 100.8 Write property test for workshop script orchestration
515-
- **Property 20: Workshop Script Orchestration**
516-
- **Validates: Requirements 17.1, 17.2**
517-
518-
- [ ]* 100.9 Write property test for workshop error handling
519-
- **Property 21: Workshop Error Handling**
520-
- **Validates: Requirements 17.3**
521-
522-
- [ ]* 100.10 Write property test for workshop verification
523-
- **Property 22: Workshop Verification**
524-
- **Validates: Requirements 17.4**
525511

526512
- [x] 100.11 Validate java-on-aws migration
527513
- Generated template with TEMPLATE_TYPE=java-on-aws and verified all EKS resources are present ✅
@@ -563,11 +549,11 @@
563549
- Verified all resources present in generated java-on-aws-stack.yaml ✅
564550
- _Requirements: 1.2, 1.3_
565551

566-
- [ ] 100.16 Create thread-dump-lambda.py implementation
567-
- Create infra/cdk/src/main/resources/lambda/thread-dump-lambda.py
568-
- Implement EKS pod discovery and thread dump collection
569-
- Add Bedrock integration for AI-powered thread analysis
570-
- Store results in S3 bucket with proper prefixes
552+
- [x] 100.16 Create thread-dump-lambda.py implementation
553+
- Created infra/cdk/src/main/resources/lambda/thread-dump-lambda.py
554+
- Implemented EKS pod discovery and thread dump collection
555+
- Added Bedrock integration for AI-powered thread analysis
556+
- Store results in S3 bucket with proper prefixes
571557
- _Requirements: 5.6_
572558

573559
- [x] 100.24 Create Unicorn construct with ECR and Roles
@@ -603,18 +589,3 @@
603589
- Validate template generation and workshop setup scripts
604590
- _Requirements: 5.4, 5.5_
605591

606-
## Validation & Cleanup (1000.x)
607-
608-
- [ ] 1000.1 Comprehensive testing
609-
- Test template generation for all workshop types
610-
- Validate sync scripts copy templates and policies correctly
611-
- Test convention-based script discovery for all workshops
612-
- Verify error handling and timeout behavior in setup scripts
613-
- _Requirements: 3.4, 3.5, 4.5_
614-
615-
- [ ] 1000.2 Documentation and final validation
616-
- Update README with new infra/ usage instructions
617-
- Document migration process and parallel operation approach
618-
- Verify both infrastructure/ and infra/ systems can operate independently
619-
- Create migration checklist for workshop maintainers
620-
- _Requirements: 5.9_

infra/cdk/src/main/java/sample/com/constructs/Eks.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,8 @@ private void createAccessEntries(EksProps props) {
7373
.build()
7474
);
7575

76-
// WSParticipantRole Access Entry - TEMPORARILY COMMENTED OUT FOR TESTING
77-
// String wsParticipantRoleArn = String.format("arn:aws:iam::%s:role/WSParticipantRole", Aws.ACCOUNT_ID);
78-
// AccessEntry.Builder.create(this, "WSParticipantAccessEntry")
79-
// .cluster(cluster)
80-
// .principal(wsParticipantRoleArn)
81-
// .accessEntryType(AccessEntryType.STANDARD)
82-
// .accessPolicies(List.of(clusterAdminPolicy))
83-
// .build();
84-
8576
// IDE Instance Role Access Entry (if provided)
77+
// This grants the IDE instance role cluster admin permissions for kubectl access
8678
if (props.getIdeInstanceRole() != null) {
8779
AccessEntry.Builder.create(this, "InstanceAccessEntry")
8880
.cluster(cluster)

0 commit comments

Comments
 (0)