apiVersion: xl/v2
kind: Blueprint

metadata:
  name: dictionaries-and-secret-stores
  description: |
    A single Linux VM using Terraform
  author: XebiaLabs
  version: 2.0
  instructions: Please read xebialabs/USAGE-dictionaries-and-secret-stores.md
  suppressXebiaLabsFolder: true
spec:
  parameters:
  - name: AppName
    type: Input
    prompt: What do you want to name the application?
    validate: !expr "regex('^[a-zA-Z][\\\\w-]{1,29}[\\\\w]$', AppName)"

  - name: AzureVMName
    type: Input
    prompt: "Enter a name to give the VM:"

  - name: AzureVMSize
    type: Select
    prompt: "Select a VM size:"
    options:
    - label: 1 vCPU, 3.5 GiB RAM
      value: Standard_DS1_v2
    - label: 2 vCPUs, 7 GiB RAM
      value: Standard_DS2_v2
    - label: 4 vCPUs, 14 GiB RAM
      value: Standard_DS3_v2
    - label: 8 vCPUs, 28 GiB RAM
      value: Standard_DS4_v2
    - label: 16 vCPUs, 56 GiB RAM
      value: Standard_DS5_v2

  - name: AzureOSUsername
    type: Input
    prompt: "Enter the username that will log into the VM:"
    default: "azureuser"

  - name: CredentialsSource
    type: Select
    prompt: "Select a secret store for the credentials:"
    options:
    - label: "Max security - external secret store that you have configured (HashiCorp Vault or CyberArk Conjur)"
      value: secret-store
    - label: "Med security - encrypted dictionary to be created within XL Deploy"
      value: dictionary

  includeAfter:
  - blueprint: fragments/secret-store
    includeIf: !expr "CredentialsSource == 'secret-store'"
    parameterOverrides:
    - name: SecretStoreDirectoryName
      value: !expr "AppName"
    - name: SecretStoreKeys
      value: "azure.clientsecret,azure.ospassword,azure.resourcegroup"

  - blueprint: fragments/dictionary
    includeIf: !expr "CredentialsSource == 'dictionary'"
    parameterOverrides:
    - name: DictionaryDirectoryName
      value: !expr "AppName"
    - name: DictionaryKeys
      value: "azure.clientsecret,azure.ospassword,azure.resourcegroup"

  - blueprint: fragments/azure-resourcegroup-location
    parameterOverrides:
    - name: PromptForResourceGroup
      value: false

  - blueprint: fragments/azure-credentials
    parameterOverrides:
    - name: PromptForClientSecret
      value: !expr "false"

  - blueprint: xl-devops-platform
    parameterOverrides:
    - name: UseXLDeploy
      value: !expr "true"
    - name: UseXLRelease
      value: !expr "true"
    - name: UseJenkins
      value: !expr "false"
    - name: UseDockerProxy
      value: !expr "false"

  files:
  # XebiaLabs
  - path: xebialabs.yaml.tmpl
  - path: README.md
  - path: xebialabs/USAGE-dictionaries-and-secret-stores-dictionary.md.tmpl
    writeIf: !expr "CredentialsSource == 'dictionary'"
    renameTo: xebialabs/USAGE-dictionaries-and-secret-stores.md.tmpl
  - path: xebialabs/USAGE-dictionaries-and-secret-stores-secret-store.md.tmpl
    writeIf: !expr "CredentialsSource == 'secret-store'"
    renameTo: xebialabs/USAGE-dictionaries-and-secret-stores.md.tmpl
  - path: xebialabs/xld-dictionaries-and-secret-stores-applications.yaml.tmpl
  - path: xebialabs/xld-dictionaries-and-secret-stores-environments.yaml.tmpl
  - path: xebialabs/xld-dictionaries-and-secret-stores-infrastructure.yaml.tmpl
  - path: xebialabs/xlr-dictionaries-and-secret-stores-pipeline-ci-cd.yaml.tmpl
  - path: xebialabs/xlr-dictionaries-and-secret-stores-pipeline-destroy.yaml.tmpl
  # Terraform
  - path: terraform/main.tf
  - path: terraform/outputs.tf
  - path: terraform/variables.tf
