great-sunset-355
07/29/2021, 7:28 AMCertificateDomainValidationOptionArgs
https://www.pulumi.com/docs/reference/pkg/aws/acm/certificate/#outputs
I'd like to be able to use it as cert_validation_option.domain_name
, etc...enough-garden-22763
07/29/2021, 2:28 PMcert: acm.Certificate
cert.domain_validation_options: Output[Sequence[CertificateDomainValidationOption]]
cert.domain_validation_options.apply(lambda x: x[0]): Output[CertificateDomainValidationOption]
domain_name = cert.domain_validation_options.apply(lambda x: x[0]).apply(lambda x: x.domain_name)
domain_name: Output[str]
Input[str]
you can now pass domain_name: Output[str]
into it as Input arguments accept Output.great-sunset-355
07/29/2021, 3:01 PMlambda x: x[0]).apply(lambda x: x.domain_name)
that my IDEs are not able to suggest the attributes of x
which is ultimately what I'm trying to achieve.
It's the lost information that bothers meenough-garden-22763
07/29/2021, 3:05 PMgreat-sunset-355
07/29/2021, 3:06 PMenough-garden-22763
07/29/2021, 3:08 PMgreat-sunset-355
07/29/2021, 3:09 PMpulumi.Output
because they can also return a dict but it is not a dict but Output[dict]
enough-garden-22763
07/29/2021, 3:15 PMgreat-sunset-355
07/29/2021, 3:15 PMOutput.future()
and await
inside an async function then scheduling the function with loop.create_task
However due to my limited experience with python async I'm not able to tell if there are any potential side effects.
It seems to be a similar case to Output.apply()
- where documentation recommends to avoid creating resources inside apply()
import pulumi
from pydantic import BaseModel
class MyZone(BaseModel):
zone_id: str
force_destroy: bool
async def fun():
ref_zone = pulumi.StackReference(stack_name)
print('lol')
result = await ref_zone.outputs.future()
print(result)
my_zone = MyZone.parse_obj(result['my_zone'])
print(my_zone)
ec2.SecurityGroup(
f"mhh{my_zone.zone_id}"
)
loop = asyncio.get_running_loop()
loop.create_task(fun())
enough-garden-22763
07/29/2021, 3:18 PMOutput[MyZone]
in the code above I think?ref_zone.outputs.apply(lambda result: MyZone.parse_obj(result['my_zone'])): Output[MyZone]
name
parameter of SecurityGroup though, that’s true. I’ll need to ask what is the recommended practice around this.async def main():
print('Hello ...')
await asyncio.sleep(1)
print('... World!')
# Python 3.7+
asyncio.run(main())
# ec2
class SecurityGroup(pulumi.CustomResource):
@overload
def __init__(__self__,
resource_name: str,
...
name: Optional[pulumi.Input[str]] = None,
...
__props__=None):
"""
# BUILT BY genResourceInitDocstring()
:param str resource_name: The name of the resource. ### this is the name as Pulumi sees it
...
:param pulumi.Input[str] name: Name of the security group. If omitted, this provider will assign a random, unique name. ### this is actual name in AWS
"""
...
great-sunset-355
07/29/2021, 3:36 PMasyncio.run
gave me error about multiple loops but will have to revisit the test later onenough-garden-22763
07/29/2021, 3:37 PMmy_zone: Output[MyZone] = ref_zone.outputs.apply(lambda result: MyZone.parse_obj(result['my_zone']))
sg = SecurityGroup(
"mhh", # pulumi name does not depend on my_zone
resource_name=my_zone.apply(lambda z: f"mhh{z.zone_id}") # but AWS name does
)
great-sunset-355
07/29/2021, 4:38 PMz.
has the attribute of z.zone_id
I'll try the similar example in C# to see if the IDE experience is somewhat different there then I'll think if there is something like that of python typhintingList[str]
you get hinted methods from that list_items[0].join()
if we could get the same experience for Output in python that would be amazing