Skip to main content

Use Codebox for automation in BlueXP workload factory

Contributors netapp-rlithman netapp-bcammett

You can use Codebox to generate the code needed to execute any operation supported by BlueXP workload factory. You can generate code that can be consumed and run using workload factory REST APIs, the AWS CLI, and AWS CloudFormation.

Codebox is aligned with the workload factory operation modes (Basic, Read, and Automate) by populating the appropriate data in the code based on the AWS permissions provided in the workload factory account for each user. The code can be used like a template where you can fill in missing information (for example, credentials) or customize certain data before running the code.

How to use Codebox

As you enter values in the workload factory UI wizards, you can see the data update in Codebox as you complete each field. When you complete the wizard, but before you select the Create button at the bottom of the page, select the copy button to copy in Codebox to capture the code required to build your configuration. For example, this screenshot from creating a new Microsoft SQL Server shows the wizard entries for VPC and availability zones and the equivalent entries in Codebox for a REST API implementation.

A screenshot showing how to create a Microsoft SQL Server in the UI and the corresponding entries for VPC and availability zones in Codebox.

With some code formats you can also select the Download button to save the code in a file that you can bring to another system. If required, you can edit the code after it has been downloaded so that you can adapt it to other AWS accounts.

Use CloudFormation code from Codebox

You can copy the CloudFormation code generated from Codebox and then launch the Amazon Web Services CloudFormation stack in your AWS account. CloudFormation will perform the actions that you defined in the workload factory UI.

The steps to use the CLoudFormation code might be different depending on whether you are deploying an FSx for ONTAP file system, creating account credentials, or performing other workload factory actions.

Note that the code within a CloudFormation-generated YAML file expires after 7 days for security reasons.

Before you begin
  • You'll need to have credentials to log in to your AWS account.

  • You'll need to have the following user permissions to use a CloudFormation stack:

    Details
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "cloudformation:CreateStack",
                    "cloudformation:UpdateStack",
                    "cloudformation:DeleteStack",
                    "cloudformation:DescribeStacks",
                    "cloudformation:DescribeStackEvents",
                    "cloudformation:DescribeChangeSet",
                    "cloudformation:ExecuteChangeSet",
                    "cloudformation:ListStacks",
                    "cloudformation:ListStackResources",
                    "cloudformation:GetTemplate",
                    "cloudformation:ValidateTemplate",
                    "lambda:InvokeFunction",
                    "iam:PassRole",
                    "iam:CreateRole",
                    "iam:UpdateAssumeRolePolicy",
                    "iam:AttachRolePolicy",
                    "iam:CreateServiceLinkedRole"
                ],
                "Resource": "*"
            }
        ]
    }
Steps
  1. After you have used the UI to define the operation that you want to perform, copy the code in the Codebox.

  2. Select Redirect to CloudFormation and the Redirect to CloudFormation page is displayed.

  3. Open another browser window and log in to the AWS Management Console.

  4. Select Continue from the Redirect to CloudFormation page.

  5. Log in to the AWS account where the code should be run.

  6. On the Quick create stack page, under Capabilities, select I acknowledge that AWS CloudFormation might …​.

  7. Select Create stack.

  8. Monitor the progress from AWS or from workload factory.

Use REST API code from Codebox

You can use the workload factory REST APIs generated from Codebox to deploy and manage your FSx for ONTAP file systems and other AWS resources.

You can run the APIs from any host that supports curl and that has internet connectivity.

Note that the authentication tokens are hidden in Codebox, but they are populated when you copy and paste the API call.

Steps
  1. After you have used the UI to define the operation that you want to perform, copy the API code in the Codebox.

  2. Paste the code and run it on your host system.

Use AWS CLI code from Codebox

You can use the Amazon Web Services CLI generated from Codebox to deploy and manage your FSx for ONTAP file systems and other AWS resources.

Steps
  1. After you have used the UI to define the operation that you want to perform, copy the AWS CLI in the Codebox.

  2. Open another browser window and log in to the AWS Management Console.

  3. Paste the code and run it.

Use Terraform from Codebox

You can use Terraform to deploy and manage your FSx for ONTAP file systems and other AWS resources.

Before you begin
  • You'll need a system where Terraform is installed (Windows/Mac/Linux).

  • You'll need to have credentials to log in to your AWS account.

Steps
  1. After you have used the user interface to define the operation that you want to perform, download the Terraform code from the Codebox.

  2. Copy the downloaded script archive to the system where Terraform is installed.

  3. Extract the zip file and follow the steps in the README.md file.