Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/deploy/assets/gateway-production-parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
"vmssCleanupEnabled": {
"value": true
},
"vmssIpTags": {
"value": []
},
"vmssIpTagsDisabledRegions": {
"value": []
},
"vmssName": {
"value": ""
}
Expand Down
13 changes: 12 additions & 1 deletion pkg/deploy/assets/gateway-production.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
"type": "bool",
"defaultValue": true
},
"vmssIpTags": {
"type": "array",
"defaultValue": []
},
"vmssIpTagsDisabledRegions": {
"type": "array",
"defaultValue": []
},
"vmssName": {
"type": "string"
}
Expand Down Expand Up @@ -271,7 +279,10 @@
},
"primary": true,
"publicIPAddressConfiguration": {
"name": "gateway-vmss-pip"
"name": "gateway-vmss-pip",
"properties": {
"ipTags": "[if(or(contains(parameters('vmssIpTagsDisabledRegions'), resourceGroup().location), equals(length(parameters('vmssIpTags')), 0)), createArray(), createArray(createObject('ipTagType', parameters('vmssIpTags')[0].type, 'tag', parameters('vmssIpTags')[0].value)))]"
}
},
"loadBalancerBackendAddressPools": [
{
Expand Down
8 changes: 8 additions & 0 deletions pkg/deploy/assets/rp-development.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
},
"rpServicePrincipalId": {
"type": "string"
},
"vmssIpTags": {
"type": "array",
"defaultValue": []
},
"vmssIpTagsDisabledRegions": {
"type": "array",
"defaultValue": []
}
},
"resources": [
Expand Down
6 changes: 6 additions & 0 deletions pkg/deploy/assets/rp-production-parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@
"vmssCleanupEnabled": {
"value": true
},
"vmssIpTags": {
"value": []
},
"vmssIpTagsDisabledRegions": {
"value": []
},
"vmssName": {
"value": ""
}
Expand Down
13 changes: 12 additions & 1 deletion pkg/deploy/assets/rp-production.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@
"type": "bool",
"defaultValue": true
},
"vmssIpTags": {
"type": "array",
"defaultValue": []
},
"vmssIpTagsDisabledRegions": {
"type": "array",
"defaultValue": []
},
"vmssName": {
"type": "string"
}
Expand Down Expand Up @@ -438,7 +446,10 @@
},
"primary": true,
"publicIPAddressConfiguration": {
"name": "rp-vmss-pip"
"name": "rp-vmss-pip",
"properties": {
"ipTags": "[if(or(contains(parameters('vmssIpTagsDisabledRegions'), resourceGroup().location), equals(length(parameters('vmssIpTags')), 0)), createArray(), createArray(createObject('ipTagType', parameters('vmssIpTags')[0].type, 'tag', parameters('vmssIpTags')[0].value)))]"
}
},
"loadBalancerBackendAddressPools": [
{
Expand Down
8 changes: 8 additions & 0 deletions pkg/deploy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ type Configuration struct {
SubscriptionResourceGroupLocation *string `json:"subscriptionResourceGroupLocation,omitempty" value:"required"`
VMSize *string `json:"vmSize,omitempty" value:"required"`
VMSSCleanupEnabled *bool `json:"vmssCleanupEnabled,omitempty"`
VmssIpTags []IPTag `json:"vmssIpTags,omitempty"`
VmssIpTagsDisabledRegions []string `json:"vmssIpTagsDisabledRegions,omitempty"`
OIDCStorageAccountName *string `json:"oidcStorageAccountName,omitempty" value:"required"`
OtelAuditQueueSize *string `json:"otelAuditQueueSize,omitempty" value:"required"`
MsiRpEndpoint *string `json:"msiRpEndpoint,omitempty" value:"required"`
Expand All @@ -118,6 +120,12 @@ type CosmosDBConfiguration struct {
GatewayProvisionedThroughput int `json:"gatewayProvisionedThroughput,omitempty"`
}

// IPTag represents an IP tag configuration for Azure resources
type IPTag struct {
Type string `json:"type,omitempty"`
Value string `json:"value,omitempty"`
}

// GetConfig return RP configuration from the file
func GetConfig(path, location string) (*RPConfig, error) {
data, err := os.ReadFile(path)
Expand Down
6 changes: 6 additions & 0 deletions pkg/deploy/deploy_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ func (d *deployer) DeployGateway(ctx context.Context) error {
parameters.Parameters["vmssName"] = &arm.ParametersParameter{
Value: d.version,
}
parameters.Parameters["vmssIpTags"] = &arm.ParametersParameter{
Value: d.config.Configuration.VmssIpTags,
}
parameters.Parameters["vmssIpTagsDisabledRegions"] = &arm.ParametersParameter{
Value: d.config.Configuration.VmssIpTagsDisabledRegions,
}
parameters.Parameters["azureCloudName"] = &arm.ParametersParameter{
Value: d.env.Environment().ActualCloudName,
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/deploy/deploy_rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func (d *deployer) DeployRP(ctx context.Context) error {
parameters.Parameters["vmssName"] = &arm.ParametersParameter{
Value: d.version,
}
parameters.Parameters["vmssIpTags"] = &arm.ParametersParameter{
Value: d.config.Configuration.VmssIpTags,
}
parameters.Parameters["vmssIpTagsDisabledRegions"] = &arm.ParametersParameter{
Value: d.config.Configuration.VmssIpTagsDisabledRegions,
}
parameters.Parameters["keyvaultDNSSuffix"] = &arm.ParametersParameter{
Value: d.env.Environment().KeyVaultDNSSuffix,
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/deploy/generator/resources_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ func (g *generator) gatewayVMSS() *arm.Resource {
Primary: pointerutils.ToPtr(true),
PublicIPAddressConfiguration: &mgmtcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: pointerutils.ToPtr("gateway-vmss-pip"),
VirtualMachineScaleSetPublicIPAddressConfigurationProperties: &mgmtcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
IPTags: &[]mgmtcompute.VirtualMachineScaleSetIPTag{},
},
},
LoadBalancerBackendAddressPools: &[]mgmtcompute.SubResource{
{
Expand Down
3 changes: 3 additions & 0 deletions pkg/deploy/generator/resources_rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ func (g *generator) rpVMSS() *arm.Resource {
Primary: pointerutils.ToPtr(true),
PublicIPAddressConfiguration: &mgmtcompute.VirtualMachineScaleSetPublicIPAddressConfiguration{
Name: pointerutils.ToPtr("rp-vmss-pip"),
VirtualMachineScaleSetPublicIPAddressConfigurationProperties: &mgmtcompute.VirtualMachineScaleSetPublicIPAddressConfigurationProperties{
IPTags: &[]mgmtcompute.VirtualMachineScaleSetIPTag{},
},
},
LoadBalancerBackendAddressPools: &[]mgmtcompute.SubResource{
{
Expand Down
2 changes: 2 additions & 0 deletions pkg/deploy/generator/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func (g *generator) templateFixup(t *arm.Template) ([]byte, error) {
b = bytes.ReplaceAll(b, []byte(`"throughput": `+strconv.Itoa(cosmosDbGatewayProvisionedThroughputHack)), []byte(`"throughput": "[parameters('cosmosDB').gatewayProvisionedThroughput]"`))
// pickZones doesn't work for regions that don't have zones. We have created param nonZonalRegions in both rp and gateway and set default values to include all those regions. It cannot be passed in-line to contains function, has to be created as an array in a parameter :(
b = bytes.ReplaceAll(b, []byte(`"zones": []`), []byte(`"zones": "[if(contains(parameters('nonZonalRegions'),toLower(replace(resourceGroup().location, ' ', ''))),'',pickZones('Microsoft.Network', 'publicIPAddresses', resourceGroup().location, 3))]"`))
// IP tags conditional logic: if region is disabled OR no IP tags configured, use empty array, otherwise use configured tags
b = bytes.ReplaceAll(b, []byte(`"ipTags": []`), []byte(`"ipTags": "[if(or(contains(parameters('vmssIpTagsDisabledRegions'), resourceGroup().location), equals(length(parameters('vmssIpTags')), 0)), createArray(), createArray(createObject('ipTagType', parameters('vmssIpTags')[0].type, 'tag', parameters('vmssIpTags')[0].value)))]"`))
b = bytes.ReplaceAll(b, []byte(`"routes": []`), []byte(`"routes": "[parameters('routes')]"`))

if g.production {
Expand Down
8 changes: 8 additions & 0 deletions pkg/deploy/generator/templates_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func (g *generator) gatewayTemplate() *arm.Template {
"gatewayServicePrincipalId",
"gatewayVmSize",
"gatewayVmssCapacity",
"vmssIpTags",
"vmssIpTagsDisabledRegions",
"keyvaultDNSSuffix",
"keyvaultPrefix",
"mdmFrontendUrl",
Expand Down Expand Up @@ -61,6 +63,12 @@ func (g *generator) gatewayTemplate() *arm.Template {
case "gatewayVmssCapacity":
p.Type = "int"
p.DefaultValue = 3
case "vmssIpTags":
p.Type = "array"
p.DefaultValue = []interface{}{}
case "vmssIpTagsDisabledRegions":
p.Type = "array"
p.DefaultValue = []string{}
case "vmssCleanupEnabled":
p.Type = "bool"
p.DefaultValue = true
Expand Down
9 changes: 9 additions & 0 deletions pkg/deploy/generator/templates_rp.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func (g *generator) rpTemplate() *arm.Template {
"fpServicePrincipalId",
"rpServicePrincipalId",
"globalDevopsServicePrincipalId",
"vmssIpTags",
"vmssIpTagsDisabledRegions",
}
if g.production {
params = append(params,
Expand Down Expand Up @@ -124,6 +126,12 @@ func (g *generator) rpTemplate() *arm.Template {
p.Type = "array"
case "miseValidAppIDs":
p.Type = "array"
case "vmssIpTags":
p.Type = "array"
p.DefaultValue = []interface{}{}
case "vmssIpTagsDisabledRegions":
p.Type = "array"
p.DefaultValue = []string{}
case "nonZonalRegions":
p.Type = "array"
p.DefaultValue = []string{
Expand Down Expand Up @@ -156,6 +164,7 @@ func (g *generator) rpTemplate() *arm.Template {

if g.production {
t.Variables = map[string]interface{}{

"rpCosmoDbVirtualNetworkRules": &[]mgmtdocumentdb.VirtualNetworkRule{
{
ID: pointerutils.ToPtr("[resourceId('Microsoft.Network/virtualNetworks/subnets', 'rp-vnet', 'rp-subnet')]"),
Expand Down
Loading