File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
infra/pulumi-infra-deploy Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 9
9
using ProgrammerAl . Site . IaC . Config . GlobalConfigs ;
10
10
using ProgrammerAl . Site . IaC . StackBuilders . StorageApi ;
11
11
using ProgrammerAl . Site . IaC . StackBuilders . RouteFilterWorker ;
12
+ using ProgrammerAl . Site . IaC . Utilities ;
12
13
13
14
return await Pulumi . Deployment . RunAsync ( async ( ) =>
14
15
{
16
+ CredentialsUtilities . SetCredentialEnvironmentVariables ( ) ;
15
17
var clientConfig = await Pulumi . AzureNative . Authorization . GetClientConfig . InvokeAsync ( ) ;
16
18
17
19
var config = new Config ( ) ;
Original file line number Diff line number Diff line change
1
+ using Pulumi ;
2
+ using Pulumi . AzureNative . KeyVault ;
3
+ using Pulumi . AzureNative . Storage ;
4
+
5
+ using System ;
6
+
7
+ namespace ProgrammerAl . Site . IaC . Utilities ;
8
+
9
+ public static class CredentialsUtilities
10
+ {
11
+ /// <summary>
12
+ /// We use the `DefaultCredential` class for authenticating against Azure
13
+ /// The `EnvironmentCredential` uses the AZURE_* environment variables to know what Service Principal to use
14
+ /// But when using Pulumi in GitHub we have to set the same variables under the `ARM_*` names
15
+ /// So create the AZURE_* variables from the ARM_* variables if needed
16
+ /// </summary>
17
+ public static void SetCredentialEnvironmentVariables ( )
18
+ {
19
+ var clientId = Environment . GetEnvironmentVariable ( "ARM_CLIENT_ID" ) ;
20
+ var clientSecret = Environment . GetEnvironmentVariable ( "ARM_CLIENT_SECRET" ) ;
21
+ var tenantId = Environment . GetEnvironmentVariable ( "ARM_TENANT_ID" ) ;
22
+
23
+ if ( ! string . IsNullOrWhiteSpace ( clientId )
24
+ && ! string . IsNullOrWhiteSpace ( clientSecret )
25
+ && ! string . IsNullOrWhiteSpace ( tenantId ) )
26
+ {
27
+ Log . Info ( $ "ARM_* environment variables set. Creating AZURE_* environment variables for use with the `EnvironmentCredential` class") ;
28
+
29
+ Environment . SetEnvironmentVariable ( "AZURE_CLIENT_ID" , clientId ) ;
30
+ Environment . SetEnvironmentVariable ( "AZURE_CLIENT_SECRET" , clientSecret ) ;
31
+ Environment . SetEnvironmentVariable ( "AZURE_TENANT_ID" , tenantId ) ;
32
+ }
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments