Agile Cloud Institute

Cross-Functional Architecture And Tools For Cloud-Based Operating Models

VM Scale Set in Azure using Terraform and Packer

This is a minimal starting point for developing an appliance in Azure using terraform and packer.

One service creates a virtual machine scale set that uses a custom image. The foundation creates the custom image and provides shared networking resources. This starting point contains elements from which you can build out a more full-featured appliance that includes multiple services.

STEP ONE: Create DevBox

You will need a provisioned devbox in order to orchestrate this appliance using the Agile Cloud Manager. Either Windows or Linux.

For convenience, we have defined a simple process for spinning up a DevBox at this link .

If you already have a working DevBox that you created for one of the other appliance examples, you can reuse that DevBox for this example if you do the following things first:

STEP TWO: Create keys.yaml and config.yaml

Once you have created a DevBox, you can create keys.yaml and config.yaml.

If you have already create keys.yaml for the Azure ARM template appliance example, you can reuse those same keys.yaml and config.yaml files for this terraform/packer appliance example because we made the input files the same for both Azure appliance examples to make it easier for you the user.

The process for configuring Azure requires some manual steps to validate automated steps. We have documented the process at this link

After you have created config.yaml and keys.yaml using the process documented in the link, place copies of config.yaml and keys.yaml in the $USER\acm\keys\starter directory including the exact values that were created by the automation. DO NOT CHANGE THE CONTENTS OF keys.yaml OR config.yaml.

STEP THREE: Confirm that ACM Has Been Installed

After you have confirmed that $USER\acm\keys\starter\keys.yaml and $USER\acm\keys\starter\config.yaml have been properly created and placed, navigate the command line to any empty directory into which you want the Agile Cloud Manager to place resources for the given appliance.

Check the version by running the following command:

$ acm version  
1.3  

Always use the newest version of Agile Cloud Manager because the versions are backward compatible, and because we might change these example appliances over time to only work with newer versions.

STEP FOUR: Run Setup CLI Command

Navigate to any empty directory in which you want to orchestrate the appliance, then download and install all the requirements for the appliance by running the following CLI command:

acm setup on sourceRepo=https://github.com/AgileCloudInstitute/acm-demo-terraform-packer.git    

After the setup command completes running, confirm that your current working directory directory contains an acmAdmin subdirectory and an acmConfig subdirectory in addition to subdirectories for the other repositories that are listed in the appliance’s setupConfig.yaml file. You should now be able to find setupConfig.yaml inside the acmConfig subdirectory now that the acm setup on sourceRepo=https://github.com/AgileCloudInstitute/acm-demo-terraform-packer.git command has completed running.

For example, on a Windows DevBox, you might run the dir command and see:

C:\path\to\mydirectory>dir  
 Volume in drive C is Windows  
 Volume Serial Number is 3E5E-9650  
  
 Directory of C:\p\a\acm_dl  
  
10/25/2023  04:48 PM    <DIR>          .  
10/23/2023  09:09 AM    <DIR>          ..  
10/23/2023  09:35 AM    <DIR>          acm-system-templates  
10/23/2023  09:34 AM    <DIR>          acmAdmin  
10/23/2023  09:34 AM    <DIR>          acmConfig  
10/23/2023  09:35 AM    <DIR>          azure-building-blocks  

The acmAdmin and acmConfig subdirectories will be present for any acm working directory after setup is run. The acm-system-templates and azure-building-blocks subdirectories are specific to this demo, and their names can be validated by examining the contents of the setupConfig.yaml file that you will find inside the acmConfig directory.

STEP FIVE: Run Appliance CLI Commands

After validating setup, create the appliance by running:

acm appliance on  

You can watch the appliance being created in the following two ways:

  1. The command line will print out structured logs organized by workflow steps you can read about in the documentation on this web site . These same logs will be stored in local log files on your machine.
  2. The Azure Portal GUI console at portal.azure.com has a resource groups dashboard. You can log in to that dashboard and view the resource groups being created and deleted by Agile Cloud Manager’s automation. NOTE: If you are one of the small percentage of users whose Azure resource groups dashboard GUI is not showing the resource creation, you can alternatively look for the same resources by navigating in the Azure Portal GUI to “Home>Subscriptions>YourSubScriptionName>Resources”.

After the appliance has been created, you must destroy the appliance with the following command:

acm appliance off  

Confirm in the Azure Portal GUI that all involved resources have been deleted before moving on. If you encounter a problem, you can diagnose the problem by examining the logs. If you need help, create a ticket at the project website and someone will respond to help you in a timely manner.

STEP SIX: Run Other CLI Commands

Experiment with other CLI commands after the appliance has been destroyed. The other CLI commands will enable you to create and destroy individual components of the appliance.

The documentation for the CLI commands is at this link.

You can read about the language that defines the objects on which the CLI commands work at this second link.

And you can read about operating on the object model using the CLI at this third link.

STEP SEVEN: Clean Up

Back up keys.yaml and config.yaml someplace safe so that you can re-use them later.

Confirm that all relevant resources have been deleted by viewing the Azure Portal GUI’s resource groups dashboard, or in “Home>Subscriptions>YourSubScriptionName>Resources” if for some reason you are one of the small percentage of users for whom Azure does not display resources in the resource groups dashboard.

Run acm setup off if you wish.

Confirm that anything you created has now been deleted.

Make sure that there are no keys.yaml or config.yaml in your $USER\acm\keys\starter directory after you backed up those files to a safe location.

Dig Deeper

If you encounter any errors, or if you want to experiment, dig deeper, and potentially cleanup after running “acm appliance on” and “acm appliance off”, you can try reading the instructions at this link

Return to the list of example appliances at this link