Skip to main content

Infrastructure Commands

In this section, you will learn more about the Infrastructure's commands.


CommandDescription
stk create infraCreates an Infrastructure.
stk deploy infraDeploys an Infrastructure.
stk destroy infraDestroys an Infrastructure.
stk list infraLists the Infrastructures registered to your Workspace.
stk register infraRegisters an Infrastructure to your Workspace.
stk rollback infraPerforms the rollback of an Infrastructure.
stk update infraUpdates the Infrastructure data.
stk validate infraValidates the structure of an Infrastructure.

stk create infra

The stk create infra command creates one or more Infrastructure resources from Plugins of type infra in a Stack.

tip

The -o, --target option allows you to define a different folder name to create the Infrastructure content. If the folder does not exist, it will be created.

If you do not use the -o or --target option, the Infrastructure content folder name will be the same as the one you gave when creating your Infrastructure.

Usage

stk create infra [NAME_INFRA] --stack [STUDIO/STACK]

Parameters

OptionDescriptionExample
NAME_INFRADefines the name of the Infrastructure. If the name is not provided, the name of the repository of the parameter --remote is used.
stk create infra my-infra-name
-s, --stackThe Stack that contains the list of Plugins of type infra to be applied in your Infrastructure. Must follow the pattern: [STUDIO]/[STACK].
You can choose the Stack in the terminal interactively. You can choose the Stack version by informing the -s, --starter flag and the Stack version with --starter studio-slug/stack-slug@<number-version>.
stk create infra my-infra-name --starter my-studio/my-stack/starter-name
Choose the Stack version:
stk create infra my-infra-name --starter my-studio/my-stack@3.0.0
-sr, --starter,
--starter studio-slug/stack-slug/starter-slug
Defines the Starter that will apply the set of Plugins to your Infrastructure. You must enter the name of the Starter and its source data such as Studio and Stack. You can choose the Stack in the terminal interactively.
You can choose the Stack version by informing the -s, --starter flag and the Stack version with --starter studio-slug/stack-slug@[number-version]/starter-slug .
You can enter the file path of a Starter (starter.yaml) to create the Infrastructure with a local Starter.
stk create infra my-infra-name --starter my-studio/my-stack/starter-name
Choose the Stack version:
stk create infra my-infra-name --starter my-studio/my-stack@3.0.0/starter-name
Choose a local Starter:
stk create infra my-infra-name --starter User/Documents/My -Local-Starters/starter-name.yaml
-r, --remote <git-url>Defines the URL of the remote Git repository that is used as the project source. If not provided, the remote repository will not be configured and you must do the process manually.
stk create infra my-infra-name --remote my-git-repository-url
-sgi, --skip-git-initUse this option to not initialize a Git repository during Infrastructure creation.
stk create infra my-infra-name --skip-git-init
-d, --descriptionDefines a description of your Infrastructure and its purpose.
stk create infra my-app-name --description "my infra description"
-q, --non-interactiveIt does not ask the user for input parameters and returns an error if any required parameter is not provided.
stk create infra my-infra-name --non-interactive
-sp, --spec [TEXT]Path to the specification file that contains the inputs and connections data for each applied Plugin.
stk create infra my-infra-name --spec /home/user/specs-folder/infra.yaml
-o, --targetThe -o, --target option allows you to define a different folder name to create the Infrastructure content. If the folder does not exist, it will be created. If you do not use the -o or --target option, the Infrastructure content folder name will be the same as the one you gave when creating your Infrastructure.
stk create infra my-infra-name --stack my-studio/my-stack --target home/user/Shared-Infra/my-infra
-er, --extra-repositories TEXTProvide a list of additional repositories for your Infrastructure. Each repository should be an JSON object with the following structure: "[{"name":"repository_name", "description": "repository_description", "provider": "repository_provider", "url": "repository_url"}]"stk create infra my-example-infra --starter studio/stack/starter-name --extra-repositories "[{"name":"my-example-infra-repo", "description": "repository for test my infra", "provider": "github", "url": "https://github.com/my-organization-name/my-example-infra-repo"}]"
-h, --helpDisplays the command help and exits.
stk create infra --help

stk deploy infra

The stk deploy infra command deploys your infrastructure in an Environment of your Workspace.

To run this command, you must first:

  1. Login to your Account with the stk login command.
  2. If you do not have an active Workspace, access a Workspace with the stk use workspace command.

Usage

stk deploy infra

Parameters

OptionDescriptionExample
-v, --versionDefines the version of the deploy tag. You must use the semantic versioning pattern. Example: "1.0.0"
stk deploy infra --version 1.0.0
-e, --envDefines the name of the Environment that will be used to deploy the application. Consult the Environments available in your Workspace through the stk list infra command.
stk deploy infra --env qa
-b, --branchName of the Git branch that will be used for the deployment. Optional.
stk deploy infra --branch infra-last-release
--open-api-pathPath to the Open API file relative to the root of the Git repository. Optional.
stk deploy infra --open-api-path /home/user/my-infra-folder
-w, --watchMonitors the deployment status automatically.
stk deploy infra --env qa --watch
-h, --helpDisplays the command help and exits.
stk deploy infra --help

stk destroy infra

warning

This feature is temporarily disabled. During this period, if you need to destroy an Infrastructure, please contact our support team.

The stk destroy infra command destroys an Infrastructure in an environment.

Usage

Syntax

stk destroy infra --env<ENV_NAME>

Example

To destroy the Infrastructure in the prod environment, run the following command:

cd my-shared-infra-folder
stk destroy infra --env prod

Parameters

OptionDescriptionExample
-e, --envThe name of the environment where the Infrastructure was deployed. Required
stk destroy infra --env prod
-w, --watchMonitors the infrastructure destruction status automatically.
stk destroy infra --env prod --watch
-q, --non-interactiveDoes not ask the user for input parameters and returns an error if any required parameter is not provided.
stk destroy infra --env prod --non-interactive
-h, --helpDisplays the command help and exits.
stk destroy infra --help

stk list infra

The stk list infra command lists all Infrastructures registered in your Workspace.

Before running the command, you must:

  1. Log in to your Account with the stk login command.
  2. If you do not have an active Workspace, access a Workspace with the stk use workspace command.

Usage

stk list infra

Parameters

OptionDescriptionExample
-h, --helpDisplays the command help and exits.
stk list infra --help

stk register infra

The stk register infra command registers an Infrastructure in your Workspace.

Before running the command, you must:

  1. Log in to your Account with the stk login command.
  2. If you do not have an active Workspace, access a Workspace with the stk use workspace command.

Usage

stk register infra

Parameters

OptionDescriptionExample
-r, --remoteThe URL of the remote Git repository that hosts your Infrastructure.
stk register infra --remote https://github.com/my-git-repository-url
-bb, --base-branchThe base branch name of your Infrastructure repository.
stk register infra --base-branch my-shared-infra-branch
-er, --extra-repositories TEXTProvide a list of additional repositories for your Infrastructure. Each repository should be an JSON object with the following structure: "[{"name":"repository_name", "description": "repository_description", "provider": "repository_provider", "url": "repository_url"}]"stk register infra --remote https://github.com/my-git-repository-url --extra-repositories "[{"name":"my-example-infra-repo", "description": "repository for test my infra", "provider": "github", "url": "https://github.com/my-organization-name/my-example-infra-repo"}]"
-h, --helpDisplays the command help and exits.
stk register infra --help

stk rollback infra

The stk rollback infra command rolls back your Infrastructure to a previous version.

Usage

Syntax

stk rollback infra --version<VERSION> --env<ENV_NAME>

Example

stk rollback infra --version 2.2.0 --env prod

Parameters

OptionDescriptionExample
-v, --versionThe tag version used in the deploy, the pattern must follow semantic versioning.
stk rollback infra --version 2.2.0 --env prod
-e, --envThe environment that will be used to perform the rollback. You can query the available environments using the stk list env command.
stk rollback infra --version 2.2.0 --env prod
-w, --watchMonitors the infrastructure rollback status automatically.
stk rollback infra --version 2.2.0 --env prod --watch
-q, --non-interactiveDoes not ask the user for input parameters and returns an error if any required parameter is not provided.
stk rollback infra --version 2.2.0 --env prod --non-interactive
-h, --helpDisplays the command help and exits.
stk rollback infra --help

stk update infra

The stk update infra command updates the Infrastructure data in StackSpot.

You can update the following Infrastructure data:

  • name;
  • description;
  • repository URL;
  • default branch.

Usage

Syntax

stk update infra [OPTIONS]

Example

stk update infra --name infra-renamed-example
Complementary Information

Data stored in the Infrastructure metadata will be synchronized with the API.

Parameters

OptionDescriptionExample
-n, --name TEXTIt adds the Infrastructure name.
stk update infra --name infra-renamed
-d, --description TEXTIt adds the Infrastructure description.
stk update infra --description "my infra new description"
-r, --repo-url TEXTIt adds the Infrastructure's Git repository URL.
stk update infra --repo-url https://github.com/my-org/my-new-infra-repository
-b, --repo-base-branch TEXTIt adds the Infrastructure Git base branch.
stk update infra --name "update/infra-branch-name"
-q, --non-interactiveActivate the non-interactive mode and do not request any missing parameters.
stk update infra --non-interactive
-er, --extra-repositories TEXTProvide a list of additional repositories for your Infrastructure. Each repository should be an JSON object with the following structure: "[{"name":"repository_name", "description": "repository_description", "provider": "repository_provider", "url": "repository_url"}]"stk update infra --name infra-renamed --extra-repositories "[{"name":"my-example-infra-repo", "description": "repository for test my infra", "provider": "github", "url": "https://github.com/my-organization-name/my-example-infra-repo"}]"
-h, --helpDisplays the command help and exits.
stk update infra --help

stk validate infra

The stk-validate infra command validates the structure of an infrastructure. To validate a backend, run the command inside the backend folder.

The command will:

  • Validate the structure of your infrastructure;
  • Remove empty folders;
  • Ignore files and folders that you don't want when finishing your application development.
info

Files ignored in the .gitignore file will not be validated by the command.

At the end of the command execution, it displays a message with the inconsistencies and the validation result.

Usage

stk validate infra

Parameters

OptionDescriptionExample
-v, --verboseOption to list details of all parsed, validated, and ignored items in your infrastructure.
stk validate infra --verbose
-h, --helpDisplays the command help and exits.
stk validate infra --help