Skip to content

Commit 09f2306

Browse files
author
Yuriy Bezsonov
committed
WIP
1 parent 7d1c83f commit 09f2306

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

infra/scripts/ide/bootstrap.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/bin/bash
22
set -e
33

4-
# Ensure we always signal CloudFormation, even on failure
5-
trap 'echo "Bootstrap failed at line $LINENO"; /opt/aws/bin/cfn-signal -e 1 --stack "$STACK_NAME" --resource IdeBootstrapWaitCondition --region "$AWS_REGION" 2>/dev/null || true; exit 1' ERR
6-
74
# Full bootstrap script - called by minimal UserData
85
# Parameters: GIT_BRANCH STACK_NAME TEMPLATE_TYPE
96

@@ -59,7 +56,7 @@ echo "Installing jq (required for secret parsing)..."
5956
sudo dnf install -y jq
6057

6158
echo "Installing AWS CLI..."
62-
retry_critical "curl -LSsf -o /tmp/aws-cli.zip https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip && unzip -q -d /tmp /tmp/aws-cli.zip && /tmp/aws/install --update && rm -rf /tmp/aws*"
59+
retry_critical "curl -LSsf -o /tmp/aws-cli.zip https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip && rm -rf /tmp/aws && unzip -q -d /tmp /tmp/aws-cli.zip && sudo /tmp/aws/install --update && rm -rf /tmp/aws*"
6360

6461
echo "Fetching IDE password from Secrets Manager..."
6562
IDE_PASSWORD=$(aws secretsmanager get-secret-value --secret-id "ide-password" --query SecretString --output text | jq -r .password)
@@ -73,6 +70,10 @@ echo "Setting profile variables..."
7370
# Set some useful variables
7471
export TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
7572
export AWS_REGION=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
73+
74+
# Now that we have AWS_REGION, set up error trap for CloudFormation signaling
75+
trap 'echo "Bootstrap failed at line $LINENO"; /opt/aws/bin/cfn-signal -e 1 --stack "$STACK_NAME" --resource IdeBootstrapWaitCondition --region "$AWS_REGION" 2>/dev/null || true; exit 1' ERR
76+
7677
export EC2_PRIVATE_IP=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/local-ipv4)
7778
export EC2_DOMAIN=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s http://169.254.169.254/latest/meta-data/public-hostname)
7879
export EC2_URL="http://$EC2_DOMAIN"

infra/workshop-template.yaml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ Resources:
719719
Fn::GetAtt:
720720
- IdeInstanceLauncherFunction803C5A2A
721721
- Arn
722+
InstanceTypes: m5.xlarge,m6i.xlarge,t3.xlarge
722723
UserData:
723724
Fn::Base64:
724725
Fn::Join:
@@ -837,19 +838,8 @@ Resources:
837838
/opt/aws/bin/cfn-signal -e 1 --stack "$STACK_NAME" --resource IdeBootstrapWaitCondition --region "$AWS_REGION"
838839
exit 1
839840
fi
840-
InstanceTypes: m5.xlarge,m6i.xlarge,t3.xlarge
841-
InstanceName: ide
842-
IamInstanceProfileArn:
843-
Fn::GetAtt:
844-
- IdeIdeInstanceProfile8BD997EA
845-
- Arn
846-
VolumeSize: "50"
847-
SubnetIds:
848-
Fn::Join:
849-
- ""
850-
- - Ref: VpcWorkshopVpcPublicSubnet1SubnetBCB45C45
851-
- ","
852-
- Ref: VpcWorkshopVpcPublicSubnet2SubnetF8F9426F
841+
ImageId:
842+
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
853843
SecurityGroupIds:
854844
Fn::Join:
855845
- ""
@@ -860,8 +850,18 @@ Resources:
860850
- Fn::GetAtt:
861851
- IdeIdeInternalSecurityGroupD5D3B421
862852
- GroupId
863-
ImageId:
864-
Ref: SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter
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
865865
UpdateReplacePolicy: Delete
866866
DeletionPolicy: Delete
867867
IdeIdeEipAssociation6C6C215D:
@@ -1110,12 +1110,12 @@ Resources:
11101110
Environment:
11111111
ComputeType: BUILD_GENERAL1_MEDIUM
11121112
EnvironmentVariables:
1113-
- Name: TEMPLATE_TYPE
1114-
Type: PLAINTEXT
1115-
Value: base
11161113
- Name: GIT_BRANCH
11171114
Type: PLAINTEXT
11181115
Value: new-ws-infra
1116+
- Name: TEMPLATE_TYPE
1117+
Type: PLAINTEXT
1118+
Value: base
11191119
- Name: STACK_NAME
11201120
Type: PLAINTEXT
11211121
Value:
@@ -1334,12 +1334,12 @@ Resources:
13341334
Description: base-setup build complete
13351335
EventPattern:
13361336
detail:
1337-
project-name:
1338-
- Ref: CodeBuildProjectA0FF5539
13391337
build-status:
13401338
- SUCCEEDED
13411339
- FAILED
13421340
- STOPPED
1341+
project-name:
1342+
- Ref: CodeBuildProjectA0FF5539
13431343
detail-type:
13441344
- CodeBuild Build State Change
13451345
source:
@@ -1371,13 +1371,13 @@ Resources:
13711371
Fn::GetAtt:
13721372
- CodeBuildStartLambdaFunction8349284F
13731373
- Arn
1374-
ContentHash: "1765685570178"
1375-
ProjectName:
1376-
Ref: CodeBuildProjectA0FF5539
1374+
ContentHash: "1765686098739"
13771375
CodeBuildIamRoleArn:
13781376
Fn::GetAtt:
13791377
- CodeBuildCodeBuildRoleBA9C6D5C
13801378
- Arn
1379+
ProjectName:
1380+
Ref: CodeBuildProjectA0FF5539
13811381
DependsOn:
13821382
- CodeBuildBuildCompleteRuleAllowEventRuleWorkshopStackCodeBuildReportLambdaFunctionD77C6091DA4A4BD8
13831383
- CodeBuildBuildCompleteRule06AAF17D

0 commit comments

Comments
 (0)