Skip to content

Working with the blueprints CLI

nadeempat edited this page Dec 13, 2023 · 2 revisions

The blueprint CLI provides tooling to manage and work with your custom blueprint.

Image upload tool

The image upload tool provides you with the ability to upload your own image to an S3 bucket in your AWS account and then distribute that image publicly behind CloudFront. The tool takes an image path in the local storage (and optional bucket name) as input, and returns the URL to the image that is publicly available. For more information, see What is Amazon CloudFront? and What is Amazon S3?

  1. Use the following command to install dependencies, including the blueprint CLI:
yarn && yarn build
  1. Use the following command to make sure the latest blueprint CLI version is installed:
yarn upgrade @amazon-codecatalyst/blueprint-util.cli
  1. Log in to the AWS account with the S3 bucket you want to upload your image to. For more information, see Get started with the AWS CLI, Configure the AWS CLI, and Sign in through the AWS Command Line Interface.
  2. Use the following command from the root of your CodeCatalyst repository to navigate to the directory with the blueprint CLI:
cd packages/utils/blueprint-cli
  1. Use the following command to upload your image to an S3 bucket:
yarn blueprint upload-image-public <./path/to/your/image> <optional: optional-bucket-name>

A URL to your image is generated. The URL won’t be available immediately since it requires some time for the CloudFront distribution to be reployed. Check the distribution status to get the latest deployment status. For more information, see Working with distributions.

Snapshot converter

The snapshot converter tool allows you to generate blueprint assessment objects based on existing snapshot configurations of a blueprint and user-defined configurations.

To run the converter, use the following command at the root of the blueprint folder:

yarn blueprint:snapshot-converter

If you ran the converter for the first time, it will first create the following directory: /src/snapshot-assessment-converter/config. Then, it will generate the following three files in the directory:

  • /src/snapshot-assessment-converter/config/minimal.json: The smallest valid blueprint assessment object.
  • /src/snapshot-assessment-converter/config/full.json: A blueprint assessment object that has all the fields filled out.
  • /src/snapshot-assessment-converter/config/user-defined-assessment-configuration.json: A sample user-defined configuration file. The default is identical to minimal.json.

The output blueprint assessment object can be found in the following location: /src/snapshot-assessment-converter/assessments/assessment-objects.json.

As a blueprint author, you can modify the user-defined-assessment-configuration.json file directly to add your own configurations, and then use the snapshot converter command again to update the assessment objects. The output .json file contains a list of assessment object.

Appendix

Minimal blueprint assessment object

{
  "spaceName": "sample-space-name",
  "name": "sample-assessment-name",
  "blueprintName": "sample-blueprint-name",
  "schedule": {
    "scheduleType": "ONCE"
  },
  "timeoutInMinutes": 60,
  "stepConfigurations": {
    "createStep": {
      "assessmentProjectName": "sample-assessment-project-name"
    }
  }
}

Full blueprint assessment object (all fields are filled out)

{
  "spaceName": "sample-space-name",
  "name": "sample-assessment-name",
  "blueprintName": "sample-blueprint-name",
  "blueprintVersion": "sample-blueprint-version",
  "schedule": {
    "scheduleType": "ONCE",
    "cronSchedule": "0 * * * *"
  },
  "timeoutInMinutes": 60,
  "stepConfigurations": {
    "createStep": {
      "assessmentProjectName": "sample-assessment-project-name",
      "blueprintOptionsOverrides": {}
    },
    "workflowsStep": {
      "timeoutInMinutes": 60,
      "verifyWorkflowsExist": [
        {
          "workflowNameRegex": "[(A-Z)(a-z)]",
          "expectedCount": 1
        }
      ],
      "verifyWorkflowRunsSucceed": [
        {
          "workflowNameRegex": "[(A-Z)(a-z)]",
          "expectedCount": 1
        }
      ]
    },
    "cleanupStep": {
      "timeoutInMinutes": 60,
      "cleanupWorkflows": [
        {
          "workflowNameRegex": "[(A-Z)(a-z)]"
        }
      ]
    },
    "devEnvironmentStep": {
      "devEnvironmentConfigurations": [
        {
          "sourceRepositoryRegex": "[(A-Z)(a-z)]",
          "sourceBranchName": "sample-source-branch-name",
          "alias": "sample-alias",
          "instanceType": "dev.standard1.medium",
          "inactivityTimeoutMinutes": 60,
          "ides": [
            {
              "name": "Cloud9",
              "runtime": "public.ecr.aws/q6e8p2q0/cloud9-ide-runtime:latest"
            }
          ],
          "persistentStorage": 16,
          "startDevEnvironmentOnCreate": true,
          "validateDevEnvironment": [
            {
              "validateDevEnvironment": true,
              "validatePostStartEvents": true
            }
          ]
        }
      ]
    }
  }
}