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

View the Template and Create Revision​

When viewing a template, you're presented with several tabs:

Fig: View and Create Revision

  • Meta: Overview of template details.
  • Documentation: Detailed guide and references for using the template.
  • No Code: JSON Schema form for inputs without coding.
  • Code: Direct code inputs for the template.
  • Analysis: Reviews the Terraform setup, detailing resources, modules, and outputs.
  • Usage: Shows workflows that include this template for quick reference.

To create a new template revision, click on "Create New Revision" at the top.

note

Templates can be deleted, deprecated, or unpublished depending on your needs.

Configure Access to IAC Templates​

After setting up your IAC template, managing access is crucial for collaboration and governance. Stackguardian provides various options to control how your templates are accessed and utilized.

Share Template​

  • Share Template: Enables you to share your template with other users or teams, fostering collaboration on infrastructure projects.

Subscribe​

  • Subscribe: Subscribing to a template allows you to use it in workflows and receive updates, ensuring ongoing alignment with the latest standards.

Public Access and Publishing​

  • Make Public + Publish: To make a template visibility outside your own organization you need to make the template public (Make Public) and also choose one or multiple revisions by using Publish .

Deprecation​

  • Deprecate: Mark outdated templates to discourage use without deleting them, guiding users towards alternatives.