Skip to content

Start/Stop a Cloud Resource

  • Use Case: A recipe requires the computing capacity of an Elastic Compute Cloud (EC2) instance on Amazon Web Services (AWS) infrastructure. The EC2 pricing structure includes an on-demand option, so the ability to start the service only when required could be a cost savings.
  • Example Ingredients: In this example there are two variations declared as ingredients that reside in a separate kitchen. One runs a start procedure, the other runs a stop procedure. These ingredients have the proper AWS credentials configured as the default values for optional inflowing variables. The only required entry for reusing these ingredients across many recipe variations is the EC2 instance ID.

    Tip

    Consolidate Ingredients: This example could have used a single ingredient variation to run both start and stop scripts by requiring "start" or "stop" as an input parameter. This method is a good way to reduce code duplication using a single node in a single variation, then reusing that node as an ingredient across multiple recipes.

  • Example Recipe: In this example, the variation runs nightly tests that require EC2 cloud services.

  • Ingredient Node Roles: The first node processed in this variation is an ingredient node which calls the ingredient to start the EC2 instance. The fourth node is an ingredient node which calls the stop EC2 ingredient after the testing, run from a container node, is complete.

()

An ingredient node calls a shared, single-node ingredient that is pre-configured to start an EC2 instance.

Ingredient Configuration

Before your team can call a shared ingredient from multiple variations, the ingredient, itself, must be configured. See Declare Ingredients for more information.

  • Variation declared as an ingredient in the Ingredient Settings tab
  • Required and optional Inflowing Variables set
  • Configurations, connections, and tests for any nodes included in the ingredient

()

A variation declared as an ingredient sets required and optional input fields with default values.

()

This example ingredient is a container node that runs a Python script to start the EC2 instance.

Ingredient Node Configuration

With the start and stop ingredients pre-configured, the example variation can call them using ingredient nodes.

()

Ingredient node configuration starts with a "mapping" to the ingredient.

()

Ingredient node configuration includes setting inflowing values or accepting the ingredient's defaults.

File Contents

The platform records the configurations made in web app forms for the ingredient node in the node's notebook.json file.

{
    "ingredient-name": "start_ec2_instance",
    "ingredient-recipe-name": "Utility_AWS_Ingredients",
    "required-ingredient-variables": {
        "instance_id": "{{instance_id}}",
        "aws_secret_access_key": "{{aws_secret_access_key}}",
        "aws_access_key_id": "{{aws_access_key_id}}",
        "aws_default_region": "{{aws_default_region}}"
    },
    "ingredient-required-orderrun-results": {}
}