Skip to content

Commit

Permalink
GET the devops MSI using a separate identities client scoped to the
Browse files Browse the repository at this point in the history
correct Azure subscription
  • Loading branch information
kimorris27 committed Nov 1, 2024
1 parent 9858073 commit 8151f74
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 35 deletions.
70 changes: 36 additions & 34 deletions pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,24 @@ type deployer struct {
log *logrus.Entry
env env.Core

globaldeployments features.DeploymentsClient
globalgroups features.ResourceGroupsClient
globalrecordsets dns.RecordSetsClient
globalaccounts storage.AccountsClient
deployments features.DeploymentsClient
groups features.ResourceGroupsClient
userassignedidentities msi.UserAssignedIdentitiesClient
providers features.ProvidersClient
publicipaddresses network.PublicIPAddressesClient
resourceskus compute.ResourceSkusClient
roleassignments authorization.RoleAssignmentsClient
vmss compute.VirtualMachineScaleSetsClient
vmssvms compute.VirtualMachineScaleSetVMsClient
zones dns.ZonesClient
clusterKeyvault keyvault.Manager
portalKeyvault keyvault.Manager
serviceKeyvault keyvault.Manager
globaldeployments features.DeploymentsClient
globalgroups features.ResourceGroupsClient
globalrecordsets dns.RecordSetsClient
globalaccounts storage.AccountsClient
globaluserassignedidentities msi.UserAssignedIdentitiesClient
deployments features.DeploymentsClient
groups features.ResourceGroupsClient
userassignedidentities msi.UserAssignedIdentitiesClient
providers features.ProvidersClient
publicipaddresses network.PublicIPAddressesClient
resourceskus compute.ResourceSkusClient
roleassignments authorization.RoleAssignmentsClient
vmss compute.VirtualMachineScaleSetsClient
vmssvms compute.VirtualMachineScaleSetVMsClient
zones dns.ZonesClient
clusterKeyvault keyvault.Manager
portalKeyvault keyvault.Manager
serviceKeyvault keyvault.Manager

config *RPConfig
version string
Expand Down Expand Up @@ -93,23 +94,24 @@ func New(ctx context.Context, log *logrus.Entry, _env env.Core, config *RPConfig
log: log,
env: _env,

globaldeployments: features.NewDeploymentsClient(_env.Environment(), *config.Configuration.GlobalSubscriptionID, authorizer),
globalgroups: features.NewResourceGroupsClient(_env.Environment(), *config.Configuration.GlobalSubscriptionID, authorizer),
globalrecordsets: dns.NewRecordSetsClient(_env.Environment(), *config.Configuration.GlobalSubscriptionID, authorizer),
globalaccounts: storage.NewAccountsClient(_env.Environment(), *config.Configuration.GlobalSubscriptionID, authorizer),
deployments: features.NewDeploymentsClient(_env.Environment(), config.SubscriptionID, authorizer),
groups: features.NewResourceGroupsClient(_env.Environment(), config.SubscriptionID, authorizer),
userassignedidentities: msi.NewUserAssignedIdentitiesClient(_env.Environment(), config.SubscriptionID, authorizer),
providers: features.NewProvidersClient(_env.Environment(), config.SubscriptionID, authorizer),
roleassignments: authorization.NewRoleAssignmentsClient(_env.Environment(), config.SubscriptionID, authorizer),
resourceskus: compute.NewResourceSkusClient(_env.Environment(), config.SubscriptionID, authorizer),
publicipaddresses: network.NewPublicIPAddressesClient(_env.Environment(), config.SubscriptionID, authorizer),
vmss: vmssClient,
vmssvms: compute.NewVirtualMachineScaleSetVMsClient(_env.Environment(), config.SubscriptionID, authorizer),
zones: dns.NewZonesClient(_env.Environment(), config.SubscriptionID, authorizer),
clusterKeyvault: keyvault.NewManager(kvAuthorizer, "https://"+*config.Configuration.KeyvaultPrefix+env.ClusterKeyvaultSuffix+"."+_env.Environment().KeyVaultDNSSuffix+"/"),
portalKeyvault: keyvault.NewManager(kvAuthorizer, "https://"+*config.Configuration.KeyvaultPrefix+env.PortalKeyvaultSuffix+"."+_env.Environment().KeyVaultDNSSuffix+"/"),
serviceKeyvault: keyvault.NewManager(kvAuthorizer, "https://"+*config.Configuration.KeyvaultPrefix+env.ServiceKeyvaultSuffix+"."+_env.Environment().KeyVaultDNSSuffix+"/"),
globaldeployments: features.NewDeploymentsClient(_env.Environment(), *config.Configuration.GlobalSubscriptionID, authorizer),
globalgroups: features.NewResourceGroupsClient(_env.Environment(), *config.Configuration.GlobalSubscriptionID, authorizer),
globalrecordsets: dns.NewRecordSetsClient(_env.Environment(), *config.Configuration.GlobalSubscriptionID, authorizer),
globalaccounts: storage.NewAccountsClient(_env.Environment(), *config.Configuration.GlobalSubscriptionID, authorizer),
globaluserassignedidentities: msi.NewUserAssignedIdentitiesClient(_env.Environment(), config.GlobalSubscriptionID, authorizer),

Check failure on line 101 in pkg/deploy/deploy.go

View workflow job for this annotation

GitHub Actions / golangci-lint

config.GlobalSubscriptionID undefined (type *RPConfig has no field or method GlobalSubscriptionID)) (typecheck)

Check failure on line 101 in pkg/deploy/deploy.go

View workflow job for this annotation

GitHub Actions / golangci-lint

config.GlobalSubscriptionID undefined (type *RPConfig has no field or method GlobalSubscriptionID)) (typecheck)

Check failure on line 101 in pkg/deploy/deploy.go

View workflow job for this annotation

GitHub Actions / golangci-lint

config.GlobalSubscriptionID undefined (type *RPConfig has no field or method GlobalSubscriptionID) (typecheck)

Check failure on line 101 in pkg/deploy/deploy.go

View workflow job for this annotation

GitHub Actions / golangci-lint

config.GlobalSubscriptionID undefined (type *RPConfig has no field or method GlobalSubscriptionID)) (typecheck)

Check failure on line 101 in pkg/deploy/deploy.go

View workflow job for this annotation

GitHub Actions / golangci-lint

config.GlobalSubscriptionID undefined (type *RPConfig has no field or method GlobalSubscriptionID)) (typecheck)

Check failure on line 101 in pkg/deploy/deploy.go

View workflow job for this annotation

GitHub Actions / golangci-lint

config.GlobalSubscriptionID undefined (type *RPConfig has no field or method GlobalSubscriptionID) (typecheck)
deployments: features.NewDeploymentsClient(_env.Environment(), config.SubscriptionID, authorizer),
groups: features.NewResourceGroupsClient(_env.Environment(), config.SubscriptionID, authorizer),
userassignedidentities: msi.NewUserAssignedIdentitiesClient(_env.Environment(), config.SubscriptionID, authorizer),
providers: features.NewProvidersClient(_env.Environment(), config.SubscriptionID, authorizer),
roleassignments: authorization.NewRoleAssignmentsClient(_env.Environment(), config.SubscriptionID, authorizer),
resourceskus: compute.NewResourceSkusClient(_env.Environment(), config.SubscriptionID, authorizer),
publicipaddresses: network.NewPublicIPAddressesClient(_env.Environment(), config.SubscriptionID, authorizer),
vmss: vmssClient,
vmssvms: compute.NewVirtualMachineScaleSetVMsClient(_env.Environment(), config.SubscriptionID, authorizer),
zones: dns.NewZonesClient(_env.Environment(), config.SubscriptionID, authorizer),
clusterKeyvault: keyvault.NewManager(kvAuthorizer, "https://"+*config.Configuration.KeyvaultPrefix+env.ClusterKeyvaultSuffix+"."+_env.Environment().KeyVaultDNSSuffix+"/"),
portalKeyvault: keyvault.NewManager(kvAuthorizer, "https://"+*config.Configuration.KeyvaultPrefix+env.PortalKeyvaultSuffix+"."+_env.Environment().KeyVaultDNSSuffix+"/"),
serviceKeyvault: keyvault.NewManager(kvAuthorizer, "https://"+*config.Configuration.KeyvaultPrefix+env.ServiceKeyvaultSuffix+"."+_env.Environment().KeyVaultDNSSuffix+"/"),

config: config,
version: version,
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/deploy_rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (d *deployer) DeployRP(ctx context.Context) error {
return err
}

globalDevopsMSI, err := d.userassignedidentities.Get(ctx, *d.config.Configuration.GlobalResourceGroupName, *d.config.Configuration.GlobalDevopsManagedIdentity)
globalDevopsMSI, err := d.globaluserassignedidentities.Get(ctx, *d.config.Configuration.GlobalResourceGroupName, *d.config.Configuration.GlobalDevopsManagedIdentity)
if err != nil {
return err
}
Expand Down

0 comments on commit 8151f74

Please sign in to comment.