alz-terraform-acceleratordocswiki[User-Guide]-Quick-Start-Phase-1.md at main · Azurealz-terraform-accelerator
Open in github.dev Open in a new github.dev tab Open in codespace
t
Phase 1 of the accelerator is to setup your pre-requisites. Follow the steps below to do that.
1.1 Tools
You'll need to install the following tools before getting started.
- PowerShell Core: Follow the instructions for your operating system
- Terraform CLI: Follow the instructions for your operating system
- Azure CLI: Follow the instructions for your operating system
- Git: Follow the instructions for your operating system
[!NOTE] In all cases, ensure that the tools are available from a PowerShell core (pwsh) terminal. You may need to add them to your environment path if they are not.
1.2 Azure Subscriptions
We recommend setting up 3 subscriptions for Azure landing zones. These are management, identity and networking. You can read more about this in the Landing Zone docs.
To create the subscriptions you will need access to a billing agreement. The following links detail the permissions required for each type of agreement:
Once you have the access required, create three subscriptions following your desired naming convention with the following purposes:
- management
- identity
- networking
Take note of the subscription id of each subscription as we'll need them later.
1.3 Azure Credentials
You need an Azure User or Service Principal with the following permissions to run the bootstrap:
Management Group Contributor
on you root management groups (usually calledTenant Root Group
)Owner
on your Azure landing zone subscriptions
For simplicity we recommend using a User account since this is a one off proceess that you are unlikely to repeat.
1.3.1 Azure Permissions
It is likely that if you were able to create the subscriptions you already have the level of access required for a user account, however you should follow these steps to validate them.
If your preference is to run the bootstrap in the context of a Service Principal, follow these steps to create one:
1.3.1.1 Create Service Principal (Skip this if using a User account)
- Navigate to the Azure Portal and sign in to your tenant.
- Search for
Azure Active Directory
and open it. - Copy the
Tenant ID
field and save it somewhere safe, making a note it is theARM_TENANT_ID
. - Click
App registrations
in the left navigation. - Click
+ New registration
. - Choose a name (SPN) that you will remember and make a note of it, we recommend using
sp-alz-boostrap
. - Type the chosen name into the
Name
field. - Leave the other settings as default and click
Register
. - Wait for it to be created.
- Copy the
Application (client) ID
field and save it somewhere safe, making a note it is theARM_CLIENT_ID
. - Click
Certificates & secrets
in the left navigation. - Ensure the
Client secrets
tab is selected and click+ New client secret
. - Enter
ALZ Bootstrap
in theDescription
field. - Change the
Expires
field, chooseCustom
. - Set the
Start
field to todays date. - Set the
End
field to tomorrows date. - Click
Add
. - Copy the
Value
field save it somewhere safe, making a note that it is theARM_CLIENT_SECRET
.
1.3.1.2 Create Permissions
- The service principal name (SPN) is the username of the User account or the name of the app registration you c reated.
- Search for
Subscriptions
and click to navigate to the subscription view. - For each of the subscriptions you created in the previous step:
- Navigate to the subscription.
- Click
Access control (IAM)
in the left navigation. - Click
+ Add
and chooseAdd role assignment
. - Choose the
Priviledged administrator roles
tab. - Click
Owner
to highlight the row and then clickNext
. - Leave the
User, group or service principal
option checked. - Click
+ Select Members
and search for your SPN in the search box on the right. - Click on your User to highlight it and then click
Select
. - Click
Review + assign
, then clickReview + assign
again when the warning appears. - Wait for the role to be assinged and move onto the next subscription.
- Search for
Management Groups
and click to navigate to the management groups view. - Click the
Tenant Root Group
management group (Note, it is possible someone changed the name of your root management group, select the one at the very top of the hierarchy if that is the case) - Click
Access control (IAM)
in the left navigation. - Click
+ Add
and chooseAdd role assignment
. - Remain on the
Job function roles
tab. - Search for
Management Group Contributor
and click the row to highlight that role. - Click
Next
. - Leave the
User, group or service principal
option checked. - Click
+ Select Members
and search for your SPN in the search box on the right. - Click on your User to highlight it and then click
Select
. - Click
Review + assign
, then clickReview + assign
again when the warning appears. - Wait for the role to be assinged and you are done with this part.
1.4 Login / Set Credentials
Follow these steps to login as a User or user Service Princiapl credentials:
1.4.1 User Login
- Open a new PowerShell Core (pwsh) terminal.
- Run
az login
. - You'll be redirected to a browser to login, perform MFA, etc.
- Find the subscription id of the management subscription you made a note of earlier.
- Type
az account set --subscription "<subscription id of your management subscription>"
and hit enter. - Type
az account show
and verify that you are connected to the management subscription.
1.4.2 Service Principal Credentials
- Open a new PowerShell Core (pwsh) terminal.
- Find the
ARM_TENANT_ID
you made a note of earlier. - Type
$env:ARM_TENANT_ID="<tenant id>"
and hit enter. - Find the
ARM_CLIENT_ID
you made a note of earlier. - Type
$env:ARM_CLIENT_ID="<client id>"
and hit enter. - Find the
ARM_CLIENT_SECRET
you made a note of earlier. - Type
$env:ARM_CLIENT_SECRET="<client id>"
and hit enter. - Find the subscription id of the manangement subscription you made a note of earlier.
- Type
$env:ARM_SUBSCRIPTION_ID="<subscription id>"
and hit enter.
[!NOTE] If you close your PowerShell prompt prior to running the bootstrap, you need to re-enter these environment variables.
1.5 Version Control System Personal Access Token (PAT)
You'll need to decide whether you are using GitHub or Azure DevOps and follow the instructions below to generate a PAT:
1.5.1 Azure DevOps
- Navigate to dev.azure.com and sign in to your organization.
- Ensure you navigate to the organization you want to deploy to.
- Click the
User settings
icon in the top right and selectPersonal access tokens
. - Click
+ New Token
. - Enter
Azure Landing Zone Terraform Accelerator
in theName
field. - Alter the
Expiration
drop down and selectCustom defined
. - Choose tommorrows date in the date picker.
- Click the
Show all scopes
link at the bottom. - Check the following scopes:
Agent Pools
:Read & manage
Build
:Read & execute
Code
:Full
Environment
:Read & manage
Graph
:Read & manage
Pipeline Resources
:Use & manage
Project and Team
:Read, write & manage
Service Connections
:Read, write & manage
Variable Groups
:Read, create & manage
- Click
Create
. - Copy the token and save it somewhere safe.
- Click
Close
.
1.5.2 GitHub
- Navigate to github.com.
- Click on your user icon in the top right and select
Settings
. - Scroll down and click on
Developer Settings
in the left navigation. - Click
Personal access tokens
in the left navigation and selectTokens (classic)
. - Click
Generate new token
at the top and selectGenerate new token (classic)
. - Enter
Azure Landing Zone Terraform Accelerator
in theNote
field. - Alter the
Expiration
drop down and selectCustom
. - Choose tommorrows date in the date picker.
- Check the following scopes:
repo
workflow
admin:org
:write:org
user
:read:user
user
:user:email
delete_repo
- Click
Generate token
. - Copy the token and save it somewhere safe.
- If your organization uses single sign on, then click the
Configure SSO
link next to your new PAT. - Select your organization and click
Authorize
, then follow the prompts to allow SSO.