Skip to main content

Infrastructure Commands

In this section, you can find the list of Infrastructure commands.


CommandDescription
stk create infraCreates an Infrastructure.
stk deploy infraDeploys your Infrastructure.
stk destroy infraDestroys the Infrastructure in an environment.
stk list infraLists the Infrastructures registered in your Workspace.
stk register infraRegisters Infrastructure information in a Workspace.
stk rollback infraExecutes the rollback of your Infrastructure.
stk update infraUpdates the information of an Infrastructure.
stk validate infraValidates the structure of an Infrastructure.

stk create infra

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

Additional information

You cannot register or deploy Infrastructures created outside a Workspace.

The -o, --target option lets you 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 folder name for the Infrastructure content will be the same as the name you gave when creating your Infrastructure.

Usage

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

Parameters

OptionsDescriptionExample
INFRA_NAMESets the name of the Infrastructure. If not provided, the name is taken from the repository defined in the --remote parameter.
stk create infra my-infra-name
-s, --stackStack that contains the list of infra Plugins to be applied to your Infrastructure. It must follow the [STUDIO]/[STACK] pattern.
You can also select the Stack interactively in the terminal.
stk create infra my-infra-name --stack my-studio/my-stack
-sr, --starter,
--starter studio-slug/stack-slug/starter-slug
Defines the Starter that will apply the set of Plugins to your Infrastructure. You must provide the Starter name and its origin data, such as Studio and Stack. You can select the Stack interactively in the terminal.
You can select the Stack version by using --starter studio-slug/stack-slug@[number-version]/starter-slug.
You can also provide the path to a Starter file (starter.yaml) to create the Infrastructure with a local Starter.
stk create infra my-infra-name --starter my-studio/my-stack/starter-name
Select the Stack version:
stk create infra my-infra-name --starter my-studio/my-stack@3.0.0/starter-name
Use a local Starter:
stk create infra my-infra-name --starter User/Documents/My-Local-Starters/starter-name.yaml
-r, --remote <git-url>Sets the URL of the remote Git repository used as the project origin. If not provided, a remote repository will not be configured and you must set it manually.
stk create infra my-infra-name --remote https://github.com/my-git-repository-url
-sgi, --skip-git-initUse this option to avoid initializing a Git repository when creating the Infrastructure.
stk create infra my-infra-name --skip-git-init
-d, --descriptionSets a description for your Infrastructure and its purpose.
stk create infra my-infra-name --description "my infra description"
-q, --non-interactiveDoes not prompt the user for input parameters and returns an error if any required parameter is missing.
stk create infra my-infra-name --non-interactive
-sp, --spec [TEXT]Path to the specification file that contains input and connection data for each applied Plugin.
stk create infra my-infra-name --spec /home/user/specs-folder/infra.yaml
-o, --targetDefines a different folder name to create the Infrastructure content. If the folder does not exist, it will be created. If you do not use -o or --target, the folder name will be the same as the Infrastructure name.
stk create infra my-infra-name --stack my-studio/my-stack --target home/user/Shared-Infra/my-infra
-er, --extra-repositories TEXTProvides a list of additional repositories for your Infrastructure. Each repository must be a JSON object in 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"}]"
-wf, --workflow TEXTName of the Workflow used to create the Infrastructure.
stk create infra my-example-infra --workflow studio-name/stack-name/workflow-name
-rs, --report-statusWorkflow only. Reports the execution status as an activity in the current Application or Infrastructure.
stk create infra my-example-infra --workflow studio-name/stack-name/workflow-name --report-status
-i, --inputs-json TEXTWorkflow only. Workflow inputs in JSON format.
stk create infra my-example-infra --workflow studio-name/stack-name/workflow-name --inputs-json "[{"label":"Host","name":"host","type":"text","required":true},{"label":"Port","name":"port","type":"int","required":true}]"
-h, --helpShows the command help and exits.
stk create infra --help

stk deploy infra

The stk deploy infra command deploys your Infrastructure to an Environment in your Workspace.

Before running the command, you must:

  1. Log in to your account with the stk login command.
  2. Have an active Workspace. Access a Workspace with the stk use workspace command.

Usage

stk deploy infra

Parameters

OptionsDescriptionExample
-v, --versionSets the deploy tag version. You must use semantic versioning (for example, 1.0.0).
stk deploy infra --version 1.0.0
-e, --envSets the name of the Environment to use for the application deploy. Check the available Environments in your Workspace with the stk list infra command.
stk deploy infra --env qa
-b, --branchName of the Git branch that will be used in 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
-wf, --workflowSets the deploy Workflow name when using a Workflow to deploy the Infrastructure. The Workflow name must be its qualifier.
stk deploy infra --workflow studio/stack/workflow-name@1.0.0
-rs, --report-statusReports the deploy execution status as an activity on the current Infrastructure, which is available in the StackSpot Portal.
stk deploy infra --workflow studio/stack/workflow-name@1.0.0 --report-status
-q, --non-interactiveEnables non-interactive mode. It will not prompt for missing parameters.
stk deploy infra --workflow studio/stack/workflow-name@1.0.0 --report-status --non-interactive
-bc, --backend-configInput used only with StackSpot Workflows. It defines which Terraform backend should be used, that is, where the deploy state is stored. When the type is S3, only the s3 object is required. When the type is AZURERM, only the azurerm object is required. Use the contracts presented in the deploy guide.
stk deploy infra --workflow studio/stack/workflow-name@1.0.0 --report-status --non-interactive --backend-config '{"type":"S3","s3":{"iac":{"bucket":"","region":""},"tfstate":{"bucket":"","region":""}}}'
-rwc, --resume-workflow-configReceives a JSON string with Azure, GitHub, or GitLab configuration (one at a time). Examples:
{"azure": {"pipeline_name": "...", "org": "...", "project_name": "...","branch": "..."}}
ou
{"github":{"repository_name": "...", "org": "...", "workflow_name": "...", "branch": "..."}}
ou
{"gitlab": {"id": "...", "slug": "..."}}
.
stk deploy infra --workflow studio/stack/workflow-name@1.0.0 --report-status --non-interactive --backend-config '{"type":"S3","s3":{"iac":{"bucket":"","region":""},"tfstate":{"bucket":"","region":""}}}' --resume-workflow-config '{"azure": {"pipeline_name": "...", "org": "...", "project_name": "...","branch": "..."}}'
-h, --helpShows 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, contact our support.

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

Usage

Syntax

stk destroy infra --env <ENV_NAME>

Example

You must access the folder of the Infrastructure you want to destroy and run:

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

Parameters

OptionsDescriptionExample
-e, --envEnvironment where the Infrastructure was deployed. Required.
stk destroy infra --env prod
-w, --watchAutomatically monitors the Infrastructure destruction status.
stk destroy infra --env prod --watch
-q, --non-interactiveDoes not prompt the user for input parameters and returns an error if any required parameter is missing.
stk destroy infra --env prod --non-interactive
-wf, --workflow TEXTName of the Workflow used to destroy the Infrastructure.
stk destroy infra --env prod --workflow studio-name/stack-name/workflow-name
-rs, --report-statusExclusive use with Workflow. Reports the execution status as an activity in the Application or Infrastructure.
stk destroy infra --env prod --workflow studio-name/stack-name/workflow-name --report-status
-h, --helpShows the command help and exits.
stk destroy infra --help

stk list infra

The stk list infra command prints in the terminal a list of all Infrastructures registered in your Workspace.

Before running the command, you must:

  1. Log in to your account with the stk login command.
  2. Have an active Workspace. Access a Workspace with the stk use workspace command.

Usage

stk list infra

Parameters

OptionsDescriptionExample
-h, --helpShows 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. Have an active Workspace. Access a Workspace with the stk use workspace command.

Usage

stk register infra

Parameters

OptionsDescriptionExample
-r, --remoteSets the URL of the remote Git repository used to host your Infrastructure.
stk register infra --remote https://github.com/my-git-repository-url
-bb, --base-branchName of the base branch of your Infrastructure repository.
stk register infra --base-branch my-shared-infra-branch
-er, --extra-repositories TEXTProvides a list of additional repositories for your Infrastructure. Each repository must be a JSON object in 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, --helpShows the command help and exits.
stk register infra --help

stk rollback infra

The stk rollback infra command executes the rollback of your Infrastructure.

Usage

Syntax

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

Example

stk rollback infra --version 2.2.0 --env prod

Parameters

OptionsDescriptionExample
-v, --versionTag version used in the deploy. The value must follow semantic versioning.
stk rollback infra --version 2.2.0 --env prod
-e, --envEnvironment that will be used to execute the rollback. You can check available environments using the stk list env command.
stk rollback infra --version 2.2.0 --env prod
-w, --watchAutomatically monitors the Infrastructure rollback status.
stk rollback infra --version 2.2.0 --env prod --watch
-q, --non-interactiveDoes not prompt the user for input parameters and returns an error if any required parameter is missing.
stk rollback infra --version 2.2.0 --env prod --non-interactive
-wf, --workflow TEXTName of the Workflow for Infrastructure rollback.
stk rollback infra --version 1.2.0 --env prod --workflow studio-name/stack-name/workflow-name
-bc, --backend-configExclusive use with StackSpot Workflows. Sets the Terraform backend used to store the deployment state. For S3, provide only the S3 object; for AZURERM, only the azurerm object. See contracts in the deployment guide.
stk rollback infra --version 1.2.0 --env prod --report-status --non-interactive --backend-config '{{"type":"S3","s3":{"iac":{"bucket":"","region":""},"tfstate":{"bucket":"","region":""}}}}'
-rs, --report-statusExclusive use with Workflow. Reports the execution status as an activity.
stk rollback infra --version 1.2.0 --env prod --report-status
-h, --helpShows the command help and exits.
stk rollback infra --help

stk update infra

The stk update infra command updates the information of an Infrastructure in StackSpot.

You can update the following Infrastructure information:

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

Usage

Syntax

stk update infra [OPTIONS]

Example

stk update infra --name infra-renamed-example
Additional information

The data stored in the Infrastructure metadata will be synchronized with the API.

Parameters

OptionsDescriptionExample
-n, --name TEXTUpdates the Infrastructure name.
stk update infra --name infra-renamed
-d, --description TEXTUpdates the Infrastructure description.
stk update infra --description "my new infra description"
-r, --repo-url TEXTAdds or updates the Infrastructure Git repository URL.
stk update infra --repo-url https://github.com/my-org/my-new-infra-repository
-b, --repo-base-branch TEXTUpdates the base Git branch of the Infrastructure repository.
stk update infra --repo-base-branch "update/infra-branch-name"
-q, --non-interactiveEnables non-interactive mode and does not prompt for missing parameters.
stk update infra --non-interactive
-er, --extra-repositories TEXTProvides a list of additional repositories for your Infrastructure. Each repository must be a JSON object in 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, --helpShows 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 an Infrastructure, run the command inside the Infrastructure folder.

The command will:

  • Validate the structure of your Infrastructure;
  • Remove empty folders;
  • Ignore files and folders that you do not want to keep after 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 prints a message with any inconsistencies and the validation result.

Usage

stk validate infra

Parameters

OptionsDescriptionExample
-v, --verboseLists the details of all items analyzed, validated, and ignored in your Infrastructure.
stk validate infra --verbose
-h, --helpShows the command help and exits.
stk validate infra --help