Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment yaml arg type hints don't indicate all accepted inputs #448

Open
stooj opened this issue Nov 22, 2024 · 0 comments
Open

Environment yaml arg type hints don't indicate all accepted inputs #448

stooj opened this issue Nov 22, 2024 · 0 comments
Labels
kind/enhancement Improvements or new features
Milestone

Comments

@stooj
Copy link

stooj commented Nov 22, 2024

What happened?

The docs and type hints state that the Environment resource expects pulumi.Asset which cannot handle outputs.

This means you can't have outputs in the yaml.

If you ignore the type hints, you can input an output (see example below) and it works fine but breaks type checking. Could you please check and update the type hints?

Example

def callback(arg):
    data = {
        'values': {
            'root': {
                'cloud-config': {
                    'foo': arg,
                },
            },
        },
    }
    return yaml.safe_dump(data)

# aws_cloud.testexport is a random aws resource

Environment(
    'public',
    organization=pulumi.get_organization(),
    project=pulumi.get_project(),
    name='public',
    yaml=aws_cloud.testexport.arn.apply(callback),
)

Additional context

Here's a version that works and gets type checked successfully:

data = pulumi.Output.from_input(
    {
        'values': {
            'root': {
                'cloud-config': {
                    'foo': aws_cloud.testexport.arn,
                },
            },
        },
    }
).apply(lambda x: pulumi.StringAsset(yaml.safe_dump(x)))


Environment(
    'public',
    organization=pulumi.get_organization(),
    project=pulumi.get_project(),
    name='public',
    yaml=data,
)

Nevertheless it seems to accept Input[str] for the yaml arg as well, but the type hints don't indicate that. Therefore I'd expect the wrapping into pulumi.StringAsset would be unnecessary if the type hints were extended.

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@stooj stooj added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 22, 2024
@cleverguy25 cleverguy25 removed the needs-triage Needs attention from the triage team label Dec 1, 2024
@cleverguy25 cleverguy25 added this to the 0.114 milestone Dec 1, 2024
@komalali komalali added kind/enhancement Improvements or new features and removed kind/bug Some behavior is incorrect or out of spec labels Dec 2, 2024
@komalali komalali modified the milestones: 0.114, 0.115 Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

3 participants