AWS ParallelCluster Python library API
Starting with AWS ParallelCluster version 3.5.0, you can access AWS ParallelCluster with the AWS ParallelCluster Python library. You can access the
AWS ParallelCluster library in your pcluster
environment or from within an AWS Lambda runtime. Learn how to access the AWS ParallelCluster
API by using the AWS ParallelCluster Python library. The AWS ParallelCluster Python library offers the same functionality that the AWS ParallelCluster API
delivers.
The AWS ParallelCluster Python library operations and parameters mirror those of the API parameters when converted to snake_case
with no capital
letters.
Topics
AWS ParallelCluster Python library authorization
Specify credentials by using any of the standard ways that are valid for boto3. For more information,
see the boto3 documentation
Install the AWS ParallelCluster Python library
-
Install
pcluster
CLI version 3.5.0 or later by following the instructions given in Setting up AWS ParallelCluster. -
Import the
pcluster
module and start using the library, as shown in the following example:import pcluster.lib as
pc
pc.create_cluster(cluster_name="mycluster"
, cluster_configuration="config.yaml"
AWS Lambda for the AWS ParallelCluster Python library
You can deploy a Lambda layer and runtime to access to the AWS ParallelCluster Python library. We host AWS ParallelCluster zip files that you can use by entering the link to the zip file as described in the following steps. Lambda uses the zip files to prepare the runtime environment to support access to the Python library. The AWS ParallelCluster Python library is added with AWS ParallelCluster version 3.5.0. You can only use the library for versions 3.5.0 and later.
The hosted zip file URL is in the format: s3://
aws-region-id
-aws-parallelcluster/parallelcluster/3.7.0
/layers/aws-parallelcluster/lambda-layer.zip
Get started accessing the AWS ParallelCluster Python library with AWS Lambda
Create a Lambda layer
-
Log in to the AWS Management Console and navigate to the AWS Lambda console.
-
In the navigation pane, select Layers, then Create layer.
-
Enter a name for your layer and select Upload a file from Amazon S3.
-
Enter the URL to the zip file: s3://
aws-region-id
-aws-parallelcluster/parallelcluster/3.7.0
/layers/aws-parallelcluster/lambda-layer.zip. -
For Compatible architectures, choose the x86_64 architecture.
-
For Compatible runtimes, choose the Python 3.9 runtime.
-
Choose Create.
Use your Lambda layer
-
In the Lambda console navigation pane, select Functions, then Create function.
-
Enter a name for your function.
-
For Runtime, choose the Python 3.9 runtime.
-
For Architecture, choose the x86_64 architecture.
-
Choose Create function.
-
After the function is created, choose Layers and select Add a layer.
-
Select Custom layers and choose the layer you created in previous steps.
-
Choose the layer version.
-
Choose Add.
-
Your Lambda needs permissions to manage clusters created with AWS ParallelCluster. Create a Lambda role with the permissions listed in Base AWS ParallelCluster pcluster user policy.
You can now access AWS ParallelCluster from the Python library as described in AWS ParallelCluster Python library API.