LazyStack

LzConfigure Script

The LzConfigure.ps1 PowerShell script is run on the Management Workstation to configure your SMF Organization.

This script was used in the initial SMF setup to create a GitHub Organization configured wih:

  • GitHub Organization: AzOrg
    • - GitHub Admin Account: AzAdmin
    • - Copy of InSciCo/PetStore repository (used in SMF tutorial)
    • - Fork of LazyStackSMF (tools and such)
  • - AWS Management Account: AzMgmt
  • - AWS Tutorial System Test Account with CI/CD of application test stacks: AzTutTest
  • - AWS Tutorial System Production Account with CD of application prod stack: AzTutProd

SMF.yaml File

The first time you run the AzConfigure script, a SMF.yaml file is written in your LazyStackSettings folder. This file contains the configuration settings for your SMF Organization. Here is a sample SMF.yaml file generated for our made-up organization with an OrgCode of "Az" and a GitHub organization name of "AzOrg".


Az:
  AWS:
    MgmtProfile: AzMgmt
    DefaultRegion: us-east-1
    OrgUnits:
    - DevOU
    - TestOU
    - ProdOU
  Sources:
    GitHub:
      Type: GitHub
      AcctName: AzAdmin
      OrgName: AzOrg
  Systems:
    Tut:
      Description: Tutorial System
      Accounts:
        Test:
          Type: Test
          DefaultRegion: us-east-1
          Description: Test System Account
          Pipelines:
            Test_PR_Create:
              Description: Create PR Stack on Pull Request Creation
              TemplatePath: ../LazyStackSMF/Test_CodeBuild_PR_Create.yaml
              Region: us-east-1
              TemplateParams:
                RepoParam: https://github.com/AzOrg/Petstore.git
                UtilRepoParam: https://github.com/AzOrg/LazyStackSMF.git
            Test_PR_Merge:
              Description: Delete PR Stack on Pull Request Merge
              TemplatePath: ../LazyStackSMF/Test_CodeBuild_PR_Merge.yaml
              Region: us-east-1
              TemplateParams:
                RepoParam: https://github.com/AzOrg/Petstore.git
        Prod:
          Type: Prod
          Description: Prod System Account
          Pipelines:
            Prod_PR_Merge:
              Description: Update Production Stack on Pull Request Merge
              TemplatePath: ../LazyStackSMF/Prod_CodeBuild_PR_Merge.yaml
              Region: us-east-1
              TemplateParams:
                RepoParam: https://github.com/AzOrg/Petstore.git
                UtilRepoParam: https://github.com/AzOrg/LazyStackSMF.git
                ProdStackNameParam: us-east-1-petstore

The hierarchy of this document reflects the organization diagrams previously shown:

  • OrgCode - Organization Code
    • AWS - connection and organization unit information
      • OrgUnits - names of AWS organizational units
    • Sources - connection information
      • GitHub - currently, this is the only source supported
    • Systems - one or more systems
      • SysCode - System Code
        • Accounts - one or more AWS Accounts
          • AccountType (Test or Prod)
            • Pipelines - one or more CI/CD pipelines
              • PipelineName - CodeBuild pipeline project configuration
Adding a New System

It is very easy to add additional systems (each containing a test and production account with CI/CD pipelines). You can copy an existing system (like Tut), paste it into the SMF file, give it a new SysCode, and then edit Pipeline properties as necessary. Typically, this would mean changing the RepoParm value on each Pipeline under the new system.

After making these changes you simply run the LzConfigure script and it will create the new AWS Accounts and deploy the new pipeline projects.

NOTE: AWS limits new Organizations to having 4 Accounts. Each time you add a new system you are adding 2 new accounts. Before configuring a new System, request that AWS increase the maximum number of accounts limt in your organization.

Adding another Serverless Stack to a System

Adding a new Serverless Stack to a System is accomplished by adding additional pipelines under the existing System Accounts. Use the existing pipelines as an example. Each Pipeline must have a unique name under the Pipelines section.

After making these changes you simply run the LzConfigure script and it will create and deploy the new pipeline projects.

Running the LzConfigure Script

Each new AWS Account needs a unique email address or alias. Have these handy before you run the script.

  1. Open a PowerShell terminal

  2. CD into your LazyStackSettings folder.

  3. ..\LazyStackSMF\LzConfigure.ps1