Skip to content

Commit 6671882

Browse files
authored
Remove admin access to container registry from pipelines (#7492)
As part of the Safe Secrets Standard, we need to ensure that our Azure Container Registry resources do not have their local admin accounts enabled. In our test pipelines that set up IoT Edge with credentials for pulling daily builds of our Docker images, we need to use short-lived tokens to pull images, rather than grabbing the local admin credentials from a key vault. This change makes the appropriate changes to our test pipelines. It removes the old key vault secret references, adds a new template that can generate a short-lived token (plus server address and username), and uses the new information throughout the pipelines, in place of the old secrets. To test, I disabled the local admin on the key vaults we use in our test pipelines, then I ran the following pipelines and confirmed they succeed: - Checkin end-to-end tests - End-to-end tests - Nested end-to-end tests - ISA-95 smoke tests - Connectivity tests ## Azure IoT Edge PR checklist:
1 parent 3ff140f commit 6671882

16 files changed

+340
-506
lines changed

builds/checkin/e2e-checkin.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,27 @@ stages:
6060
steps:
6161
- template: ../e2e/templates/e2e-vault-secrets.yaml
6262
parameters:
63-
azureSubscription: $(az.subscription)
64-
keyVaultName: $(kv.name)
63+
azureSubscription: '$(az.subscription)'
64+
keyVaultName: '$(kv.name)'
6565
- template: ../e2e/templates/storage-token.yaml
6666
parameters:
67-
azureSubscription: $(az.subscription)
67+
azureSubscription: '$(az.subscription)'
68+
- template: ../e2e/templates/acr-credentials.yaml
69+
parameters:
70+
acrName: '$(cr.name)'
71+
serviceConnection: '$(az.subscription)'
6872
- template: ../e2e/templates/e2e-setup.yaml
6973
parameters:
74+
containerRegistryServer: '$(acrServer)'
75+
containerRegistryUsername: '$(acrUsername)'
7076
iotHubResourceId: '$(iotHubResourceId)'
7177
rootCaCertificate: '$(rootCaCertificate)'
7278
rootCaKey: '$(rootCaKey)'
7379
- template: ../e2e/templates/e2e-run.yaml
7480
parameters:
75-
containerRegistryPassword: '$(containerRegistryPassword)'
81+
containerRegistryPassword: '$(acrPassword)'
7682
dpsGroupKeySymmetric: '$(dpsGroupKeySymmetric)'
7783
eventHubCompatibleEndpoint: '$(eventHubCompatibleEndpoint)'
7884
iotHubConnectionString: '$(iotHubConnectionString)'
7985
rootCaPassword: '$(rootCaPassword)'
80-
sas_uri: $(sas_uri)
86+
sas_uri: '$(sas_uri)'

builds/e2e/connectivity.yaml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,26 @@ jobs:
4242
azureSubscription: $(azure.subscription)
4343
crossJobVariables: true
4444

45+
- job: ContainerRegistryCredentials
46+
displayName: 'Get ACR Credentials'
47+
pool:
48+
name: $(pool.linux.name)
49+
demands:
50+
- ImageOverride -equals agent-aziotedge-ubuntu-22.04-msmoby
51+
steps:
52+
- template: templates/acr-credentials.yaml
53+
parameters:
54+
acrName: $(cr.name)
55+
crossJobVariables: true
56+
serviceConnection: $(azure.subscription)
57+
4558
################################################################################
4659
- job: linux_amd64_moby
4760
################################################################################
4861
displayName: Linux AMD64 Moby
49-
dependsOn: Token
62+
dependsOn:
63+
- Token
64+
- ContainerRegistryCredentials
5065
condition: and(succeeded('Token'), eq(variables['run.linux.amd64.moby'], 'true'), ne(variables['agent.group'], ''))
5166
timeoutInMinutes: 240
5267
strategy:
@@ -107,6 +122,9 @@ jobs:
107122
identity.artifact.name: 'aziot-identity-ubuntu22.04-amd64'
108123
edgelet.artifact.name: 'iotedged-ubuntu22.04-amd64'
109124
sas_uri: $[ dependencies.Token.outputs['generate.sas_uri'] ]
125+
cr.server: $[ dependencies.ContainerRegistryCredentials.outputs['acrgen.acrServer'] ]
126+
cr.username: $[ dependencies.ContainerRegistryCredentials.outputs['acrgen.acrUsername'] ]
127+
cr.token: $[ dependencies.ContainerRegistryCredentials.outputs['acrgen.acrPassword'] ]
110128
steps:
111129
- task: Bash@3
112130
name: Print_test_parameters
@@ -134,8 +152,6 @@ jobs:
134152
azureSubscription: $(azure.subscription)
135153
KeyVaultName: 'edgebuildkv'
136154
SecretsFilter: >-
137-
edgebuilds-azurecr-io-username,
138-
edgebuilds-azurecr-io-pwd,
139155
kvLogAnalyticWorkspaceId,
140156
kvLogAnalyticSharedKey,
141157
- task: AzureKeyVault@2
@@ -205,9 +221,9 @@ jobs:
205221
identity.artifact.name: '$(identity.artifact.name)'
206222
edgelet.artifact.name: '$(edgelet.artifact.name)'
207223
images.artifact.name: '$(images.artifact.name.linux)'
208-
container.registry: '$(container.registry)'
209-
container.registry.username: '$(edgebuilds-azurecr-io-username)'
210-
container.registry.password: '$(edgebuilds-azurecr-io-pwd)'
224+
container.registry: '$(cr.server)'
225+
container.registry.username: '$(cr.username)'
226+
container.registry.password: '$(cr.token)'
211227
iotHub.connectionString: '$(IotHub-ConnStr)'
212228
eventHub.connectionString: '$(IotHub-EventHubConnStr)'
213229
deploymentFileName: '$(deploymentFileName)'
@@ -238,7 +254,9 @@ jobs:
238254
- job: linux_arm32v7_moby
239255
################################################################################
240256
displayName: Linux ARM32v7 Moby
241-
dependsOn: Token
257+
dependsOn:
258+
- Token
259+
- ContainerRegistryCredentials
242260
condition: and(succeeded('Token'), eq(variables['run.linux.arm32v7.moby'], 'true'), ne(variables['agent.group'], ''))
243261
timeoutInMinutes: 240
244262
strategy:
@@ -303,6 +321,9 @@ jobs:
303321
identity.artifact.name: 'aziot-identity-debian11-arm32v7'
304322
edgelet.artifact.name: 'iotedged-debian11-arm32v7'
305323
sas_uri: $[ dependencies.Token.outputs['generate.sas_uri'] ]
324+
cr.server: $[ dependencies.ContainerRegistryCredentials.outputs['acrgen.acrServer'] ]
325+
cr.username: $[ dependencies.ContainerRegistryCredentials.outputs['acrgen.acrUsername'] ]
326+
cr.token: $[ dependencies.ContainerRegistryCredentials.outputs['acrgen.acrPassword'] ]
306327
steps:
307328
- task: Bash@3
308329
name: Print_test_parameters
@@ -330,8 +351,6 @@ jobs:
330351
azureSubscription: $(azure.subscription)
331352
KeyVaultName: 'edgebuildkv'
332353
SecretsFilter: >-
333-
edgebuilds-azurecr-io-username,
334-
edgebuilds-azurecr-io-pwd,
335354
kvLogAnalyticWorkspaceId,
336355
kvLogAnalyticSharedKey,
337356
- task: AzureKeyVault@2
@@ -398,9 +417,9 @@ jobs:
398417
identity.artifact.name: '$(identity.artifact.name)'
399418
edgelet.artifact.name: '$(edgelet.artifact.name)'
400419
images.artifact.name: '$(images.artifact.name.linux)'
401-
container.registry: '$(container.registry)'
402-
container.registry.username: '$(edgebuilds-azurecr-io-username)'
403-
container.registry.password: '$(edgebuilds-azurecr-io-pwd)'
420+
container.registry: '$(cr.server)'
421+
container.registry.username: '$(cr.username)'
422+
container.registry.password: '$(cr.token)'
404423
iotHub.connectionString: '$(EdgeConnectivityTestHubARM32ConnString)'
405424
eventHub.connectionString: '$(EdgeConnectivityEventHubARM32ConnString)'
406425
deploymentFileName: '$(deploymentFileName)'

0 commit comments

Comments
 (0)