Amazon ParallelCluster Python library API - Amazon ParallelCluster
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon ParallelCluster Python library API

Starting with Amazon ParallelCluster version 3.5.0, you can access Amazon ParallelCluster with the Amazon ParallelCluster Python library. You can access the Amazon ParallelCluster library in your pcluster environment or from within an Amazon Lambda runtime. Learn how to access the Amazon ParallelCluster API by using the Amazon ParallelCluster Python library. The Amazon ParallelCluster Python library offers the same functionality that the Amazon ParallelCluster API delivers.

The Amazon ParallelCluster Python library operations and parameters mirror those of the API parameters when converted to snake_case with no capital letters.

Amazon 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 Amazon ParallelCluster Python library

  1. Install pcluster CLI version 3.5.0 or later by following the instructions given in Setting up Amazon ParallelCluster.

  2. 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"

Amazon Lambda for the Amazon ParallelCluster Python library

You can deploy a Lambda layer and runtime to access to the Amazon ParallelCluster Python library. We host Amazon 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 Amazon ParallelCluster Python library is added with Amazon 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 Amazon ParallelCluster Python library with Amazon Lambda

Create a Lambda layer
  1. Log in to the Amazon Web Services Management Console and navigate to the Amazon Lambda console.

  2. In the navigation pane, select Layers, then Create layer.

  3. Enter a name for your layer and select Upload a file from Amazon S3.

  4. Enter the URL to the zip file: s3://aws-region-id-aws-parallelcluster/parallelcluster/3.7.0/layers/aws-parallelcluster/lambda-layer.zip.

  5. For Compatible architectures, choose the x86_64 architecture.

  6. For Compatible runtimes, choose the Python 3.9 runtime.

  7. Choose Create.

Use your Lambda layer
  1. In the Lambda console navigation pane, select Functions, then Create function.

  2. Enter a name for your function.

  3. For Runtime, choose the Python 3.9 runtime.

  4. For Architecture, choose the x86_64 architecture.

  5. Choose Create function.

  6. After the function is created, choose Layers and select Add a layer.

  7. Select Custom layers and choose the layer you created in previous steps.

  8. Choose the layer version.

  9. Choose Add.

  10. Your Lambda needs permissions to manage clusters created with Amazon ParallelCluster. Create a Lambda role with the permissions listed in Base Amazon ParallelCluster pcluster user policy.

You can now access Amazon ParallelCluster from the Python library as described in Amazon ParallelCluster Python library API.