Skip to main content

IAC Template

Infrastructure as Code (IAC) templates are automated blueprints for provisioning and managing infrastructure through code. They facilitate rapid and reliable environment setup, with version control for easy collaboration and updates.

Create an IAC Template​

To create an IAC template, navigate to Marketplace Home and select 'Create Template' in the top-right corner.

Let's step through crafting a demo template for an AWS EC2 instance.

Template Details​

  • Template type: Preselected as IAC.
  • Template Name: Unique identifier, e.g., aws-ec2-demo.
  • Owner Org: Your organization name.
  • Short Description: Brief description, e.g., "EC2 instance setup template for production environment".

Documentation & Configuration​

  • Documentation: Include any pertinent notes or a URL to comprehensive documentation.
  • Source Config Kind: Select the IAC tool, e.g., Terraform from available options.
  • Source Destination Kind: Choose the repository service, e.g., Github.
  • Repository URL: Enter the URL where the IAC configuration is hosted.
  • Reference: Specify the Git branch or tag, like main or v2.0.1.

Additional Settings​

  • Working Dir: Directory path for the IAC configuration if not at the repo's root.
  • Git Sparse Checkout Config: Git Sparse Checkout Config: Specify paths to include or exclude for the repository checkout, akin to .gitignore. By default we checkout the full repository.
  • Enable git core.autocrlf: Tick if you need to normalize line endings.
  • Private Source: Mark this for private repositories and provide an authentication method.

Template Inputs​

Select between FORM and JSON for input methods. Here's a JSON example for creating a simple EC2 instance:

{
"create": true,
"name": "production-instance",
"instance_type": "t2.micro",
"ami": "ami-0110d1b5b1cdd8780",
"key_name": "production-key",
"vpc_security_group_ids": ["sg-12345678"],
"subnet_id": "subnet-12345678"
}

Fig: Creating an IAC Template

Create and Manage Template Revisions​

All template types in StackGuardian support versioned revisions for controlled deployment and collaboration. You can select, clone, publish, deprecate versions and more. Visit the Manage Template Revision guide.