cyberark / pas-on-cloud

CyberArk Privileged Access Security on Cloud
Other
60 stars 63 forks source link

Template parameters with spaces in the name can't be used in CI\CD pipelines #278

Closed afridrikh closed 2 years ago

afridrikh commented 3 years ago

Summary

Azure ARM template consists of parameters with spaces in the parameter name. Azure pipeline doesn't support "multi word" parameter name and doesn't allow to override such parameters. The recommendation is to remove spaces from the parameter's names or replace with "_" sign.

Additional details - https://stackoverflow.com/questions/58629448/override-parameter-with-a-space-in-the-parameter-name

Steps to Reproduce

Create a base pipeline in Azure and add AzureResourceManagerTemplateDeployment task:

task: AzureResourceManagerTemplateDeployment@3 inputs: deploymentScope: 'Resource Group' azureResourceManagerConnection: 'Subscription-Name' subscriptionId: '123456-0ec1-4a4c-8eba-1bd12947485d' action: 'Create Or Update Resource Group' resourceGroupName: 'PAMaaS-CorePAS-RG' location: 'North Europe' templateLocation: 'URL of the file' csmFileLink: 'https://raw.githubusercontent.com/cyberark/pas-on-cloud/master/azure/pas-full-network.json' overrideParameters: '- "User Access CIDR" "10.2.0.0/24" - "Administrative Access CIDR" "10.2.0.0/24"' deploymentMode: 'Incremental'

Expected Results

Expected result that the template is deployed with custom values for User and Administrative VNET

Actual Results (including error logs, if applicable)

Deployment failed:

`` ARM Service Connection deployment scope - Subscription Checking if the following resource group exists: PAMaaS-CorePAS-RG. Resource group exists: true. Creating deployment parameters. There was an error while overriding '' parameter because of 'TypeError: Cannot read property 'type' of undefined', make sure it follows JavaScript Object Notation (JSON) There was an error while overriding '' parameter because of 'TypeError: Cannot read property 'type' of undefined', make sure it follows JavaScript Object Notation (JSON) There was an error while overriding '' parameter because of 'TypeError: Cannot read property 'type' of undefined', make sure it follows JavaScript Object Notation (JSON) There was an error while overriding '' parameter because of 'TypeError: Cannot read property 'type' of undefined', make sure it follows JavaScript Object Notation (JSON) Starting template validation. Deployment name is pas-full-network-20210521-101823-f374 There were errors in your deployment. Error code: InvalidDeploymentParameterKey.

[error]One of the deployment parameters has an empty key. Please see https://aka.ms/resource-manager-parameter-files for details.

[warning]Validation errors were found in the Azure Resource Manager template. This can potentially cause template deployment to fail. Task failed while creating or updating the template deployment.. Please follow https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax

Starting Deployment. Deployment name is pas-full-network-20210521-101823-f374 There were errors in your deployment. Error code: InvalidDeploymentParameterKey.

[error]One of the deployment parameters has an empty key. Please see https://aka.ms/resource-manager-parameter-files for details.

[error]Check out the troubleshooting guide to see if your issue is addressed: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting

[error]Task failed while creating or updating the template deployment.

Finishing: AzureResourceManagerTemplateDeployment ``

Reproducible

Version/Tag number

Not relevant

Environment setup

Not relevant

Additional Information

pelegor commented 2 years ago

Hi, The documentation does not state Azure Pipeline as a supported platform. If you wish to use the given template with other solutions that differ from the documentation, sadly you'd have to change the parameter names to suit the required demands specifically.