Skip to content

Commit fa2011c

Browse files
author
Yuriy Bezsonov
committed
WIP
1 parent c238dd3 commit fa2011c

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
104104
))
105105
.build();
106106

107+
// Add CloudFormation signaling permissions
108+
PolicyStatement cfnSignalPermissions = PolicyStatement.Builder.create()
109+
.effect(Effect.ALLOW)
110+
.actions(List.of(
111+
"cloudformation:SignalResource"
112+
))
113+
.resources(List.of("*"))
114+
.build();
115+
116+
workshopRole.addToPolicy(cfnSignalPermissions);
117+
107118
// Load additional IAM policy from file
108119
var policyDocumentJson = loadFile("/iam-policy.json");
109120
if (policyDocumentJson != null) {
@@ -151,7 +162,7 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
151162

152163
// Create CloudFront prefix list lookup Lambda function
153164
var prefixListLookup = new Lambda(this, "PrefixListLookup",
154-
"/lambda/cloudfront-prefix-lookup.py", Aws.STACK_NAME + "-cloudfront-prefix-lookup", Duration.minutes(3), lambdaRole);
165+
"/lambda/cloudfront-prefix-lookup.py", "ide-cloudfront-prefix-lookup", Duration.minutes(3), lambdaRole);
155166
var prefixListFunction = prefixListLookup.getFunction();
156167

157168
// Add EC2 permissions for prefix list lookup
@@ -357,7 +368,7 @@ public Ide(final Construct scope, final String id, final IdeProps props) {
357368

358369
// Create instance launcher Lambda with multi-AZ and multi-instance-type failover
359370
var instanceLauncher = new Lambda(this, "InstanceLauncher",
360-
"/lambda/ec2-launcher.py", Aws.STACK_NAME + "-ec2-launcher", Duration.minutes(5), lambdaRole);
371+
"/lambda/ec2-launcher.py", "ide-ec2-launcher", Duration.minutes(5), lambdaRole);
361372
var instanceLauncherFunction = instanceLauncher.getFunction();
362373

363374
// Create EC2 instance via Custom Resource with intelligent failover

infra/scripts/ide/vscode.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ run_as_user() {
4343
}
4444

4545
echo "Installing code-server..."
46-
codeServer=$(dnf list installed code-server | wc -l)
46+
codeServer=$(dnf list installed code-server 2>/dev/null | wc -l)
4747
if [ "$codeServer" -eq "0" ]; then
4848
# Install as ec2-user with retry logic - pass version as environment variable
4949
retry_critical "sudo -u ec2-user bash -c 'curl -fsSL https://code-server.dev/install.sh | sh -s -- --version $VSCODE_VERSION'"

infra/workshop-template.yaml

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ Resources:
245245
Properties:
246246
PolicyDocument:
247247
Statement:
248+
- Action: cloudformation:SignalResource
249+
Effect: Allow
250+
Resource: "*"
248251
- Action:
249252
- secretsmanager:DescribeSecret
250253
- secretsmanager:GetSecretValue
@@ -456,11 +459,7 @@ Resources:
456459
responseData = {'Error': tb_err}
457460
finally:
458461
cfnresponse.send(event, context, status, responseData, 'CustomResourcePhysicalID')
459-
FunctionName:
460-
Fn::Join:
461-
- ""
462-
- - Ref: AWS::StackName
463-
- -cloudfront-prefix-lookup
462+
FunctionName: ide-cloudfront-prefix-lookup
464463
Handler: index.lambda_handler
465464
Role:
466465
Fn::GetAtt:
@@ -697,11 +696,7 @@ Resources:
697696
responseData = {'Error': tb_err}
698697
699698
cfnresponse.send(event, context, status, responseData, physical_id)
700-
FunctionName:
701-
Fn::Join:
702-
- ""
703-
- - Ref: AWS::StackName
704-
- -ec2-launcher
699+
FunctionName: ide-ec2-launcher
705700
Handler: index.lambda_handler
706701
Role:
707702
Fn::GetAtt:
@@ -719,6 +714,30 @@ Resources:
719714
Fn::GetAtt:
720715
- IdeInstanceLauncherFunction803C5A2A
721716
- Arn
717+
ImageId:
718+
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
719+
SecurityGroupIds:
720+
Fn::Join:
721+
- ""
722+
- - Fn::GetAtt:
723+
- IdeIdeSecurityGroup5C503C8A
724+
- GroupId
725+
- ","
726+
- Fn::GetAtt:
727+
- IdeIdeInternalSecurityGroupD5D3B421
728+
- GroupId
729+
SubnetIds:
730+
Fn::Join:
731+
- ""
732+
- - Ref: VpcWorkshopVpcPublicSubnet1SubnetBCB45C45
733+
- ","
734+
- Ref: VpcWorkshopVpcPublicSubnet2SubnetF8F9426F
735+
VolumeSize: "50"
736+
IamInstanceProfileArn:
737+
Fn::GetAtt:
738+
- IdeIdeInstanceProfile8BD997EA
739+
- Arn
740+
InstanceName: ide
722741
InstanceTypes: m5.xlarge,m6i.xlarge,t3.xlarge
723742
UserData:
724743
Fn::Base64:
@@ -838,30 +857,6 @@ Resources:
838857
/opt/aws/bin/cfn-signal -e 1 --stack "$STACK_NAME" --resource IdeBootstrapWaitCondition --region "$AWS_REGION"
839858
exit 1
840859
fi
841-
ImageId:
842-
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
843-
SecurityGroupIds:
844-
Fn::Join:
845-
- ""
846-
- - Fn::GetAtt:
847-
- IdeIdeSecurityGroup5C503C8A
848-
- GroupId
849-
- ","
850-
- Fn::GetAtt:
851-
- IdeIdeInternalSecurityGroupD5D3B421
852-
- GroupId
853-
SubnetIds:
854-
Fn::Join:
855-
- ""
856-
- - Ref: VpcWorkshopVpcPublicSubnet1SubnetBCB45C45
857-
- ","
858-
- Ref: VpcWorkshopVpcPublicSubnet2SubnetF8F9426F
859-
VolumeSize: "50"
860-
IamInstanceProfileArn:
861-
Fn::GetAtt:
862-
- IdeIdeInstanceProfile8BD997EA
863-
- Arn
864-
InstanceName: ide
865860
UpdateReplacePolicy: Delete
866861
DeletionPolicy: Delete
867862
IdeIdeEipAssociation6C6C215D:
@@ -1334,12 +1329,12 @@ Resources:
13341329
Description: base-setup build complete
13351330
EventPattern:
13361331
detail:
1332+
project-name:
1333+
- Ref: CodeBuildProjectA0FF5539
13371334
build-status:
13381335
- SUCCEEDED
13391336
- FAILED
13401337
- STOPPED
1341-
project-name:
1342-
- Ref: CodeBuildProjectA0FF5539
13431338
detail-type:
13441339
- CodeBuild Build State Change
13451340
source:
@@ -1377,7 +1372,7 @@ Resources:
13771372
- Arn
13781373
ProjectName:
13791374
Ref: CodeBuildProjectA0FF5539
1380-
ContentHash: "1765687186152"
1375+
ContentHash: "1765688217799"
13811376
DependsOn:
13821377
- CodeBuildBuildCompleteRuleAllowEventRuleWorkshopStackCodeBuildReportLambdaFunctionD77C6091DA4A4BD8
13831378
- CodeBuildBuildCompleteRule06AAF17D

0 commit comments

Comments
 (0)