Starter Kits

Source code & Installation

The source code of this kit module can be found hereopen in new window

Run the following command to install the kit module:

collie kit import azure/buildingblocks/starterkit/backplane
1

This is an implementation of "Cloud Starter Kits" that provides application teams with

  • a GitHub repository, seeded with an application starter kit
  • a GitHub actions pipeline
  • a service account solution that enables the GitHub actions pipeline to deploy to their Azure Subscription

Prerequisites

GitHub App

Apart from an Azure Landing Zone (we recommend using starter kits only with Sandbox Landing Zones) you will need a GitHub organization and the ability to create and install a private GitHub Appopen in new window on the organization. This app will need the following permissions

  • Permissions
    • Read access to metadata and organization administration
    • Read and write access to actions, administration, code, secrets, and workflows
  • Repository access: All repositories

You will also need to generate a private key .PEM file for the app to be used by the github terraform provideropen in new window when deploying instances of the buildingblock/ module.

Template Repository

You will also need a template repository that contains code and GitHub actions pipelines. The "official example" that we use for testing is likvid-bank/starterkit-template-azure-static-websiteopen in new window. This template sets up an Azure Static Website including a PR workflow for terraform and code.

Structure of this Kit module

This kit module comes with three components, each responsible for enabling deployment of the next

  • the kit module itself, acting as the building block's "backplane" that sets up all required infrastructure for deploying starterkits for application teams
  • a terraform module that forms the definition for each "building block", i.e. the instance of the starterkit deployed for a particular application team including a GitHub repo and GitHub actions pipeline
  • terraform code that lives in the starterkit template, deployed by a GitHub actions pipeline

The following sections explain these parts in more detail

Deployment of the Building Block backplane

Before we can deploy building blocks, we need to first set up the backplane. This operation is only performed once by deploying this kit module using collie as any other kit module with collie kit apply and collie foundation deploy.

Unforutnately it's currently not possible to setup a GitHub app via terraform, so please perform this manually.

This will deploy the following resources:

flowchart TD
  subgraph github[GitHub Organization]
    ghapp[GitHub App]
    ghrepotemplate[GitHub Template Repository]
  end
  subgraph Azure
    subgraph bbsub[Building Block Backplane Subscription]
      bbsubtfstate[StarterKit BB TF State]
      bbspn[StarterKit SPN]

    end
  end

  BB((Starter Kit<br>Building Block))

  BB --> github
  BB --> Azure
  bbspn --Storage Blob Owner--> bbsubtfstate


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Deployment of a Building Block

Now that we the backplane deployed, we can use the backplane to deploy an instance of the buildingblock terraform module into a sandbox subscription supplied by the application team. The easiest way to do this is to create a building block definition from the buildingblock terraform module in meshStack and configure it with the config_tf file produced by the backplane module.

The chart below shows the interaction of cloud resources when deploying a new building block using the backplane:

flowchart TD
  subgraph GitHub[GitHub Organization]
    ghapp[GitHub App]
    subgraph ghrepo [GitHub Repo]
      ghpipeline[Deploy Pipeline]
    end
    ghrepotemplate[GitHub Template Repository]
  end
  subgraph Azure
    subgraph bbsub[Building Block Backplane Subscription]
      bbsubtfstate[StarterKit BB TF State]
      bbspn[StarterKit SPN]

    end
    subgraph sbsub[Sandbox Subscription]
      subgraph rgcicd[Resource Group ci-cd]
        ghactionsuami[UAMI for GitHub Actions]
        sbsubtfstate[Pipeline TF State]
      end
      subgraph rgapp[Resource Group app]
        staticwebsite
      end
    end
  end

  BB((Starter Kit Building Block))

  ghapp -.deploys.-> ghrepo
  bbspn -.deploys.-> rgcicd
  bbspn -.deploys.-> rgapp
  BB -.via github provider.-> ghapp
  BB -.via azurerm provider.-> bbspn
  ghrepotemplate -.from template.-> ghrepo
  ghactionsuami --Storage Blob Owner--> sbsubtfstate
  ghpipeline --Workload Identity Federation--> ghactionsuami
  bbspn --Storage Blob Owner--> bbsubtfstate
  ghactionsuami --Owner--> rgapp

  linkStyle 0,1,2,3,4,5 stroke:#ff3,stroke-width:4px;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

Deployment of the App

Now that we have the application team's sandbox subscription and their GitHub repository configured, the team can use the setup to deploy their staticwebsite app.

flowchart TD
  subgraph GitHub[GitHub Organization]
    subgraph ghrepo [GitHub Repo]
      ghpipeline[Deploy Pipeline]
    end
  end
  subgraph Azure
    subgraph sbsub[Sandbox Subscription]
      subgraph rgcicd[Resource Group ci-cd]
        ghactionsuami[UAMI for GitHub Actions]
        sbsubtfstate[Pipeline TF State]
      end
      subgraph rgapp[Resource Group app]
        staticwebsite
      end
    end
  end

  ghactionsuami -.deploys.-> staticwebsite

  ghactionsuami --Storage Blob Owner--> sbsubtfstate
  ghpipeline --Workload Identity Federation--> ghactionsuami
  ghactionsuami --Owner--> rgapp

  linkStyle 0 stroke:#ff3,stroke-width:4px;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

Creating Custom Starter Kits

Using this kit module as a template, you can quickly develop similar starter kits. You will typically only need to customize the template repository with code and GitHub Actions workflows.

For advanced use cases, you can of course also want to customize the buildingblock/ terraform module itself or even the backplane terraform module.

Requirements

NameVersion
terraform>= 1.0
azuread3.0.2
azurerm3.116.0
github5.42.0
random3.6.0
time0.11.1

Modules

No modules.

Resources

NameType
azuread_app_role_assignment.starterkit-directoryopen in new windowresource
azuread_application.starterkitopen in new windowresource
azuread_service_principal.starterkitopen in new windowresource
azuread_service_principal_password.starterkitopen in new windowresource
azurerm_resource_group.tfstatesopen in new windowresource
azurerm_role_assignment.starterkit_accessopen in new windowresource
azurerm_role_assignment.terraform_stateopen in new windowresource
azurerm_role_definition.starterkit_accessopen in new windowresource
azurerm_role_definition.starterkit_deployopen in new windowresource
azurerm_storage_account.tfstatesopen in new windowresource
azurerm_storage_container.tfstatesopen in new windowresource
github_repository.staticwebsite_templateopen in new windowresource
random_string.resource_codeopen in new windowresource
time_rotating.key_rotationopen in new windowresource
azuread_application_published_app_ids.well_knownopen in new windowdata source
azuread_group.project_adminsopen in new windowdata source
azuread_service_principal.msgraphopen in new windowdata source
azurerm_subscription.currentopen in new windowdata source

Inputs

NameDescriptionTypeDefaultRequired
github_app_idid of your GitHub Appnumbern/ayes
github_app_installation_idid of your GitHub App installation as it appears in URLs on GitHub.comnumbern/ayes
github_orgid of your GitHub organization as it appears in URLs on GitHub.comstringn/ayes
locationAzure location for deploying the building block terraform state storage accountstringn/ayes
scopeScope where the building block should be deployable, typically a Sandbox Landing Zone Management Groupstringn/ayes

Outputs

NameDescription
config_tfGenerates a config.tf that can be dropped into meshStack's BuildingBlockDefinition as an encrypted file input to configure this building block.
documentation_mdn/a