pulumi-kubernetes icon indicating copy to clipboard operation
pulumi-kubernetes copied to clipboard

Add support for asset (StringAsset) as file parameter to kubernetes.yaml.v2.ConfigFile

Open ecerulm opened this issue 6 months ago • 0 comments

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

It would be nice if kubernetes.yaml.v2.ConfigFile would allow assets (specifically pulumi.StringAsset) to be passed in the file parameter.

that way I could have an output that render yaml via jinja2 and returns an StringAsset and pass it to ConfigFile like this

config_file = pulumi.Output.all(arg1=resource1.arn, arg2=resource2.arn).apply(lambda args: pulumi.StringAsset(template.render(args)))

# https://www.pulumi.com/registry/packages/kubernetes/api-docs/yaml/v2/configfile/#kubernetes-yaml-v2-configfile
kubernetes.yaml.v2.ConfigFile(
    "test",
    file=config_file,
    opts=pulumi.ResourceOptions(
        provider=kubernetes_provider,
    ),
)

the above code now raises

 Exception: setting args: copying input "file": expected a pulumi.String, got a asset

To me there are two possible solutions

  • allow file= to be a file-like object , or StringAsset in addition to the str (file-path)
  • introduce a new parameter to ConfigFile like content= where you can pass the computed manifest
  • Add a new concept like kubernetes.yaml.v2.Manifest() where we can pass the manifest content without having a file (allowing the manifest content to be a computed string )

Affected area/feature

ecerulm avatar Aug 16 '24 21:08 ecerulm