Version Control Settings
To configure your workflow's source code to be fetched, you have two options under Source and Parameters:
- VCS Provider: Fetch code directly from supported Git providers like GitHub, GitLab, etc.
- Subscribed Templates: Leverage pre-defined templates from the StackGuardian Library for quick and code-free deployment setups.
Learn how to create an IAC template. These templates act as automated blueprints for managing infrastructure as code, offering benefits such as no-code interfaces and lifecycle management capabilities.
Selecting a VCS Provider:β
- Choose a supported "Git provider" using the HTTPS protocol, or select "Git Others (SSH, Secrets, or public Repo)" for other Git providers and SSH access.
For HTTPS Repositories:β
- For private repositories, select the VCS provider from the dropdown. Refer to the VCS Connectors documentation for detailed setup instructions.
For SSH Repositories:β
- Create a secret in the Vault containing your private SSH key and select the appropriate Authentication method. You can use a secret or a connector to authenticate against private repositories (e.g.,
/secrets/your-ssh-key
or/integrations/github_com
). For detailed instructions, see How to create a secret.
Advanced Optionsβ
Stackguardian provides the following options under advanced setups:
Referenceβ
Specify a Git reference such as a branch, tag, or commit to fetch the code at runtime.
Working Directoryβ
Define a specific directory path within the repository to run operations if not located at the root (e.g., infra
, app1/aws/ec2
).
Git Sparse Checkout Configβ
This option allows specifying paths to selectively checkout parts of a repository. Here are some examples:
- To include the entire repository except for the
.terraform
directory and thebackend.tf
file:/**
!.terraform
!backend.tf - To include only the
IaC
directory from the root and exclude theIaC/Documentation
subdirectory:/IaC
!/IaC/Documentation
Exclusion rules should be placed after inclusion rules.
Enable git core.autocrlfβ
When enabled, Git will automatically convert line endings, which helps maintain consistent line endings for files that are checked out across different operating systems, like Windows and Unix.
Template Parametersβ
Choose how to provide inputs variables to a template, enabling parameterized terraform executions.
- Select a "Subscribed Template" to utilise
SG noCode
form to pass input variables to the template parameters,
- Available with source type "Subscribed Template" or "Git Repository", use
JSON-Formatted Input
to provide inputs in key-value format,
Example: Using a Private Repository in Workflowsβ
This guide demonstrates how to configure a workflow to execute Terraform code using the Terraform Workflow Type. Begin by forking the Infrastructure as Code template that deploys an S3 bucket for hosting a static website from this GitHub repository: template-tf-aws-s3-demo-website. Alternatively, you may use your own IaC code sourced from Git.
Next, select Git Repository
and enter the Repository URL
for the forked Terraform code.
To integrate a private GitHub.com repository, you can either use an existing GitHub Integration or set up a new one via VCS Connectors.
Although the template includes default values for Terraform variables, you can override them directly within the StackGuardian Platform under the Template Parameters
section. Provide a JSON-formatted tfvars file to pass customized values during workflow execution. This enables creating highly parameterized IaC templates that adapt based on the values provided directly from the Workflow. An example configuration is shown below:
{
"bucket_region": "eu-central-1",
"s3_bucket_acl": "public-read",
"s3_bucket_force_destroy": true,
"s3_bucket_block_public_acls": false,
"s3_bucket_block_public_policy": false,
"s3_bucket_ignore_public_acls": false,
"s3_bucket_restrict_public_buckets": false,
"s3_bucket_tags": {},
"s3_bucket_versioning": {
"enabled": "true",
"mfa_delete": "false"
}
}
Working with Privately Hosted Version Control Systems When configuring VCS settings for a privately-hosted Git server, you can use Private Runners Groups to access these servers at the network level.
By following these steps, you can easily configure and execute Terraform workflows using both public and private repositories, ensuring secure and seamless infrastructure deployments.