Hello Everyone, I am trying to use Pulumi with Yam...
# azure
a
Hello Everyone, I am trying to use Pulumi with Yaml file and when I try to do
pulumi preview
, I get the following error:
Copy code
Previewing update (shared.shared):
     Type                                     Name                       Plan       Info
 +   pulumi:pulumi:Stack                      svcmeshdemo-shared.shared  create
     └─ azure-native:resources:ResourceGroup  resourceGroup                         1 error


Diagnostics:
  azure-native:resources:ResourceGroup (resourceGroup):
    error: azure-native:resources:ResourceGroup resource 'resourceGroup' has a problem: 'resourceGroupName' does not match expression '^[-\w\._\(\)]+$'
My
Pulumi.yaml
file is as follows:
Copy code
name: svcmeshdemo
runtime: yaml
description: A minimal Azure Native Pulumi YAML program
config:
  env:
    type: string
    default: ${env}
  project:
    type: string
    default: ${project}
  projectShort:
    type: string
    default: ${projectShort}
  customer:
    type: string
    default: ${customer}
  customerShort:
    type: string
    default: ${customerShort}
  namePrefix:
    type: string
    default: ${customerShort}-${projectShort}
  namePrefixCleaned:
    type: string
    default: ${customerShort}${projectShort}

resources:
  # Create an Azure Resource Group
  resourceGroup:
    type: azure-native:resources:ResourceGroup
    properties:
      resourceGroupName: ${namePrefix}-${env}
      tags:
        Project: ${project}
        Environment: ${env}
        Source: Pulumi
        Customer: ${customer}
        Creator: ${customer}
Does anyone know what the problem is and how to fix it? Thanks 🙂
m
Hi @adventurous-mechanic-24805, it depends on the value of
resourceGroupName
, so on the values of
customerShort
,
projectShort
, and
env
. Somehow the resulting name is invalid. Does
env
maybe end in a
.
?
a
You maybe right. When you mention the
env
, does it take the pulumi stack environment or the
env
from
Pulumi.shared.shared.yaml
because the environment is
shared.shared
, but I want to reference it from the
Pulumi.shared.shared.yaml
whose value is
shared
m
I’m not sure where
env
is from. I’m not super familiar with Pulumi yaml and it’s actually not mentioned on https://www.pulumi.com/docs/reference/yaml/.
a
I figured out the problem. It was this part:
Copy code
${namePrefix}-${env}
I resolved it by replacing
config
with
variables
because I am reusing the variables. But, thank you anyways