- Initialize: Create a Validio Code project.
- Write: Write or modify your infrastructure as code to describe the desired resources in your environment.
- Plan: Preview the changes to your environment before applying them.
- Apply: When you are satisfied with the program, deploy the changes to your environment.
Initialize
To create a Validio Code project to manage your resources, start by scaffolding a project. A project is the directory housing the Python program responsible for managing your resources. Use theinit command to create a new project. There are no special considerations for the initialized directory. It contains the files main.py and requirements.txt.
In the following example, you create a project in a directory called my-project with a namespace called my-namespace:
Bash
Because it is a Python project, you can introduce any Python tools, models, dependencies, IDE, and so on.
Directory
If you are creating the project from within the desired directory, you can omit the--directory flag in the init command.
Namespace
Always assign a unique namespace to every project that you create. To assign a namespace, add the-n or --namespace flag to the init command. The project’s namespace is recorded in the validio.json file in the project directory. For more information, see Namespaces.
Write
When writing your infrastructure as code, use the definitions provided by the Validio SDK to describe the resource types in your environment. For more information, see Validio SDK. You can use any Python-based tools at your disposal when you write a program. For example, you can reuse models, import external dependencies, and load credentials from your preferred secrets manager. To deploy a resource in your environment, create an instance of the class definition for the resource type you want to declare. For easier maintenance, you can divide your resource declarations and helper functionality across different modules, as you would in any program. To delete individual resource definitions from your program, either remove or comment out the related code.Environment variables passed to the
plan and apply commands are visible to the Validio Code program.main.py file. The file consists of a full program that declares which resources to deploy into an environment:
Python
Plan
Use theplan command to preview the changes you have defined for your environment before you apply them. The preview shows any resources that are created, updated, or deleted. You can iterate between the Write and Plan steps until you are satisfied with the changes.
Invoke plan whenever you want feedback on your work:
Bash
- If you are not running
planfrom your project’s root directory, use the--directoryflag to specify your working directory. - Use the
--diffflag to choose how much of the diff to show:full,changes(the default, which shows only the changed lines), ornone(a summary only).
plan shows that the program adds six resources to the environment:
Bash
Targeting individual resources
Sometimes you only want to see the plan result or apply changes for selected resources, similar to how Terraform’s target flag works. To do this, use the flags named after the resource types, such as--credential, --source, and --validator. Each flag can be specified multiple times to target multiple resources.
Bash
plan and apply.
Apply
Use theapply command to accept and perform the planned changes to your environment. Running apply also performs the Plan step, which gives you a final look at the planned changes.
Bash
plan, followed by a request for confirmation, and finally a confirmation message when apply completes:
Bash