from pulumi import Input, Output, export from pulumi.dynamic import Resource, ResourceProvider, CreateResult from enum import Enum from typing import Optional, Union class RubberTreeVariety(str, Enum): BURGUNDY = "Burgundy" RUBY = "Ruby" TINEKE = "Tineke" class Farm(str, Enum): PLANTS_R_US = "Plants'R'Us" PULUMI_PLANTERS_INC = "Pulumi Planters Inc." current_id = 0 class PlantProvider(ResourceProvider): def create(self, inputs): global current_id current_id += 1 return CreateResult(str(current_id), inputs) class Tree(Resource): type: Output[RubberTreeVariety] farm: Optional[Output[str]] def __init__(self, name: str, type: Input[RubberTreeVariety], farm: Optional[Input[str]]): self.type = type self.farm = farm super().__init__(PlantProvider(), name, {"type": type, "farm": farm}) # Create a resource with input object. tree = Tree("myTree", type=RubberTreeVariety.BURGUNDY, farm=Farm.PULUMI_PLANTERS_INC) export("myTreeType", tree.type) export("myTreeFarmChanged", tree.farm.apply(lambda x: x + "foo")) export("mySentence", Output.all(tree.type, tree.farm).apply(lambda args: f"My {args[0].value} Rubber tree is from {args[1]}"))