Migrating a compute node group from a custom launch template to instance settings in AWS PCS
Existing compute node groups that use a custom launch template continue to work. You don't
have to migrate them. To manage a compute node group without a custom launch template, switch it
from launch template configuration (CUSTOM) to standard configuration
(MANAGED). In the same update, specify the AMI, security groups, and SSH key pair as
instance settings.
Contents
Prerequisites
-
Check that standard configuration supports the settings that you need. If the compute node group uses an On-Demand Capacity Reservation (ODCR), an interruptible ODCR (I-ODCR), or a Capacity Block, keep the custom launch template. Also keep it if the compute node group needs other settings that only a launch template provides.
-
With standard configuration, compute nodes require Instance Metadata Service Version 2 (IMDSv2). If your AMI, scripts, or applications use IMDSv1, update them to use IMDSv2 before you migrate. For more information, see Use the Instance Metadata Service to access instance metadata in the Amazon EC2 User Guide.
-
When you change the configuration type, AWS PCS replaces the compute nodes in the compute node group after their running jobs finish. For more information, see Updating a compute node group in AWS PCS.
-
If you specify an SSH key pair, the IAM identity that updates the compute node group needs permission for
ec2:DescribeKeyPairs. For more information, see Minimum permissions to use API actions.
Find the settings to move
Get the contents of the custom launch template version that the compute node group uses.
The AWS PCS console and the GetComputeNodeGroup operation don't show values from
the launch template.
In the commands on this page, make these replacements:
-
Replace
regionwith the ID of the AWS Region where your cluster is, such asus-east-1. -
Replace
my-clusterwith the name orclusterIdof your cluster. -
Replace
my-node-groupwith the name orcomputeNodeGroupIdof your compute node group. -
Replace
ami-ExampleID1,sg-ExampleID1,sg-ExampleID2, andmy-key-pairwith the values that you find in the launch template.
To get the launch template settings (AWS CLI)
-
Get the details of the compute node group. Note the values of
amiId,securityGroupIds,sshKeyName, andcustomLaunchTemplatein the output.aws pcs get-compute-node-group --regionregion\ --cluster-identifiermy-cluster\ --compute-node-group-identifiermy-node-group -
Get the contents of the launch template version. Replace
lt-ExampleID1andlaunch-template-versionwith theidandversionvalues incustomLaunchTemplatefrom the previous step.aws ec2 describe-launch-template-versions --regionregion\ --launch-template-idlt-ExampleID1\ --versionslaunch-template-version\ --query 'LaunchTemplateVersions[0].LaunchTemplateData'
Decide how to handle each setting in the launch template data:
-
ImageId,SecurityGroupIds, andKeyName– Use these values for the AMI, security groups, and SSH key pair, unless the compute node group already has instance settings for them. Standard configuration requires an AMI and at least one security group. -
NetworkInterfaces– If the launch template defines one network interface only to set its security groups (Groups), specify those security groups on the compute node group. If it defines more than one network interface, or any Elastic Fabric Adapter (EFA) network interfaces, keep the custom launch template. -
UserData– Move the scripts to node lifecycle actions. For more information, see Node lifecycle actions. -
MetadataOptions– With standard configuration, compute nodes require IMDSv2. If the launch template allows IMDSv1, update your AMI, scripts, and applications to use IMDSv2 before you migrate. For more information, see Prerequisites. -
Other settings, such as
BlockDeviceMappings,Placement, andCapacityReservationSpecification– Standard configuration doesn't support these settings. If you need them, keep the custom launch template.
Migrate a compute node group
Removing the custom launch template from the compute node group doesn't delete the launch template from your AWS account. If no other compute node group uses the launch template, you can delete it. For more information, see Delete a launch template or a launch template version in the Amazon EC2 User Guide.
Migrate a compute node group that you manage with CloudFormation
In your template, add the AmiId, SecurityGroupIds, and
SshKeyName properties to the AWS::PCS::ComputeNodeGroup resource. Set
LaunchTemplateMode to MANAGED, and remove the
CustomLaunchTemplate property. Then update the stack. For more information, see
AWS::PCS::ComputeNodeGroup in the CloudFormation Template Reference.