Skip to content

Commit

Permalink
Consistent naming between dev and prod
Browse files Browse the repository at this point in the history
  • Loading branch information
cadenmarchese committed Mar 18, 2024
1 parent 5115f21 commit a639a83
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions hack/devtools/deploy-shared-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ deploy_oic_dev() {
-n rp-oic \
--template-file pkg/deploy/assets/rp-oic.json \
--parameters \
"rpServicePrincipalId=$(az ad sp list --filter "appId eq '$AZURE_RP_CLIENT_ID'" --query '[].id' -o tsv)" >/dev/null
"rpServicePrincipalId=$(az ad sp list --filter "appId eq '$AZURE_RP_CLIENT_ID'" --query '[].id' -o tsv)" >/dev/null \
"storageAccountDomain=$(echo ${RESOURCEGROUP//-})"
}

deploy_aks_dev() {
Expand Down Expand Up @@ -88,7 +89,8 @@ deploy_oic_for_dedicated_rp() {
-n rp-oic \
--template-file pkg/deploy/assets/rp-oic.json \
--parameters \
"rpServicePrincipalId=$(az identity show -g $RESOURCEGROUP -n aro-rp-$LOCATION | jq -r '.["principalId"]')"
"rpServicePrincipalId=$(az identity show -g $RESOURCEGROUP -n aro-rp-$LOCATION | jq -r '.["principalId"]')" \
"storageAccountDomain=$(yq '.rps[].configuration.storageAccountDomain' dev-config.yaml | cut -d '.' -f1)"
}

deploy_env_dev_override() {
Expand Down
11 changes: 7 additions & 4 deletions pkg/deploy/assets/rp-oic.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"parameters": {
"rpServicePrincipalId": {
"type": "string"
},
"storageAccountDomain": {
"type": "string"
}
},
"resources": [
Expand All @@ -19,22 +22,22 @@
"minimumTlsVersion": "TLS1_2"
},
"location": "[resourceGroup().location]",
"name": "[concat(take(replace(resourceGroup().name, '-', ''), 21), 'oic')]",
"name": "[concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01"
},
{
"name": "[concat(concat(take(replace(resourceGroup().name, '-', ''), 21), 'oic'), '/Microsoft.Authorization/', guid(resourceId('Microsoft.Storage/storageAccounts', concat(take(replace(resourceGroup().name, '-', ''), 21), 'oic'))))]",
"name": "[concat(concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic'), '/Microsoft.Authorization/', guid(resourceId('Microsoft.Storage/storageAccounts', concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic'))))]",
"type": "Microsoft.Storage/storageAccounts/providers/roleAssignments",
"properties": {
"scope": "[resourceId('Microsoft.Storage/storageAccounts', concat(take(replace(resourceGroup().name, '-', ''), 21), 'oic'))]",
"scope": "[resourceId('Microsoft.Storage/storageAccounts', concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic'))]",
"roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')]",
"principalId": "[parameters('rpServicePrincipalId')]",
"principalType": "ServicePrincipal"
},
"apiVersion": "2018-09-01-preview",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', concat(take(replace(resourceGroup().name, '-', ''), 21), 'oic'))]"
"[resourceId('Microsoft.Storage/storageAccounts', concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic'))]"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/generator/resources_oic.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

var (
// Storage accounts must not contain dashes or be more than 24 characters
// Name it after the resource group + 'oic'
storageAccountName string = "concat(take(replace(resourceGroup().name, '-', ''), 21), 'oic')"
// Append "oidc" to the pre-existing storage account prefix.
storageAccountName string = "concat(take(substring(parameters('storageAccountDomain'), 0, indexOf(parameters('storageAccountDomain'), '.')), 21), 'oic')"
resourceTypeStorageAccount string = "Microsoft.Storage/storageAccounts"
)

Expand Down
3 changes: 3 additions & 0 deletions pkg/deploy/generator/templates_oic.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func (g *generator) oicTemplate() *arm.Template {
"rpServicePrincipalId": {
Type: "string",
},
"storageAccountDomain": {
Type: "string",
},
}

return t
Expand Down

0 comments on commit a639a83

Please sign in to comment.