Skip to content

Commit cac3d5e

Browse files
committed
update
1 parent a46f90a commit cac3d5e

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

Aks/index.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ export default async ({
511511
value: config,
512512
dependsOn: aks,
513513
ignoreChange: true,
514+
contentType: name,
514515
vaultInfo,
515516
});
516517
});
@@ -624,19 +625,24 @@ export default async ({
624625
// });
625626
// }
626627

627-
if (
628-
acrScope &&
629-
identityProfile &&
630-
identityProfile['kubeletidentity'] &&
631-
identityProfile['kubeletidentity'].objectId
632-
) {
628+
if (acrScope && identityProfile && identityProfile['kubeletidentity']) {
633629
await roleAssignment({
634630
name: `${name}-aks-identity-profile-pull`,
635-
principalId: identityProfile['kubeletidentity'].objectId,
631+
principalId: identityProfile['kubeletidentity'].objectId!,
636632
principalType: 'ServicePrincipal',
637633
roleName: 'AcrPull',
638634
scope: acrScope,
639635
});
636+
637+
if (vaultInfo) {
638+
addCustomSecret({
639+
name: `${name}-identity-clientId`,
640+
value: identityProfile['kubeletidentity'].clientId!,
641+
dependsOn: aks,
642+
contentType: name,
643+
vaultInfo,
644+
});
645+
}
640646
}
641647

642648
// if (identity?.principalId) {

AzAd/Role.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import adGroupCreator, { GroupPermissionProps } from './Group';
2-
import { Environments } from '../Common/AzureEnv';
2+
import { currentEnv, Environments } from '../Common/AzureEnv';
33
import { Input } from '@pulumi/pulumi';
44
import { organization } from '../Common/StackEnv';
55

@@ -33,7 +33,7 @@ export const getRoleName = ({
3333
appName,
3434
moduleName,
3535
roleName,
36-
includeOrganization=true,
36+
includeOrganization = true,
3737
}: RoleNameType) => {
3838
const prefix = includeOrganization ? `${organization} ROL` : 'ROL';
3939

Sql/index.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { EnvRoleNamesType } from '../AzAd/EnvRoles';
55
import { getAdGroup } from '../AzAd/Group';
66
import { roleAssignment } from '../AzAd/RoleAssignment';
77
import {
8+
currentEnv,
89
defaultTags,
910
isPrd,
1011
subscriptionId,
@@ -22,6 +23,7 @@ import { convertToIpRange } from '../VNet/Helper';
2223
import privateEndpointCreator from '../VNet/PrivateEndpoint';
2324
import sqlDbCreator, { SqlDbProps } from './SqlDb';
2425
import { addCustomSecret } from '../KeyVault/CustomHelper';
26+
import Role from '../AzAd/Role';
2527

2628
type ElasticPoolCapacityProps = 50 | 100 | 200 | 300 | 400 | 800 | 1200;
2729

@@ -77,7 +79,7 @@ interface Props extends BasicResourceArgs {
7779

7880
/** if Auth is not provided it will be auto generated */
7981
auth: {
80-
envRoleNames: EnvRoleNamesType;
82+
envRoleNames?: EnvRoleNamesType;
8183
/** create an Admin group on AzAD for SQL accessing.*/
8284
enableAdAdministrator?: boolean;
8385
azureAdOnlyAuthentication?: boolean;
@@ -137,7 +139,9 @@ export default async ({
137139
// }
138140

139141
const adminGroup = auth?.enableAdAdministrator
140-
? await getAdGroup(auth.envRoleNames.admin)
142+
? auth.envRoleNames
143+
? await getAdGroup(auth.envRoleNames.admin)
144+
: await Role({ env: currentEnv, roleName: 'ADMIN', appName: 'SQL' })
141145
: undefined;
142146

143147
const sqlServer = new sql.Server(
@@ -149,7 +153,6 @@ export default async ({
149153
minimalTlsVersion: '1.2',
150154

151155
identity: { type: 'SystemAssigned' },
152-
153156
administratorLogin: auth?.adminLogin,
154157
administratorLoginPassword: auth?.password,
155158

0 commit comments

Comments
 (0)