Skip to content

Commit 6ff4906

Browse files
committed
Merge branch 'existing-vpc' of https://github.com/aws-samples/sample-e2b-on-aws into existing-vpc
2 parents 0c4571e + 0df641b commit 6ff4906

File tree

4 files changed

+87
-13
lines changed

4 files changed

+87
-13
lines changed

infra-iac/packer/main.pkr.hcl

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,44 @@ source "amazon-ebs" "orch" {
2626
owners = ["amazon"] // 或实际拥有此 AMI 的 AWS 账户 ID
2727
most_recent = true
2828
}
29-
29+
3030
ssh_username = "ubuntu"
31-
31+
3232
# Enable nested virtualization
3333
ami_virtualization_type = "hvm"
34-
35-
# Use EBS for the root volume
34+
35+
# Force IMDSv2
36+
metadata_options {
37+
http_endpoint = "enabled"
38+
http_tokens = "required"
39+
http_put_response_hop_limit = 1
40+
}
41+
42+
# Tags for the temporary instance and AMI
43+
tags = {
44+
team = "GenAI"
45+
service = "GenAI"
46+
owner = "GenAI"
47+
cost_center = "GenAI"
48+
component = "GenAI"
49+
}
50+
51+
# Tags for the temporary instance only
52+
run_tags = {
53+
team = "GenAI"
54+
service = "GenAI"
55+
owner = "GenAI"
56+
cost_center = "GenAI"
57+
component = "GenAI"
58+
}
59+
60+
# Use EBS for the root volume with encryption
3661
launch_block_device_mappings {
3762
device_name = "/dev/sda1"
3863
volume_size = 10
3964
volume_type = "gp3"
4065
delete_on_termination = true
66+
encrypted = true
4167
}
4268
}
4369

infra-iac/terraform/main.tf

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ locals {
4343
common_tags = {
4444
Environment = var.environment
4545
Project = "E2B"
46-
Owner = "AWS"
4746
ManagedBy = "Terraform"
4847
}
4948

@@ -416,6 +415,13 @@ resource "aws_launch_template" "server" {
416415
name = aws_iam_instance_profile.ec2_instance_profile.name
417416
}
418417

418+
metadata_options {
419+
http_endpoint = "enabled"
420+
http_tokens = "required"
421+
http_put_response_hop_limit = 1
422+
instance_metadata_tags = "enabled"
423+
}
424+
419425
block_device_mappings {
420426
device_name = "/dev/sda1"
421427

@@ -451,7 +457,12 @@ resource "aws_launch_template" "server" {
451457
local.common_tags,
452458
{
453459
Name = "server-cluster",
454-
ec2-e2b-key = "ec2-e2b-value"
460+
ec2-e2b-key = "ec2-e2b-value",
461+
team = "GENAI",
462+
service = "GENAI",
463+
owner = "GENAI",
464+
cost_center = "GENAI",
465+
component = "GENAI"
455466
}
456467
)
457468
}
@@ -547,7 +558,7 @@ resource "aws_launch_template" "client" {
547558

548559
metadata_options {
549560
http_endpoint = "enabled"
550-
http_tokens = "optional"
561+
http_tokens = "required"
551562
http_put_response_hop_limit = 1
552563
instance_metadata_tags = "enabled"
553564
}
@@ -602,7 +613,12 @@ resource "aws_launch_template" "client" {
602613
local.common_tags,
603614
{
604615
Name = "client-cluster",
605-
ec2-e2b-key = "ec2-e2b-value"
616+
ec2-e2b-key = "ec2-e2b-value",
617+
team = "GENAI",
618+
service = "GENAI",
619+
owner = "GENAI",
620+
cost_center = "GENAI",
621+
component = "GENAI"
606622
}
607623
)
608624
}
@@ -982,6 +998,13 @@ resource "aws_launch_template" "api" {
982998
name = aws_iam_instance_profile.ec2_instance_profile.name
983999
}
9841000

1001+
metadata_options {
1002+
http_endpoint = "enabled"
1003+
http_tokens = "required"
1004+
http_put_response_hop_limit = 1
1005+
instance_metadata_tags = "enabled"
1006+
}
1007+
9851008
block_device_mappings {
9861009
device_name = "/dev/sda1"
9871010

@@ -1021,7 +1044,12 @@ resource "aws_launch_template" "api" {
10211044
local.common_tags,
10221045
{
10231046
Name = "api-cluster",
1024-
ec2-e2b-key = "ec2-e2b-value"
1047+
ec2-e2b-key = "ec2-e2b-value",
1048+
team = "GENAI",
1049+
service = "GENAI",
1050+
owner = "GENAI",
1051+
cost_center = "GENAI",
1052+
component = "GENAI"
10251053
}
10261054
)
10271055
}
@@ -1130,6 +1158,13 @@ resource "aws_launch_template" "build" {
11301158
name = aws_iam_instance_profile.ec2_instance_profile.name
11311159
}
11321160

1161+
metadata_options {
1162+
http_endpoint = "enabled"
1163+
http_tokens = "required"
1164+
http_put_response_hop_limit = 1
1165+
instance_metadata_tags = "enabled"
1166+
}
1167+
11331168
block_device_mappings {
11341169
device_name = "/dev/sda1"
11351170

@@ -1169,7 +1204,12 @@ resource "aws_launch_template" "build" {
11691204
local.common_tags,
11701205
{
11711206
Name = "build-cluster",
1172-
ec2-e2b-key = "ec2-e2b-value"
1207+
ec2-e2b-key = "ec2-e2b-value",
1208+
team = "GENAI",
1209+
service = "GENAI",
1210+
owner = "GENAI",
1211+
cost_center = "GENAI",
1212+
component = "GENAI"
11731213
}
11741214
)
11751215
}

packages/create_template.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,19 @@ while true; do
223223

224224
if [ "$STATUS" != "building" ]; then
225225
echo "Build is no longer in 'building' state. Final status: $STATUS"
226-
echo "Done!"
227226
break
228227
fi
229228

230229
sleep 10
231230
done
232231

233-
echo "Building completed successfully!"
232+
# Check final build status
233+
if [ "$STATUS" = "error" ] || [ "$STATUS" = "failed" ]; then
234+
echo "Building failed with status: $STATUS"
235+
exit 1
236+
elif [ "$STATUS" = "ready" ] || [ "$STATUS" = "success" ]; then
237+
echo "Building completed successfully!"
238+
else
239+
echo "Building finished with unknown status: $STATUS"
240+
exit 1
241+
fi

packages/upload.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if [ "$ARCHITECTURE" = "arm64" ]; then
6666
rm -rf release-${latest_version}-aarch64
6767
else
6868
# Download kernel
69-
curl -L https://s3.amazonaws.com/spec.ccfc.min/firecracker-ci/$CI_VERSION/x86_64/vmlinux-$KERNEL_VERSION -o ${TEMP_DIR}/kernels/${KERNEL_FOLDER}/vmlinux.bin
69+
curl -L https://storage.googleapis.com/e2b-prod-public-builds/kernels/vmlinux-6.1.102/vmlinux.bin -o ${TEMP_DIR}/kernels/${KERNEL_FOLDER}/vmlinux.bin
7070
# Download firecracker
7171
curl -L ${fc_url}/download/${FC_VERSION}/firecracker-${FC_VERSION}-x86_64.tgz | tar -xz
7272
mv release-${FC_VERSION}-x86_64/firecracker-${FC_VERSION}-x86_64 \

0 commit comments

Comments
 (0)