Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit d7f677a

Browse files
Updating infra generation pipeline to include Key Vault guidance (#396)
* adding key vault guidance * updates to infra kv guidance * syntax update * adding permit access note
1 parent 603b9f0 commit d7f677a

File tree

4 files changed

+87
-12
lines changed

4 files changed

+87
-12
lines changed

guides/images/kvsetupvg.png

54 KB
Loading

guides/images/permit_access.jpg

626 KB
Loading

guides/images/secrets-kv-vg.png

43.1 KB
Loading

guides/infra/spk-infra-generation-pipeline.md

+87-12
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ two flavors:
3030

3131
### 2. Add Azure Pipeline Build YAML
3232

33-
The SPK repository has a [template](../../azure-pipelines/templates/infra-generation-pipeline.yml) Azure DevOps pipeline that you may use as reference.
34-
Add the `infra-generation-pipeline.yml` file to the root of the Infra HLD repo.
33+
The SPK repository has a
34+
[template](../../azure-pipelines/templates/infra-generation-pipeline.yml) Azure
35+
DevOps pipeline that you may use as reference. Add the
36+
`infra-generation-pipeline.yml` file to the root of the Infra HLD repo.
3537

3638
### 3. Create Pipeline
3739

@@ -42,7 +44,7 @@ yaml files (e.g. definition.yaml).
4244

4345
In Azure DevOps:
4446

45-
1. Create a Variable Group.
47+
#### 3.1a. Create a Variable Group.
4648

4749
Variable Groups may vary based on the `azure-pipelines.yml` used, but for the
4850
spk `infra-generation-pipeline.yml` template, the following variables will need
@@ -69,13 +71,12 @@ AZDO_PROJECT_NAME: The name of the project in your Azure DevOps organization whe
6971

7072
You can use `spk` to create the Azure DevOps Variable Groups by executing
7173
`spk variable-group create` described in this
72-
[doc](../../guides/variable-group.md).
73-
This will require you to create a variable group manifest similar to the
74-
following:
74+
[doc](../../guides/variable-group.md). This will require you to create a
75+
variable group manifest similar to the following:
7576

76-
```
77+
```yml
7778
name: "spk-infra-hld-vg"
78-
description: "variable groupd for infra hld"
79+
description: "variable group for infra hld"
7980
type: "Vsts"
8081
variables:
8182
ACCESS_TOKEN_SECRET:
@@ -87,7 +88,7 @@ variables:
8788
ARM_SUBSCRIPTION_ID:
8889
value: "<SUBSCRIPTION-ID>"
8990
ARM_TENANT_ID:
90-
value: "<SP-TENANT-ID>
91+
value: "<SP-TENANT-ID>"
9192
CLUSTER:
9293
value: "<CLUSTER-NAME>"
9394
GENERATED_REPO:
@@ -100,12 +101,86 @@ variables:
100101
value: "<AZURE-DEVOPS-PROJECT-NAME>"
101102
```
102103
104+
![](../images/spk-infra-vg.png)
105+
106+
#### 3.1b. Create a Variable Group using Azure Key Vault
107+
103108
By using the `spk variable-group create` you are also able to link variables to
104-
secrets in Azure Keyvault.
109+
secrets in Azure Keyvault. Create a variable group in the portal or throught the
110+
`az` cli.
105111

106-
![](../images/spk-infra-vg.png)
112+
> Please note that Key Vault Secret names can only contain alphanumeric
113+
> characters and dashes.
114+
115+
Once the Keyvault has been created, You can now create a variable group manifest
116+
similar to the following:
117+
118+
```yml
119+
name: "spk-infra-hld-vg-kv"
120+
description: "key vault variable group for infra hld"
121+
type: "AzureKeyVault"
122+
variables:
123+
ACCESS-TOKEN-SECRET:
124+
enabled: true
125+
ARM-CLIENT-ID:
126+
enabled: true
127+
ARM-CLIENT-SECRET:
128+
enabled: true
129+
ARM-SUBSCRIPTION-ID:
130+
enabled: true
131+
ARM-TENANT-ID:
132+
enabled: true
133+
CLUSTER:
134+
enabled: true
135+
GENERATED-REPO:
136+
enabled: true
137+
PROJECT-DIRECTORY:
138+
enabled: true
139+
AZDO-ORG-NAME: (optional)
140+
enabled: true
141+
AZDO-PROJECT-NAME: (optional)
142+
enabled: true
143+
key_vault_provider:
144+
name: "myvault" # name of the Azure Key Vaukt with Secrets
145+
service_endpoint: # service endpoint is required to authorize with Azure Key Vault
146+
name: "my-KeyVault"
147+
# If the service endpoint with this name does not exist, the following values are required to create a new service connection with this name
148+
subscription_id: "<SUBSCRIPTION-ID>"
149+
# Azure Subscription id where Key Vault exist
150+
subscription_name: "<SUBSCRIPTION-NAME>"
151+
# Azure Subscription name where Key Vault exist
152+
service_principal_id: "<SP-ID>"
153+
# Service Principal Id that has 'Get' and 'List' in Key Vault Access Policy
154+
service_principal_secret: "<SP-PASSWORD>"
155+
# Service Principal secret for the above Service Principal Id
156+
tenant_id: "<SP-TENANT-ID>"
157+
# AAD Tenant Id for the above Service Principal
158+
```
159+
160+
> Be sure not to commit your variable group manifest to a remote repository
161+
> unless environment variables were used.
162+
163+
Alternatively you can create a variable group through the Azure DevOps UI and
164+
connect it to the pre-existing Key Vault you created. Navigate to your pipeline
165+
library and create a new variable group. Identify the key vault that was
166+
previously provisioned.
167+
168+
![](../images/kvsetupvg.png)
169+
170+
Additionally, be sure to select the respective Key secrets you wish to map to
171+
your variable group.
172+
173+
![](../images/secrets-kv-vg.png)
174+
175+
> When using a variable group, you may be prompted to grant access permission to
176+
> all pipelines in order for your newly created pipeline to have access to an
177+
> agent pool and specific service connections. Be sure to navigate to the
178+
> Pipeline UI to permit permission to use the agent pool and the service
179+
> connection to authenticate against your key vault.
180+
181+
![](../images/permit_access.jpg)
107182

108-
2. Create a new pipeline.
183+
#### 3.2. Create a new pipeline.
109184

110185
You can use the Azure CLI to create the Generation pipeline. To do that, you
111186
will need to do the following:

0 commit comments

Comments
 (0)