Skip to content

Commit 25d7e55

Browse files
committed
chore: update
Signed-off-by: Ghislain Cheng <ghislain.cheng@zama.ai>
1 parent 2e4f089 commit 25d7e55

File tree

1 file changed

+63
-20
lines changed

1 file changed

+63
-20
lines changed

modules/mpc-party/main.tf

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -558,38 +558,81 @@ module "eks_managed_node_group" {
558558
} : {}
559559
)
560560

561+
# --- NodeConfig for AL2023/nodeadm + optional Nitro Enclaves pre-script ---
562+
cloudinit_pre_nodeadm = concat(
563+
[
564+
{
565+
# IMPORTANT: exact content-type string; do not add charset or quotes
566+
content_type = "application/node.eks.aws"
567+
filename = "10-nodeconfig.yaml"
568+
content = <<-YAML
569+
---
570+
apiVersion: node.eks.aws/v1alpha1
571+
kind: NodeConfig
572+
spec:
573+
cluster:
574+
name: ${var.cluster_name}
575+
apiServerEndpoint: ${data.aws_eks_cluster.cluster.endpoint}
576+
certificateAuthority: ${data.aws_eks_cluster.cluster.certificate_authority[0].data}
577+
cidr: ${data.aws_eks_cluster.cluster.kubernetes_network_config[0].service_ipv4_cidr}
578+
YAML
579+
}
580+
],
581+
var.kms_enabled_nitro_enclaves && var.nodegroup_enable_nitro_enclaves ? [
582+
{
583+
content_type = "text/x-shellscript"
584+
filename = "20-nitro-enclaves.sh"
585+
content = <<-EOT
586+
#!/usr/bin/env bash
587+
# Node resources that will be allocated for Nitro Enclaves
588+
readonly CPU_COUNT=${local.node_group_nitro_enclaves_cpu_count}
589+
readonly MEMORY_MIB=${local.node_group_nitro_enclaves_memory_mib}
590+
readonly NE_ALLOCATOR_SPEC_PATH="/etc/nitro_enclaves/allocator.yaml"
591+
592+
dnf install -y aws-nitro-enclaves-cli
593+
594+
sed -i "s/cpu_count:.*/cpu_count: $CPU_COUNT/g" $NE_ALLOCATOR_SPEC_PATH
595+
sed -i "s/memory_mib:.*/memory_mib: $MEMORY_MIB/g" $NE_ALLOCATOR_SPEC_PATH
596+
597+
systemctl enable nitro-enclaves-allocator.service
598+
systemctl restart nitro-enclaves-allocator.service
599+
echo "NE user data script finished."
600+
EOT
601+
}
602+
] : []
603+
)
561604

562605
# This script configures and launches the Nitro enclave allocator. The
563606
# CPU_COUNT and MEMORY_MIB variables indicate the resources available to
564607
# all enclaves running on the node. A rule of thumb for the kms-core is to
565608
# allocate 75% of the underlying instance capacity.
566-
cloudinit_pre_nodeadm = local.node_group_nitro_enclaves_enabled ? [{
567-
content_type = "text/x-shellscript; charset=\"us-ascii\""
568-
content = <<-EOT
569-
#!/usr/bin/env bash
609+
//cloudinit_pre_nodeadm = local.node_group_nitro_enclaves_enabled ? [{
610+
// content_type = "text/x-shellscript; charset=\"us-ascii\""
611+
// content = <<-EOT
612+
// #!/usr/bin/env bash
570613

571-
# Node resources that will be allocated for Nitro Enclaves
572-
readonly CPU_COUNT=${local.node_group_nitro_enclaves_cpu_count}
573-
readonly MEMORY_MIB=${local.node_group_nitro_enclaves_memory_mib}
614+
// # Node resources that will be allocated for Nitro Enclaves
615+
// readonly CPU_COUNT=${local.node_group_nitro_enclaves_cpu_count}
616+
// readonly MEMORY_MIB=${local.node_group_nitro_enclaves_memory_mib}
574617

575-
readonly NE_ALLOCATOR_SPEC_PATH="/etc/nitro_enclaves/allocator.yaml"
618+
// readonly NE_ALLOCATOR_SPEC_PATH="/etc/nitro_enclaves/allocator.yaml"
576619

577-
# This step below is needed to install nitro-enclaves-allocator service.
578-
dnf install aws-nitro-enclaves-cli -y
620+
// # This step below is needed to install nitro-enclaves-allocator service.
621+
// dnf install aws-nitro-enclaves-cli -y
579622

580-
# Update enclave's allocator specification: allocator.yaml
581-
sed -i "s/cpu_count:.*/cpu_count: $CPU_COUNT/g" $NE_ALLOCATOR_SPEC_PATH
582-
sed -i "s/memory_mib:.*/memory_mib: $MEMORY_MIB/g" $NE_ALLOCATOR_SPEC_PATH
623+
// # Update enclave's allocator specification: allocator.yaml
624+
// sed -i "s/cpu_count:.*/cpu_count: $CPU_COUNT/g" $NE_ALLOCATOR_SPEC_PATH
625+
// sed -i "s/memory_mib:.*/memory_mib: $MEMORY_MIB/g" $NE_ALLOCATOR_SPEC_PATH
583626

584-
# Enable the nitro-enclaves-allocator service on boot
585-
systemctl enable nitro-enclaves-allocator.service
627+
// # Enable the nitro-enclaves-allocator service on boot
628+
// systemctl enable nitro-enclaves-allocator.service
586629

587-
# Restart the nitro-enclaves-allocator service to take changes effect.
588-
systemctl restart nitro-enclaves-allocator.service
630+
// # Restart the nitro-enclaves-allocator service to take changes effect.
631+
// systemctl restart nitro-enclaves-allocator.service
589632

590-
echo "NE user data script has finished successfully."
591-
EOT
592-
}] : null
633+
// echo "NE user data script has finished successfully."
634+
// EOT
635+
//}] : null
593636

594637
# Cluster service CIDR for user data
595638
cluster_service_cidr = data.aws_eks_cluster.cluster.kubernetes_network_config[0].service_ipv4_cidr

0 commit comments

Comments
 (0)