Skip to content

Instantly share code, notes, and snippets.

@Bharathkumarraju
Forked from 1oglop1/__main__.py
Created July 12, 2021 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bharathkumarraju/005c4fc128456939892b22470396225a to your computer and use it in GitHub Desktop.
Save Bharathkumarraju/005c4fc128456939892b22470396225a to your computer and use it in GitHub Desktop.
Pulumi component resources
import pulumi
from pulumi_aws import s3
from pulumi import Output, Input, ResourceOptions, ComponentResource, set, get
import time
import json
from pydantic import BaseModel
async def w2():
"""Awaitable simulating output"""
print("waiting")
time.sleep(2)
return "222222"
class FirstComponent(ComponentResource):
"""First component."""
def __init__(
self,
name: str,
):
super().__init__(
"custom:first",
name,
None,
opts=ResourceOptions(additional_secret_outputs=['password']),
)
# setting a property here
self.o1 = Output.from_input(w2())
self.register_outputs(
{
"w2": self.o1,
"password": self.o1.apply(lambda x: x)
}
)
class SecondComponent(ComponentResource):
"""Second component."""
def __init__(
self,
name: str,
password: Input[str]
):
super().__init__(
"custom:second",
name,
None,
opts=ResourceOptions(additional_secret_outputs=['password']),
)
self.password = password
self.register_outputs(
{
"password": self.password
}
)
first_component = FirstComponent(name='first')
print(first_component.o1)
first_component.o1.apply(print)
second_component = SecondComponent(name='second', password='Secret')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment