Skip to content

Commit f4ba823

Browse files
author
Yuriy Bezsonov
committed
WIP
1 parent d0876c0 commit f4ba823

File tree

6 files changed

+78
-62
lines changed

6 files changed

+78
-62
lines changed
256 KB
Loading

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class CodeBuild extends Construct {
2525
private final Role lambdaRole;
2626

2727
public static class CodeBuildProps {
28-
private String projectName = "workshop-codebuild";
28+
private String projectName = "workshop-setup";
2929
private IBuildImage buildImage = LinuxBuildImage.AMAZON_LINUX_2_5;
3030
private ComputeType computeType = ComputeType.MEDIUM;
3131
private Duration timeout = Duration.minutes(30);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
101101
// Create workshop role for IDE instances if not provided
102102
if (props.getIdeRole() == null) {
103103
props.ideRole = Role.Builder.create(this, "Role")
104-
.roleName("ide-user")
104+
.roleName("workshop-ide-user")
105105
.assumedBy(ServicePrincipal.Builder.create("ec2.amazonaws.com").build())
106106
.managedPolicies(List.of(
107107
ManagedPolicy.fromAwsManagedPolicyName("ReadOnlyAccess"),
@@ -191,7 +191,7 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
191191
this.ideSecurityGroup = SecurityGroup.Builder.create(this, "SecurityGroup")
192192
.vpc(props.getVpc())
193193
.allowAllOutbound(true)
194-
.securityGroupName(instanceName + "-cloudfront-ide-sg")
194+
.securityGroupName("workshop-ide-cloudfront-sg")
195195
.description("IDE security group")
196196
.build();
197197

@@ -205,7 +205,7 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
205205
this.ideInternalSecurityGroup = SecurityGroup.Builder.create(this, "InternalSecurityGroup")
206206
.vpc(props.getVpc())
207207
.allowAllOutbound(false)
208-
.securityGroupName(instanceName + "-internal-sg")
208+
.securityGroupName("workshop-ide-internal-sg")
209209
.description("IDE internal security group")
210210
.build();
211211

@@ -217,7 +217,7 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
217217
// Create instance profile
218218
var instanceProfile = InstanceProfile.Builder.create(this, "InstanceProfile")
219219
.role(this.ideRole)
220-
.instanceProfileName(this.ideRole.getRoleName())
220+
.instanceProfileName("workshop-ide-instance-profile")
221221
.build();
222222

223223
// Create Elastic IP
@@ -246,7 +246,7 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
246246
.secretStringTemplate("{\"password\":\"\"}")
247247
.excludeCharacters("\"@/\\\\")
248248
.build())
249-
.secretName(instanceName + "-password")
249+
.secretName("workshop-ide-password")
250250
.removalPolicy(RemovalPolicy.DESTROY)
251251
.build();
252252

infra/cfn/base-stack.yaml

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Resources:
239239
- Ref: AWS::Partition
240240
- :iam::aws:policy/CloudWatchAgentServerPolicy
241241
- Ref: IdeUserPolicy2460FC7D
242-
RoleName: ide-user
242+
RoleName: workshop-ide-user
243243
IdeRoleDefaultPolicyFD4BDE67:
244244
Type: AWS::IAM::Policy
245245
Properties:
@@ -483,7 +483,7 @@ Resources:
483483
Type: AWS::EC2::SecurityGroup
484484
Properties:
485485
GroupDescription: IDE security group
486-
GroupName: ide-cloudfront-ide-sg
486+
GroupName: workshop-ide-cloudfront-sg
487487
SecurityGroupEgress:
488488
- CidrIp: 0.0.0.0/0
489489
Description: Allow all outbound traffic by default
@@ -509,7 +509,7 @@ Resources:
509509
Type: AWS::EC2::SecurityGroup
510510
Properties:
511511
GroupDescription: IDE internal security group
512-
GroupName: ide-internal-sg
512+
GroupName: workshop-ide-internal-sg
513513
VpcId:
514514
Ref: VpcC3027511
515515
IdeInternalSecurityGroupfromWorkshopStackIdeInternalSecurityGroup2A6A3A7DALLTRAFFIC101F9997:
@@ -541,8 +541,7 @@ Resources:
541541
IdeInstanceProfile61B92038:
542542
Type: AWS::IAM::InstanceProfile
543543
Properties:
544-
InstanceProfileName:
545-
Ref: IdeRole4650E22E
544+
InstanceProfileName: workshop-ide-instance-profile
546545
Roles:
547546
- Ref: IdeRole4650E22E
548547
IdeElasticIP3327A0B5:
@@ -559,7 +558,7 @@ Resources:
559558
IncludeSpace: false
560559
PasswordLength: 32
561560
SecretStringTemplate: '{"password":""}'
562-
Name: ide-password
561+
Name: workshop-ide-password
563562
UpdateReplacePolicy: Delete
564563
DeletionPolicy: Delete
565564
IdeInstanceLauncherFunction803C5A2A:
@@ -714,17 +713,6 @@ Resources:
714713
Fn::GetAtt:
715714
- IdeInstanceLauncherFunction803C5A2A
716715
- Arn
717-
SubnetIds:
718-
Fn::Join:
719-
- ""
720-
- - Ref: VpcPublicSubnet1Subnet8E8DEDC0
721-
- ","
722-
- Ref: VpcPublicSubnet2SubnetA811849C
723-
VolumeSize: "50"
724-
IamInstanceProfileArn:
725-
Fn::GetAtt:
726-
- IdeInstanceProfile61B92038
727-
- Arn
728716
InstanceName: ide
729717
InstanceTypes: m5.xlarge,m6i.xlarge,t3.xlarge
730718
UserData:
@@ -872,6 +860,17 @@ Resources:
872860
- Fn::GetAtt:
873861
- IdeInternalSecurityGroupB0A5D76B
874862
- GroupId
863+
SubnetIds:
864+
Fn::Join:
865+
- ""
866+
- - Ref: VpcPublicSubnet1Subnet8E8DEDC0
867+
- ","
868+
- Ref: VpcPublicSubnet2SubnetA811849C
869+
VolumeSize: "50"
870+
IamInstanceProfileArn:
871+
Fn::GetAtt:
872+
- IdeInstanceProfile61B92038
873+
- Arn
875874
UpdateReplacePolicy: Delete
876875
DeletionPolicy: Delete
877876
IdeEipAssociationDFF81215:
@@ -1081,6 +1080,15 @@ Resources:
10811080
- Fn::Split:
10821081
- ":"
10831082
- Ref: IdePasswordSecretF907B9F2
1083+
- Fn::Select:
1084+
- 2
1085+
- Fn::Split:
1086+
- "-"
1087+
- Fn::Select:
1088+
- 6
1089+
- Fn::Split:
1090+
- ":"
1091+
- Ref: IdePasswordSecretF907B9F2
10841092
UpdateReplacePolicy: Delete
10851093
DeletionPolicy: Delete
10861094
CodeBuildRoleE9A44575:
@@ -1241,12 +1249,12 @@ Resources:
12411249
Environment:
12421250
ComputeType: BUILD_GENERAL1_MEDIUM
12431251
EnvironmentVariables:
1244-
- Name: TEMPLATE_TYPE
1245-
Type: PLAINTEXT
1246-
Value: base
12471252
- Name: GIT_BRANCH
12481253
Type: PLAINTEXT
12491254
Value: new-ws-infra
1255+
- Name: TEMPLATE_TYPE
1256+
Type: PLAINTEXT
1257+
Value: base
12501258
Image: aws/codebuild/amazonlinux2-x86_64-standard:5.0
12511259
ImagePullCredentialsType: CODEBUILD
12521260
PrivilegedMode: false
@@ -1452,12 +1460,12 @@ Resources:
14521460
Description: workshop-setup build complete
14531461
EventPattern:
14541462
detail:
1455-
project-name:
1456-
- Ref: CodeBuildProjectA0FF5539
14571463
build-status:
14581464
- SUCCEEDED
14591465
- FAILED
14601466
- STOPPED
1467+
project-name:
1468+
- Ref: CodeBuildProjectA0FF5539
14611469
detail-type:
14621470
- CodeBuild Build State Change
14631471
source:
@@ -1489,13 +1497,13 @@ Resources:
14891497
Fn::GetAtt:
14901498
- CodeBuildStartLambdaFunction8349284F
14911499
- Arn
1492-
ProjectName:
1493-
Ref: CodeBuildProjectA0FF5539
1494-
ContentHash: "1765725419413"
1500+
ContentHash: "1765726247489"
14951501
CodeBuildIamRoleArn:
14961502
Fn::GetAtt:
14971503
- CodeBuildRoleE9A44575
14981504
- Arn
1505+
ProjectName:
1506+
Ref: CodeBuildProjectA0FF5539
14991507
DependsOn:
15001508
- CodeBuildCompleteRuleAllowEventRuleWorkshopStackCodeBuildReportLambdaFunctionD77C60919E0B0C89
15011509
- CodeBuildCompleteRuleEE9277E8

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

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ Resources:
259259
- Ref: AWS::Partition
260260
- :iam::aws:policy/CloudWatchAgentServerPolicy
261261
- Ref: IdeUserPolicy2460FC7D
262-
RoleName: ide-user
262+
RoleName: workshop-ide-user
263263
IdeRoleDefaultPolicyFD4BDE67:
264264
Type: AWS::IAM::Policy
265265
Properties:
@@ -503,7 +503,7 @@ Resources:
503503
Type: AWS::EC2::SecurityGroup
504504
Properties:
505505
GroupDescription: IDE security group
506-
GroupName: ide-cloudfront-ide-sg
506+
GroupName: workshop-ide-cloudfront-sg
507507
SecurityGroupEgress:
508508
- CidrIp: 0.0.0.0/0
509509
Description: Allow all outbound traffic by default
@@ -529,7 +529,7 @@ Resources:
529529
Type: AWS::EC2::SecurityGroup
530530
Properties:
531531
GroupDescription: IDE internal security group
532-
GroupName: ide-internal-sg
532+
GroupName: workshop-ide-internal-sg
533533
VpcId:
534534
Ref: VpcC3027511
535535
IdeInternalSecurityGroupfromWorkshopStackIdeInternalSecurityGroup2A6A3A7DALLTRAFFIC101F9997:
@@ -561,8 +561,7 @@ Resources:
561561
IdeInstanceProfile61B92038:
562562
Type: AWS::IAM::InstanceProfile
563563
Properties:
564-
InstanceProfileName:
565-
Ref: IdeRole4650E22E
564+
InstanceProfileName: workshop-ide-instance-profile
566565
Roles:
567566
- Ref: IdeRole4650E22E
568567
IdeElasticIP3327A0B5:
@@ -579,7 +578,7 @@ Resources:
579578
IncludeSpace: false
580579
PasswordLength: 32
581580
SecretStringTemplate: '{"password":""}'
582-
Name: ide-password
581+
Name: workshop-ide-password
583582
UpdateReplacePolicy: Delete
584583
DeletionPolicy: Delete
585584
IdeInstanceLauncherFunction803C5A2A:
@@ -734,18 +733,8 @@ Resources:
734733
Fn::GetAtt:
735734
- IdeInstanceLauncherFunction803C5A2A
736735
- Arn
737-
InstanceName: ide
738-
IamInstanceProfileArn:
739-
Fn::GetAtt:
740-
- IdeInstanceProfile61B92038
741-
- Arn
742-
VolumeSize: "50"
743-
SubnetIds:
744-
Fn::Join:
745-
- ""
746-
- - Ref: VpcPublicSubnet1Subnet8E8DEDC0
747-
- ","
748-
- Ref: VpcPublicSubnet2SubnetA811849C
736+
ImageId:
737+
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
749738
SecurityGroupIds:
750739
Fn::Join:
751740
- ""
@@ -756,8 +745,19 @@ Resources:
756745
- Fn::GetAtt:
757746
- IdeInternalSecurityGroupB0A5D76B
758747
- GroupId
759-
ImageId:
760-
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
748+
SubnetIds:
749+
Fn::Join:
750+
- ""
751+
- - Ref: VpcPublicSubnet1Subnet8E8DEDC0
752+
- ","
753+
- Ref: VpcPublicSubnet2SubnetA811849C
754+
VolumeSize: "50"
755+
IamInstanceProfileArn:
756+
Fn::GetAtt:
757+
- IdeInstanceProfile61B92038
758+
- Arn
759+
InstanceName: ide
760+
InstanceTypes: m5.xlarge,m6i.xlarge,t3.xlarge
761761
UserData:
762762
Fn::Base64:
763763
Fn::Join:
@@ -891,7 +891,6 @@ Resources:
891891
"
892892
exit 1
893893
fi
894-
InstanceTypes: m5.xlarge,m6i.xlarge,t3.xlarge
895894
UpdateReplacePolicy: Delete
896895
DeletionPolicy: Delete
897896
IdeEipAssociationDFF81215:
@@ -1101,6 +1100,15 @@ Resources:
11011100
- Fn::Split:
11021101
- ":"
11031102
- Ref: IdePasswordSecretF907B9F2
1103+
- Fn::Select:
1104+
- 2
1105+
- Fn::Split:
1106+
- "-"
1107+
- Fn::Select:
1108+
- 6
1109+
- Fn::Split:
1110+
- ":"
1111+
- Ref: IdePasswordSecretF907B9F2
11041112
UpdateReplacePolicy: Delete
11051113
DeletionPolicy: Delete
11061114
CodeBuildRoleE9A44575:
@@ -1509,13 +1517,13 @@ Resources:
15091517
Fn::GetAtt:
15101518
- CodeBuildStartLambdaFunction8349284F
15111519
- Arn
1512-
ProjectName:
1513-
Ref: CodeBuildProjectA0FF5539
15141520
CodeBuildIamRoleArn:
15151521
Fn::GetAtt:
15161522
- CodeBuildRoleE9A44575
15171523
- Arn
1518-
ContentHash: "1765725424912"
1524+
ProjectName:
1525+
Ref: CodeBuildProjectA0FF5539
1526+
ContentHash: "1765726252761"
15191527
DependsOn:
15201528
- CodeBuildCompleteRuleAllowEventRuleWorkshopStackCodeBuildReportLambdaFunctionD77C60919E0B0C89
15211529
- CodeBuildCompleteRuleEE9277E8
@@ -1930,6 +1938,9 @@ Resources:
19301938
Fn::GetAtt:
19311939
- DatabaseSetupFunction6A2230B7
19321940
- Arn
1941+
SqlStatements: |-
1942+
CREATE TABLE IF NOT EXISTS unicorns(id TEXT DEFAULT gen_random_uuid() PRIMARY KEY, name TEXT, age TEXT, size TEXT, type TEXT);
1943+
CREATE EXTENSION IF NOT EXISTS vector;
19331944
SecretName:
19341945
Fn::Join:
19351946
- "-"
@@ -1960,9 +1971,6 @@ Resources:
19601971
- Fn::Split:
19611972
- ":"
19621973
- Ref: DatabaseSecret3B817195
1963-
SqlStatements: |-
1964-
CREATE TABLE IF NOT EXISTS unicorns(id TEXT DEFAULT gen_random_uuid() PRIMARY KEY, name TEXT, age TEXT, size TEXT, type TEXT);
1965-
CREATE EXTENSION IF NOT EXISTS vector;
19661974
DependsOn:
19671975
- DatabaseClusterDatabaseWriterF4C0B9A6
19681976
- DatabaseCluster5B53A178

infra/scripts/ide/bootstrap.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ echo "$(date '+%Y-%m-%d %H:%M:%S') - Installing CloudFormation helper scripts...
8787
install_with_version "CloudFormation helper scripts" "dnf install -y aws-cfn-bootstrap" "rpm -q aws-cfn-bootstrap --queryformat '%{VERSION}'"
8888

8989
echo "$(date '+%Y-%m-%d %H:%M:%S') - Fetching IDE password from Secrets Manager..."
90-
IDE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id "ide-password" --query SecretString --output text | jq -r .password)
90+
IDE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id "workshop-ide-password" --query SecretString --output text | jq -r .password)
9191
if [ -z "$IDE_PASSWORD" ] || [ "$IDE_PASSWORD" = "null" ]; then
9292
echo "ERROR: Failed to retrieve IDE password from Secrets Manager"
9393
exit 1
@@ -167,9 +167,9 @@ echo "$(date '+%Y-%m-%d %H:%M:%S') - Bootstrap completed successfully"
167167

168168
# Create IDE bootstrap summary for easy reference
169169
echo "Creating IDE bootstrap summary..."
170-
grep "✅ Success:" /var/log/bootstrap.log | sudo -u ec2-user tee /home/ec2-user/ide-bootstrap.log >/dev/null
171-
sudo -u ec2-user chmod 644 /home/ec2-user/ide-bootstrap.log
172-
echo "Bootstrap summary saved to ~/ide-bootstrap.log"
170+
grep "✅ Success:" /var/log/bootstrap.log | sudo -u ec2-user tee /home/ec2-user/workshop-ide-bootstrap.log >/dev/null
171+
sudo -u ec2-user chmod 644 /home/ec2-user/workshop-ide-bootstrap.log
172+
echo "Bootstrap summary saved to ~/workshop-ide-bootstrap.log"
173173

174174
# Signal CloudFormation completion
175175
/opt/aws/bin/cfn-signal -e $? "$WAIT_CONDITION_HANDLE_URL"

0 commit comments

Comments
 (0)