Skip to content

Commit 798330d

Browse files
author
Yuriy Bezsonov
committed
Install extentions and exit without error if installation fails
1 parent b92427c commit 798330d

3 files changed

Lines changed: 86 additions & 86 deletions

File tree

infrastructure/cdk/src/main/resources/bootstrapDocument.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ for extension in "${array[@]}"; do
205205
# Use retries but don't exit with error if installation fails
206206
if sudo -u ec2-user bash -c "(r=5; while [ \$r -gt 0 ]; do code-server --install-extension $extension --force && break; r=\$((r-1)); [ \$r -eq 0 ] || sleep 5; done; [ \$r -gt 0 ])"; then
207207
success_list="$success_list $extension"
208-
echo "Successfully installed extension: $extension"
208+
echo "Successfully installed extension: $extension"
209209
else
210210
failed_list="$failed_list $extension"
211-
echo "Failed to install extension: $extension"
211+
echo "Failed to install extension: $extension"
212212
fi
213213
done
214214

infrastructure/cfn/ide-gitea-stack.yaml

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ Resources:
422422
VSCodeIdeGiteaIdeLogGroupCD76FEFA:
423423
Type: AWS::Logs::LogGroup
424424
Properties:
425-
LogGroupName: ide-bootstrap-log-20250603-110425
425+
LogGroupName: ide-bootstrap-log-20250603-110933
426426
RetentionInDays: 7
427427
UpdateReplacePolicy: Retain
428428
DeletionPolicy: Retain
@@ -854,9 +854,9 @@ Resources:
854854
description: Bootstrap IDE
855855
parameters:
856856
BootstrapScript:
857-
default: ""
858-
description: (Optional) Custom bootstrap script to run.
859857
type: String
858+
description: (Optional) Custom bootstrap script to run.
859+
default: ""
860860
mainSteps:
861861
- inputs:
862862
runCommand:
@@ -1069,10 +1069,10 @@ Resources:
10691069
# Use retries but don't exit with error if installation fails
10701070
if sudo -u ec2-user bash -c "(r=5; while [ \$r -gt 0 ]; do code-server --install-extension $extension --force && break; r=\$((r-1)); [ \$r -eq 0 ] || sleep 5; done; [ \$r -gt 0 ])"; then
10711071
success_list="$success_list $extension"
1072-
echo "Successfully installed extension: $extension"
1072+
echo "Successfully installed extension: $extension"
10731073
else
10741074
failed_list="$failed_list $extension"
1075-
echo "Failed to install extension: $extension"
1075+
echo "Failed to install extension: $extension"
10761076
fi
10771077
done
10781078
@@ -1133,15 +1133,51 @@ Resources:
11331133
11341134
exit $exit_code
11351135
- splashUrl: ""
1136-
instanceIamRoleArn:
1137-
Fn::GetAtt:
1138-
- VSCodeIdeGiteaIdeRole90308F47
1139-
- Arn
1140-
readmeUrl: ""
1141-
waitConditionHandleUrl:
1142-
Ref: VSCodeIdeGiteaIdeBootstrapWaitConditionHandle78036ED5
1143-
extensions: ms-azuretools.vscode-docker,ms-kubernetes-tools.vscode-kubernetes-tools,vscjava.vscode-java-pack
1144-
domain: ""
1136+
instanceIamRoleName:
1137+
Ref: VSCodeIdeGiteaIdeRole90308F47
1138+
codeServerVersion: 4.100.2
1139+
customBootstrapScript: |
1140+
date
1141+
1142+
echo '=== Clone Git repository ==='
1143+
sudo -H -u ec2-user bash -c "git clone https://github.com/aws-samples/java-on-aws ~/java-on-aws/"
1144+
# sudo -H -u ec2-user bash -c "cd ~/java-on-aws && git checkout refactoring"
1145+
1146+
echo '=== Setup IDE ==='
1147+
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/ide.sh"
1148+
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/idp.sh"
1149+
passwordName:
1150+
Fn::Join:
1151+
- "-"
1152+
- - Fn::Select:
1153+
- 0
1154+
- Fn::Split:
1155+
- "-"
1156+
- Fn::Select:
1157+
- 6
1158+
- Fn::Split:
1159+
- ":"
1160+
- Ref: VSCodeIdeGiteaIdePasswordSecretD25F73F4
1161+
- Fn::Select:
1162+
- 1
1163+
- Fn::Split:
1164+
- "-"
1165+
- Fn::Select:
1166+
- 6
1167+
- Fn::Split:
1168+
- ":"
1169+
- Ref: VSCodeIdeGiteaIdePasswordSecretD25F73F4
1170+
- Fn::Select:
1171+
- 2
1172+
- Fn::Split:
1173+
- "-"
1174+
- Fn::Select:
1175+
- 6
1176+
- Fn::Split:
1177+
- ":"
1178+
- Ref: VSCodeIdeGiteaIdePasswordSecretD25F73F4
1179+
environmentContentsZip: ""
1180+
terminalOnStartup: "true"
11451181
installGitea: |
11461182
dnf install -y nerdctl cni-plugins
11471183
mkdir -p /gitea/config /gitea/data
@@ -1334,51 +1370,15 @@ Resources:
13341370
EOF
13351371
13361372
source /etc/profile.d/gitea.sh
1337-
terminalOnStartup: "true"
1338-
environmentContentsZip: ""
1339-
passwordName:
1340-
Fn::Join:
1341-
- "-"
1342-
- - Fn::Select:
1343-
- 0
1344-
- Fn::Split:
1345-
- "-"
1346-
- Fn::Select:
1347-
- 6
1348-
- Fn::Split:
1349-
- ":"
1350-
- Ref: VSCodeIdeGiteaIdePasswordSecretD25F73F4
1351-
- Fn::Select:
1352-
- 1
1353-
- Fn::Split:
1354-
- "-"
1355-
- Fn::Select:
1356-
- 6
1357-
- Fn::Split:
1358-
- ":"
1359-
- Ref: VSCodeIdeGiteaIdePasswordSecretD25F73F4
1360-
- Fn::Select:
1361-
- 2
1362-
- Fn::Split:
1363-
- "-"
1364-
- Fn::Select:
1365-
- 6
1366-
- Fn::Split:
1367-
- ":"
1368-
- Ref: VSCodeIdeGiteaIdePasswordSecretD25F73F4
1369-
customBootstrapScript: |
1370-
date
1371-
1372-
echo '=== Clone Git repository ==='
1373-
sudo -H -u ec2-user bash -c "git clone https://github.com/aws-samples/java-on-aws ~/java-on-aws/"
1374-
# sudo -H -u ec2-user bash -c "cd ~/java-on-aws && git checkout refactoring"
1375-
1376-
echo '=== Setup IDE ==='
1377-
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/ide.sh"
1378-
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/idp.sh"
1379-
codeServerVersion: 4.100.2
1380-
instanceIamRoleName:
1381-
Ref: VSCodeIdeGiteaIdeRole90308F47
1373+
domain: ""
1374+
extensions: ms-azuretools.vscode-docker,ms-kubernetes-tools.vscode-kubernetes-tools,vscjava.vscode-java-pack
1375+
waitConditionHandleUrl:
1376+
Ref: VSCodeIdeGiteaIdeBootstrapWaitConditionHandle78036ED5
1377+
readmeUrl: ""
1378+
instanceIamRoleArn:
1379+
Fn::GetAtt:
1380+
- VSCodeIdeGiteaIdeRole90308F47
1381+
- Arn
13821382
name: IdeBootstrapFunction
13831383
action: aws:runShellScript
13841384
DocumentFormat: YAML
@@ -1518,10 +1518,10 @@ Resources:
15181518
- Arn
15191519
SsmDocument:
15201520
Ref: VSCodeIdeGiteaIdeBootstrapDocument7FC8732A
1521-
InstanceId:
1522-
Ref: VSCodeIdeGiteaIdeEC2Instance51274E6D
15231521
LogGroupName:
15241522
Ref: VSCodeIdeGiteaIdeLogGroupCD76FEFA
1523+
InstanceId:
1524+
Ref: VSCodeIdeGiteaIdeEC2Instance51274E6D
15251525
UpdateReplacePolicy: Delete
15261526
DeletionPolicy: Delete
15271527
Outputs:

infrastructure/cfn/ide-stack.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ Resources:
422422
VSCodeIdeGiteaIdeLogGroupCD76FEFA:
423423
Type: AWS::Logs::LogGroup
424424
Properties:
425-
LogGroupName: ide-bootstrap-log-20250603-110451
425+
LogGroupName: ide-bootstrap-log-20250603-110906
426426
RetentionInDays: 7
427427
UpdateReplacePolicy: Retain
428428
DeletionPolicy: Retain
@@ -837,9 +837,9 @@ Resources:
837837
description: Bootstrap IDE
838838
parameters:
839839
BootstrapScript:
840-
type: String
841840
default: ""
842841
description: (Optional) Custom bootstrap script to run.
842+
type: String
843843
mainSteps:
844844
- inputs:
845845
runCommand:
@@ -1052,10 +1052,10 @@ Resources:
10521052
# Use retries but don't exit with error if installation fails
10531053
if sudo -u ec2-user bash -c "(r=5; while [ \$r -gt 0 ]; do code-server --install-extension $extension --force && break; r=\$((r-1)); [ \$r -eq 0 ] || sleep 5; done; [ \$r -gt 0 ])"; then
10541054
success_list="$success_list $extension"
1055-
echo "Successfully installed extension: $extension"
1055+
echo "Successfully installed extension: $extension"
10561056
else
10571057
failed_list="$failed_list $extension"
1058-
echo "Failed to install extension: $extension"
1058+
echo "Failed to install extension: $extension"
10591059
fi
10601060
done
10611061
@@ -1115,7 +1115,23 @@ Resources:
11151115
/opt/aws/bin/cfn-signal -e $exit_code '${waitConditionHandleUrl}'
11161116
11171117
exit $exit_code
1118-
- passwordName:
1118+
- codeServerVersion: 4.100.2
1119+
instanceIamRoleName:
1120+
Ref: VSCodeIdeGiteaIdeRole90308F47
1121+
splashUrl: ""
1122+
instanceIamRoleArn:
1123+
Fn::GetAtt:
1124+
- VSCodeIdeGiteaIdeRole90308F47
1125+
- Arn
1126+
readmeUrl: ""
1127+
waitConditionHandleUrl:
1128+
Ref: VSCodeIdeGiteaIdeBootstrapWaitConditionHandle78036ED5
1129+
extensions: ms-azuretools.vscode-docker,ms-kubernetes-tools.vscode-kubernetes-tools,vscjava.vscode-java-pack
1130+
domain: ""
1131+
installGitea: echo bootstrapGitea was not provided
1132+
terminalOnStartup: "true"
1133+
environmentContentsZip: ""
1134+
passwordName:
11191135
Fn::Join:
11201136
- "-"
11211137
- - Fn::Select:
@@ -1155,22 +1171,6 @@ Resources:
11551171
echo '=== Setup IDE ==='
11561172
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/ide.sh"
11571173
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/idp.sh"
1158-
codeServerVersion: 4.100.2
1159-
instanceIamRoleName:
1160-
Ref: VSCodeIdeGiteaIdeRole90308F47
1161-
splashUrl: ""
1162-
instanceIamRoleArn:
1163-
Fn::GetAtt:
1164-
- VSCodeIdeGiteaIdeRole90308F47
1165-
- Arn
1166-
readmeUrl: ""
1167-
waitConditionHandleUrl:
1168-
Ref: VSCodeIdeGiteaIdeBootstrapWaitConditionHandle78036ED5
1169-
extensions: ms-azuretools.vscode-docker,ms-kubernetes-tools.vscode-kubernetes-tools,vscjava.vscode-java-pack
1170-
domain: ""
1171-
installGitea: echo bootstrapGitea was not provided
1172-
terminalOnStartup: "true"
1173-
environmentContentsZip: ""
11741174
name: IdeBootstrapFunction
11751175
action: aws:runShellScript
11761176
DocumentFormat: YAML
@@ -1308,12 +1308,12 @@ Resources:
13081308
Fn::GetAtt:
13091309
- VSCodeIdeGiteaIdeBootstrapFunction34BA645E
13101310
- Arn
1311-
LogGroupName:
1312-
Ref: VSCodeIdeGiteaIdeLogGroupCD76FEFA
13131311
SsmDocument:
13141312
Ref: VSCodeIdeGiteaIdeBootstrapDocument7FC8732A
13151313
InstanceId:
13161314
Ref: VSCodeIdeGiteaIdeEC2Instance51274E6D
1315+
LogGroupName:
1316+
Ref: VSCodeIdeGiteaIdeLogGroupCD76FEFA
13171317
UpdateReplacePolicy: Delete
13181318
DeletionPolicy: Delete
13191319
Outputs:

0 commit comments

Comments
 (0)