Skip to content

Commit

Permalink
Merge pull request #32 from baoduy/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
baoduy authored Jun 22, 2024
2 parents 299eec0 + 67239e7 commit 1b9fe7a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 44 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
"replace-in-file": "^7.2.0"
},
"dependencies": {
"@drunk-pulumi/azure-providers": "^0.0.18",
"@drunk-pulumi/azure-providers": "^0.0.21",
"@pulumi/azure-native": "^2.46.0",
"@pulumi/azuread": "5.52.0",
"@pulumi/pulumi": "^3.120.0",
"@pulumi/pulumi": "^3.121.0",
"@pulumi/random": "^4.16.2",
"@pulumi/tls": "^5.0.3",
"axios": "^1.7.2",
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/types/sqlBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SqlDbSku } from "../../Sql/SqlDb";

export type SqlBuilderAuthOptionsType = Pick<
SqlAuthType,
"enableAdAdministrator" | "azureAdOnlyAuthentication"
"azureAdOnlyAuthentication"
>;

export type SqlDbBuilderType = Record<
Expand Down
27 changes: 11 additions & 16 deletions src/Sql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ const createElasticPool = ({

export type SqlAuthType = {
envRoles: EnvRolesResults;
/** create an Admin group on AzAD for SQL accessing.*/
enableAdAdministrator?: boolean;
azureAdOnlyAuthentication?: boolean;
adminLogin: Input<string>;
password: Input<string>;
Expand Down Expand Up @@ -126,8 +124,10 @@ export default ({

const adminGroup = auth.envRoles.contributor;

if (auth.azureAdOnlyAuthentication)
if (auth.azureAdOnlyAuthentication) {
ignoreChanges.push("administratorLogin");
ignoreChanges.push("administratorLoginPassword");
}

const sqlServer = new sql.Server(
sqlName,
Expand All @@ -141,20 +141,15 @@ export default ({
administratorLogin: auth?.adminLogin,
administratorLoginPassword: auth?.password,

administrators:
(auth?.enableAdAdministrator || auth.azureAdOnlyAuthentication) &&
adminGroup
? {
administratorType: sql.AdministratorType.ActiveDirectory,
azureADOnlyAuthentication: auth.azureAdOnlyAuthentication,

principalType: sql.PrincipalType.Group,
tenantId,
sid: adminGroup.objectId,
login: adminGroup.displayName,
}
: undefined,
administrators: {
administratorType: sql.AdministratorType.ActiveDirectory,
azureADOnlyAuthentication: Boolean(auth.azureAdOnlyAuthentication),

principalType: sql.PrincipalType.Group,
tenantId,
sid: adminGroup?.objectId,
login: adminGroup?.displayName,
},
publicNetworkAccess: network?.asPrivateLink
? sql.ServerNetworkAccessFlag.Disabled
: sql.ServerNetworkAccessFlag.Enabled,
Expand Down
29 changes: 14 additions & 15 deletions src/VNet/PrivateDns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const addARecord = ({
};

interface VnetToPrivateDnsProps extends BasicResourceArgs {
zoneName: string;
zoneName: Input<string>;
vnetId: Input<string>;
registrationEnabled?: boolean;
}
Expand All @@ -55,15 +55,16 @@ export const linkVnetToPrivateDns = ({
group,
zoneName,
vnetId,
registrationEnabled,
registrationEnabled = false,
...others
}: VnetToPrivateDnsProps) => {
return new native.network.VirtualNetworkLink(
`${name}-${zoneName}-link`,
`${name}-link`,
{
...group,
location: "global",
privateZoneName: zoneName,
registrationEnabled: registrationEnabled || false,
registrationEnabled,
virtualNetwork: { id: vnetId },
},
others,
Expand Down Expand Up @@ -103,17 +104,15 @@ export default ({
const toDnsInfo = () => ({ resourceName: name, group, id: zone.id });

if (vnetIds) {
all(vnetIds).apply((vn) =>
vn.map((id) =>
linkVnetToPrivateDns({
name,
vnetId: id,
zoneName: name,
group,
registrationEnabled: false,
dependsOn: zone,
}),
),
vnetIds.map((id) =>
linkVnetToPrivateDns({
name,
vnetId: id,
zoneName: name,
group,
registrationEnabled: false,
dependsOn: zone,
}),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/VNet/PrivateEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default ({

//Create Zone
const zone = PrivateZone({
name: `${resourceInfo?.name}.${privateDnsZoneName}`,
name: `${resourceInfo!.name}.${privateDnsZoneName}`,
group,
});

Expand All @@ -69,7 +69,7 @@ export default ({
const vnetId = getVnetIdFromSubnetId(id);
linkVnetToPrivateDns({
name: `${name}-${index}`,
zoneName: privateDnsZoneName,
zoneName: zone.name,
vnetId,
group,
dependsOn: zone.resource,
Expand Down

0 comments on commit 1b9fe7a

Please sign in to comment.