Skip to main content

Create Infrastructure via STK CLI

In this section, you will find a guide on how to create Infrastructure via STK CLI.


To create Infrastructure on StackSpot, you can use Infrastructure Plugins that generate infrastructure pieces (IaC code). This process is similar to creating an Application, which generates source code from Application Plugins.

Check the steps

Diagram illustrating the process of creating infrastructure on the StackSpot Platform. The steps include accessing the Workspace dashboard, clicking Create Infra, selecting a Stack and its version, adding infrastructure plugins to the creation flow, and finally deploying the infrastructure.Diagram illustrating the process of creating infrastructure on the StackSpot Platform. The steps include accessing the Workspace dashboard, clicking Create Infra, selecting a Stack and its version, adding infrastructure plugins to the creation flow, and finally deploying the infrastructure.

Prerequisites


If you still need to meet any of these requirements, use the links above to complete them before proceeding.

Follow the steps to create your Infrastructure via STK CLI


You will follow the steps below via STK CLI.


Step 1. Open your terminal, select the Workspace you want to use for Infrastructure and execute:

stk use workspace

Choose the Workspace from the list and press Enter.

tip

To see the list of available Workspaces from your terminal, run the command stk list workspace.
The Workspace in use is marked with an asterisk (*).

You can also see the list on the StackSpot Platform, in the 'Workspaces' section.

Step 2. To create an Infrastructure, execute:

stk create infra

Answer the questions in the terminal:

  • Name your Infrastructure: enter the name of your Infrastructure.

    The Infrastructure name has a 60-character limit.

  • Do you want to start a Git repository?: answer '(Y/n) Yes or No' to start a Git repository in the Infrastructure folder. If the answer is '(Y) Yes', then you must enter the URL of the remote repository.

  • Infrastructure description: enter a brief description for your Infrastructure.

  • Select the Studio: select one of the Studios available in your account.

  • Select the Stack: select the desired Stack.

  • Select the version of the Stack: select the version of the Stack you want to use.

  • Select the desired Infrastructure plugins: select the desired Infrastructure plugins from the list displayed in the terminal.

  • Name the usage of the Plugin: the Plugin usage is automatically filled. Then, you must answer the Plugin inputs.

caution

You can apply the same Plugin more than once in your Infrastructure. That is why the question below appears every time:

? Name the usage of the plugin (studio/stack/name-of-plugin)

This is the alias of the Plugin usage and it is pre-filled by STK CLI. For example:

  • The name of the Plugin is bucket-s3.
  • If it is the first time you apply this Plugin, the alias is pre-filled with a name like bucket-s3-1694809616257. This number is a Unix Timestamp.

The alias indicates the purpose of this Plugin application and avoids duplicate names.

The alias is immutable once configured.

Step 3. Answer the remaining questions in your terminal. If any Plugin requires a Connection Interface, provide the usage alias.


Repeat the process for all the Plugins you apply.


Your Infrastructure was created.


danger

You must not manually edit the stk.yaml file of an Application or Infrastructure. You can modify the Plugins in your Application or Infrastructure using the commands below:

  • To modify the version or settings of a Plugin:
stk update plugin
  • To remove a Plugin:
stk remove plugin
  • To add new features to your project:
stk apply plugin

Step 4. Register your Infrastructure in your account. Access its directory:

cd <infrastructure-name>

Then, execute the command below to register:

stk register infra

Answer the questions:

  • Repository URL: inform the repository that will store your infrastructure code.
  • Base branch: inform the branch you will use in the repository.

Your Infrastructure was created and registered.


You can now view your Infrastructure data within your Workspace on the StackSpot Platform. Access the 'Infrastructure' section.

How to Use Account Variables to Configure Plugins in Your Infrastructure

You can choose to use Account Variables created by your Organization to fill in the inputs for Plugins and Actions when creating your Infrastructure.

To do this, type {{ when responding to the input and select the Variable you want to use.

Visit the How to Create Account Variables page to learn more.

caution

The infrastructure deployment is only performed at this stage if your organization has configured the deployment via Runtime Self-Hosted.

Next steps