|
1 | 1 | # azure-create-app-registrations-using-terraform
|
2 | 2 | Create app registrations in Azure using terraform and github workflow
|
3 | 3 |
|
| 4 | +# How code works |
4 | 5 |
|
5 |
| -#References |
| 6 | +* This repo uses terraform to create app registration and service principal in Azure. |
| 7 | + |
| 8 | +# parameters used |
| 9 | + |
| 10 | +| input name | description | type | mandatory | |
| 11 | +|------------|------------|-----|-------------| |
| 12 | +| app_registration_name | Azure App registration name | string | :heavy_check_mark: | |
| 13 | +| app_registration_owner | App registration owners names | string | :heavy_check_mark: | |
| 14 | +| app_registration_description | App registration description | string | | |
| 15 | + |
| 16 | +# Terraform commands and How to run the code locally |
| 17 | + |
| 18 | +1. Clone the repo and switch to the folder |
| 19 | +2. cd azure-create-app-registrations-using-terraform |
| 20 | +3. Then run `terraform init` |
| 21 | +4. run `terraform validate` |
| 22 | +5. then `terraform plan` |
| 23 | +6. provide the values when popped up |
| 24 | +7. then `terraform apply` and provide `yes` as confirmation |
| 25 | + |
| 26 | +## Conditions |
| 27 | + |
| 28 | +* Azure active directory user should have a proper mail id available |
| 29 | + |
| 30 | +# How to run as a github workflow |
| 31 | + |
| 32 | +1. Go to your cloned repo and then to actions tab |
| 33 | + |
| 34 | +2. Choose the workflow `azure-create-app-registrations-using-terraform.yaml` on left side |
6 | 35 |
|
7 |
| -[azuread_application_password](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/application_password) |
| 36 | +3. Next click on `Run Workflow` on right side top and enter the input parameters required |
| 37 | + |
| 38 | +4. Click on `Run Workflow` (green one) |
| 39 | + |
| 40 | +5. After the job is completed, The app registration and sp will be created with owners |
| 41 | + |
| 42 | +# Credentials needed |
| 43 | + |
| 44 | +**Authentication to Azure is done using service principal** |
| 45 | + |
| 46 | +``` |
| 47 | +env: |
| 48 | + ARM_CLIENT_ID: ${{ secrets.APP_ID }} |
| 49 | + ARM_CLIENT_SECRET: ${{ secrets.APP_SECRET }} |
| 50 | + ARM_TENANT_ID: ${{ secrets.TENANT_ID }} |
| 51 | + ARM_SUBSCRIPTION_ID: ${{ secrets.SUBSCRIPTION_ID }} |
| 52 | +``` |
| 53 | + |
| 54 | +`ARM_CLIENT_ID`, `ARM_CLIENT_SECRET`, `ARM_TENANT_ID`, `ARM_SUBSCRIPTION_ID` are required Environment variables. |
| 55 | + |
| 56 | +I used GitHub secrets on the workflow for authentication. |
| 57 | + |
| 58 | + |
| 59 | +#References |
| 60 | +* [using-secrets-in-github-actions](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions) |
| 61 | +* [azuread_application_password](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/application_password) |
| 62 | +* [azuread_service_principal](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/resources/service_principal) |
0 commit comments