Skip to content

Commit 5f28b56

Browse files
author
Yuriy Bezsonov
committed
WIP
1 parent 8b004c3 commit 5f28b56

File tree

8 files changed

+107
-85
lines changed

8 files changed

+107
-85
lines changed

.kiro/specs/infra/debugging-notes.md

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Java-on-AWS Deployment Guide
2+
3+
## Generate Templates
4+
```bash
5+
cd infra
6+
TEMPLATE_TYPE=java-on-aws npm run generate
7+
```
8+
9+
## Deploy Stack
10+
```bash
11+
aws cloudformation deploy \
12+
--template-file cfn/java-on-aws-stack.yaml \
13+
--stack-name workshop-stack \
14+
--capabilities CAPABILITY_IAM \
15+
--parameter-overrides \
16+
ParameterKey=ParameterName,ParameterValue=Value
17+
```
18+
19+
## Test & Debug
20+
21+
### Get Stack Outputs
22+
```bash
23+
source .env
24+
aws cloudformation describe-stacks --stack-name workshop-stack --query 'Stacks[0].Outputs'
25+
```
26+
27+
### Check Bootstrap Logs
28+
```bash
29+
source .env
30+
# Find log group (format: ide-bootstrap-YYYYMMDD-HHMMSS)
31+
aws logs describe-log-groups --log-group-name-prefix "ide-bootstrap"
32+
33+
# Get logs
34+
aws logs get-log-events \
35+
--log-group-name "ide-bootstrap-YYYYMMDD-HHMMSS" \
36+
--log-stream-name "i-instanceid" \
37+
--start-from-head --output text
38+
```
39+
40+
### Check EKS Cluster
41+
```bash
42+
source .env
43+
aws eks describe-cluster --name workshop-cluster
44+
kubectl get nodes
45+
kubectl get pods -A
46+
```
47+
48+
### Verify Database
49+
```bash
50+
source .env
51+
aws rds describe-db-clusters --db-cluster-identifier workshop-db-cluster
52+
aws secretsmanager get-secret-value --secret-id workshop-db-secret
53+
```
54+
55+
## Git Workflow
56+
```bash
57+
git add .
58+
git commit -m "Update infrastructure"
59+
git push origin new-ws-infra
60+
```
61+
62+
**Note**: Always `source .env` first for AWS CLI access with proper credentials.

infra/cdk/src/main/java/sample/com/WorkshopStack.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class WorkshopStack extends Stack {
2020
- |
2121
aws --version
2222
echo "Environment Variables:"
23-
echo "STACK_NAME: $STACK_NAME"
2423
echo "TEMPLATE_TYPE: $TEMPLATE_TYPE"
2524
echo "GIT_BRANCH: $GIT_BRANCH"
2625
build:
@@ -61,7 +60,6 @@ public WorkshopStack(final Construct scope, final String id, final StackProps pr
6160
.projectName("workshop-setup")
6261
.vpc(vpc.getVpc())
6362
.environmentVariables(Map.of(
64-
"STACK_NAME", Aws.STACK_NAME,
6563
"TEMPLATE_TYPE", templateType,
6664
"GIT_BRANCH", gitBranch))
6765
.buildSpec(buildSpec)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
255255
String userDataTemplate = loadFile("/userdata.sh");
256256
String userDataContent = userDataTemplate
257257
.replace("${GIT_BRANCH}", gitBranch)
258-
.replace("${STACK_NAME}", Aws.STACK_NAME)
259258
.replace("${AWS_REGION}", Aws.REGION)
260259
.replace("${TEMPLATE_TYPE}", templateType)
261260
.replace("${WAIT_CONDITION_HANDLE_URL}", waitHandle.getRef());

infra/cdk/src/main/resources/userdata.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ set -e
66

77
# Configuration from CDK
88
export GIT_BRANCH="${GIT_BRANCH}"
9-
export STACK_NAME="${STACK_NAME}"
109
export AWS_REGION="${AWS_REGION}"
1110
export TEMPLATE_TYPE="${TEMPLATE_TYPE}"
1211
export WAIT_CONDITION_HANDLE_URL="${WAIT_CONDITION_HANDLE_URL}"
@@ -95,7 +94,7 @@ if clone_repository; then
9594

9695
echo "Executing full bootstrap script..."
9796
# Run bootstrap script as root from the cloned directory
98-
if cd /home/ec2-user/java-on-aws && WAIT_CONDITION_HANDLE_URL="${WAIT_CONDITION_HANDLE_URL}" infra/scripts/ide/bootstrap.sh "$GIT_BRANCH" "$STACK_NAME" "$TEMPLATE_TYPE"; then
97+
if cd /home/ec2-user/java-on-aws && WAIT_CONDITION_HANDLE_URL="${WAIT_CONDITION_HANDLE_URL}" infra/scripts/ide/bootstrap.sh "$GIT_BRANCH" "$TEMPLATE_TYPE"; then
9998
echo "Bootstrap completed successfully"
10099
# Bootstrap script already signaled success
101100
else

infra/cfn/base-stack.yaml

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,25 @@ Resources:
714714
Fn::GetAtt:
715715
- IdeInstanceLauncherFunction803C5A2A
716716
- Arn
717-
InstanceTypes: m5.xlarge,m6i.xlarge,t3.xlarge
717+
VolumeSize: "50"
718+
SubnetIds:
719+
Fn::Join:
720+
- ""
721+
- - Ref: VpcWorkshopVpcPublicSubnet1SubnetBCB45C45
722+
- ","
723+
- Ref: VpcWorkshopVpcPublicSubnet2SubnetF8F9426F
724+
SecurityGroupIds:
725+
Fn::Join:
726+
- ""
727+
- - Fn::GetAtt:
728+
- IdeIdeSecurityGroup5C503C8A
729+
- GroupId
730+
- ","
731+
- Fn::GetAtt:
732+
- IdeIdeInternalSecurityGroupD5D3B421
733+
- GroupId
734+
ImageId:
735+
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
718736
UserData:
719737
Fn::Base64:
720738
Fn::Join:
@@ -729,10 +747,6 @@ Resources:
729747

730748
# Configuration from CDK
731749
export GIT_BRANCH="new-ws-infra"
732-
export STACK_NAME="
733-
- Ref: AWS::StackName
734-
- |-
735-
"
736750
export AWS_REGION="
737751
- Ref: AWS::Region
738752
- |-
@@ -833,7 +847,7 @@ Resources:
833847
if cd /home/ec2-user/java-on-aws && WAIT_CONDITION_HANDLE_URL="
834848
- Ref: IdeBootstrapWaitConditionHandleD7141CA8
835849
- |-
836-
" infra/scripts/ide/bootstrap.sh "$GIT_BRANCH" "$STACK_NAME" "$TEMPLATE_TYPE"; then
850+
" infra/scripts/ide/bootstrap.sh "$GIT_BRANCH" "$TEMPLATE_TYPE"; then
837851
echo "Bootstrap completed successfully"
838852
# Bootstrap script already signaled success
839853
else
@@ -852,30 +866,12 @@ Resources:
852866
"
853867
exit 1
854868
fi
855-
ImageId:
856-
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
857-
SecurityGroupIds:
858-
Fn::Join:
859-
- ""
860-
- - Fn::GetAtt:
861-
- IdeIdeSecurityGroup5C503C8A
862-
- GroupId
863-
- ","
864-
- Fn::GetAtt:
865-
- IdeIdeInternalSecurityGroupD5D3B421
866-
- GroupId
867-
SubnetIds:
868-
Fn::Join:
869-
- ""
870-
- - Ref: VpcWorkshopVpcPublicSubnet1SubnetBCB45C45
871-
- ","
872-
- Ref: VpcWorkshopVpcPublicSubnet2SubnetF8F9426F
873-
VolumeSize: "50"
869+
InstanceTypes: m5.xlarge,m6i.xlarge,t3.xlarge
870+
InstanceName: ide
874871
IamInstanceProfileArn:
875872
Fn::GetAtt:
876873
- IdeIdeInstanceProfile8BD997EA
877874
- Arn
878-
InstanceName: ide
879875
UpdateReplacePolicy: Delete
880876
DeletionPolicy: Delete
881877
IdeIdeEipAssociation6C6C215D:
@@ -1251,10 +1247,6 @@ Resources:
12511247
- Name: TEMPLATE_TYPE
12521248
Type: PLAINTEXT
12531249
Value: base
1254-
- Name: STACK_NAME
1255-
Type: PLAINTEXT
1256-
Value:
1257-
Ref: AWS::StackName
12581250
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
12591251
ImagePullCredentialsType: CODEBUILD
12601252
PrivilegedMode: false
@@ -1275,7 +1267,6 @@ Resources:
12751267
- |
12761268
aws --version
12771269
echo "Environment Variables:"
1278-
echo "STACK_NAME: $STACK_NAME"
12791270
echo "TEMPLATE_TYPE: $TEMPLATE_TYPE"
12801271
echo "GIT_BRANCH: $GIT_BRANCH"
12811272
build:
@@ -1498,13 +1489,13 @@ Resources:
14981489
Fn::GetAtt:
14991490
- CodeBuildStartLambdaFunction8349284F
15001491
- Arn
1501-
ContentHash: "1765709885426"
1492+
ProjectName:
1493+
Ref: CodeBuildProjectA0FF5539
15021494
CodeBuildIamRoleArn:
15031495
Fn::GetAtt:
15041496
- CodeBuildCodeBuildRoleBA9C6D5C
15051497
- Arn
1506-
ProjectName:
1507-
Ref: CodeBuildProjectA0FF5539
1498+
ContentHash: "1765710511221"
15081499
DependsOn:
15091500
- CodeBuildBuildCompleteRuleAllowEventRuleWorkshopStackCodeBuildReportLambdaFunctionD77C6091DA4A4BD8
15101501
- CodeBuildBuildCompleteRule06AAF17D

infra/cfn/java-on-aws-stack.yaml

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,18 @@ Resources:
734734
Fn::GetAtt:
735735
- IdeInstanceLauncherFunction803C5A2A
736736
- Arn
737+
ImageId:
738+
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
739+
SecurityGroupIds:
740+
Fn::Join:
741+
- ""
742+
- - Fn::GetAtt:
743+
- IdeIdeSecurityGroup5C503C8A
744+
- GroupId
745+
- ","
746+
- Fn::GetAtt:
747+
- IdeIdeInternalSecurityGroupD5D3B421
748+
- GroupId
737749
SubnetIds:
738750
Fn::Join:
739751
- ""
@@ -761,10 +773,6 @@ Resources:
761773

762774
# Configuration from CDK
763775
export GIT_BRANCH="new-ws-infra"
764-
export STACK_NAME="
765-
- Ref: AWS::StackName
766-
- |-
767-
"
768776
export AWS_REGION="
769777
- Ref: AWS::Region
770778
- |-
@@ -865,7 +873,7 @@ Resources:
865873
if cd /home/ec2-user/java-on-aws && WAIT_CONDITION_HANDLE_URL="
866874
- Ref: IdeBootstrapWaitConditionHandleD7141CA8
867875
- |-
868-
" infra/scripts/ide/bootstrap.sh "$GIT_BRANCH" "$STACK_NAME" "$TEMPLATE_TYPE"; then
876+
" infra/scripts/ide/bootstrap.sh "$GIT_BRANCH" "$TEMPLATE_TYPE"; then
869877
echo "Bootstrap completed successfully"
870878
# Bootstrap script already signaled success
871879
else
@@ -884,18 +892,6 @@ Resources:
884892
"
885893
exit 1
886894
fi
887-
ImageId:
888-
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
889-
SecurityGroupIds:
890-
Fn::Join:
891-
- ""
892-
- - Fn::GetAtt:
893-
- IdeIdeSecurityGroup5C503C8A
894-
- GroupId
895-
- ","
896-
- Fn::GetAtt:
897-
- IdeIdeInternalSecurityGroupD5D3B421
898-
- GroupId
899895
UpdateReplacePolicy: Delete
900896
DeletionPolicy: Delete
901897
IdeIdeEipAssociation6C6C215D:
@@ -1271,10 +1267,6 @@ Resources:
12711267
- Name: GIT_BRANCH
12721268
Type: PLAINTEXT
12731269
Value: new-ws-infra
1274-
- Name: STACK_NAME
1275-
Type: PLAINTEXT
1276-
Value:
1277-
Ref: AWS::StackName
12781270
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
12791271
ImagePullCredentialsType: CODEBUILD
12801272
PrivilegedMode: false
@@ -1295,7 +1287,6 @@ Resources:
12951287
- |
12961288
aws --version
12971289
echo "Environment Variables:"
1298-
echo "STACK_NAME: $STACK_NAME"
12991290
echo "TEMPLATE_TYPE: $TEMPLATE_TYPE"
13001291
echo "GIT_BRANCH: $GIT_BRANCH"
13011292
build:
@@ -1518,13 +1509,13 @@ Resources:
15181509
Fn::GetAtt:
15191510
- CodeBuildStartLambdaFunction8349284F
15201511
- Arn
1521-
ContentHash: "1765709890926"
15221512
CodeBuildIamRoleArn:
15231513
Fn::GetAtt:
15241514
- CodeBuildCodeBuildRoleBA9C6D5C
15251515
- Arn
15261516
ProjectName:
15271517
Ref: CodeBuildProjectA0FF5539
1518+
ContentHash: "1765710516249"
15281519
DependsOn:
15291520
- CodeBuildBuildCompleteRuleAllowEventRuleWorkshopStackCodeBuildReportLambdaFunctionD77C6091DA4A4BD8
15301521
- CodeBuildBuildCompleteRule06AAF17D
@@ -1941,6 +1932,9 @@ Resources:
19411932
Fn::GetAtt:
19421933
- DatabaseDatabaseSetupFunction04FDCEBB
19431934
- Arn
1935+
SqlStatements: |-
1936+
CREATE TABLE IF NOT EXISTS unicorns(id TEXT DEFAULT gen_random_uuid() PRIMARY KEY, name TEXT, age TEXT, size TEXT, type TEXT);
1937+
CREATE EXTENSION IF NOT EXISTS vector;
19441938
SecretName:
19451939
Fn::Join:
19461940
- "-"
@@ -1971,9 +1965,6 @@ Resources:
19711965
- Fn::Split:
19721966
- ":"
19731967
- Ref: DatabaseDatabaseSecret487264A7
1974-
SqlStatements: |-
1975-
CREATE TABLE IF NOT EXISTS unicorns(id TEXT DEFAULT gen_random_uuid() PRIMARY KEY, name TEXT, age TEXT, size TEXT, type TEXT);
1976-
CREATE EXTENSION IF NOT EXISTS vector;
19771968
DependsOn:
19781969
- DatabaseDatabaseClusterDatabaseWriter0EEAA63C
19791970
- DatabaseDatabaseCluster0C7C993F

infra/scripts/ide/bootstrap.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
set -e
33

44
# Full bootstrap script - called by minimal UserData
5-
# Parameters: GIT_BRANCH STACK_NAME TEMPLATE_TYPE
5+
# Parameters: GIT_BRANCH TEMPLATE_TYPE
66

77
# Parse parameters
88
GIT_BRANCH="$1"
9-
STACK_NAME="$2"
10-
TEMPLATE_TYPE="$3"
9+
TEMPLATE_TYPE="$2"
1110

1211
echo "Full bootstrap started at $(date)"
1312
echo "Parameters: GIT_BRANCH=$GIT_BRANCH, TEMPLATE_TYPE=$TEMPLATE_TYPE"

0 commit comments

Comments
 (0)