creamy-monkey-35142
01/03/2023, 3:25 AMechoing-dinner-19531
01/03/2023, 10:38 AMcreamy-monkey-35142
01/03/2023, 10:42 AMoutput
, I’m thinking 2 way to do it
• use id from output or Pulumi state file
• create our own id list while running Pulumi with
accessGroup = cloudflare.AccessGroup(**v)
return_id = accessGroup.id.apply(lambda a: print(f"{a}"))
print(return_id)
and result is
11f9b35b-9174-4df8-ab2a-redacted
d1478109-50f2-4aed-b375-redacted
ec03461c-158e-49a1-b318-redacted
but I don’t know how to assign it as variable, tried with
return_id = accessGroup.id.apply(lambda a: a)
but it return
Calling __str__ on an Output[T] is not supported.
To get the value of an Output[T] as an Output[str] consider:
1. o.apply(lambda v: f"prefix{v}suffix")
See <https://pulumi.io/help/outputs> for more details.
This function may throw in a future version of Pulumi.
echoing-dinner-19531
01/03/2023, 10:59 AMcreamy-monkey-35142
01/03/2023, 2:23 PMaccessGroup = cloudflare.AccessGroup(**v)
print(accessGroup.id)
pulumi.export("group_id", accessGroup.id)
and result is
Calling __str__ on an Output[T] is not supported.
To get the value of an Output[T] as an Output[str] consider:
1. o.apply(lambda v: f"prefix{v}suffix")
See <https://pulumi.io/help/outputs> for more details.
This function may throw in a future version of Pulumi.
Outputs:
+ group_id: "5d624102-5a12-4ac4-a3ea-db0ec95df84a"
id
from group name, it’ll help user can define policy without find somewhere for group iddef set_grous_output(self, key, value):
self.groups_output[key] = value
def get_groups_output(self, key):
if key in self.groups_output:
return self.groups_output[key]
else:
return None
it’ll define group with name & id and id at this time is in memory like
[<pulumi.output.Output object at 0x103e68130>]
and input resource before create Access Policy will be
Diagnostics:
pulumi:pulumi:Stack (pulum-redacted):
{'application_id': <pulumi.output.Output object at 0x10a0c8dc0>, 'account_id': 'redacted', 'resource_name': 'bypass', 'name': 'bypass', 'decision': 'bypass', 'precedence': 1, 'includes': [<pulumi_cloudflare._inputs.AccessPolicyIncludeArgs object at 0x10a0a7af0>]}
cloudflare.AccessGroup
first to have list, what I expected is I can get group id
from state file or somewhere official than write our own functionechoing-dinner-19531
01/03/2023, 3:01 PMpulumi stack export
) it's just JSON should be pretty easy to understand. But you've got the id its just wrapped in an output, but you can save that from inside the apply.
Note that it has to be an output because your program runs at preview time, and at preview time when creating a new AccessGroup there is no id! You have to handle that case, Output<T> handles it for you by just not running apply when the value isn't actually available.creamy-monkey-35142
01/03/2023, 3:12 PMpulumi stack export
result in python code? should I do it with pulumi automation
and hope you can share me an exampleechoing-dinner-19531
01/03/2023, 3:51 PMexport_stack
function on the workspace type in the python automation api. That gives you back an object with a deployment: Optional[Mapping[str, Any]]
field. If you look through that mapping the id info would be in there somewhere. But again you have the id in your program you just need to access it within the Apply block.creamy-monkey-35142
01/03/2023, 3:56 PM