Hi all, aws-native datazone is prefixing the proj...
# python
d
Hi all, aws-native datazone is prefixing the project.id with the domain and a pipe, such as: <domain.id>|<project.id> How can i split these so i can get the raw project.id to pass it to other resource-properties? I tried the str-class but it complained about: ValueError: unexpected input of type TrimPrefixResult for environment_profile_identifier in Environment
a
If not, make sure you're passing in the
TrimPrefixResult.result
output and not the
TrimPrefixResult
object
d
The following code:
Copy code
datazone_bank_project_konsument.aws_id.apply(lambda aws_id: print('Project.aws_id:', aws_id))
datazone_bank_project_konsument.id.apply(lambda id: print('Project.id:', id))
datazone_bank_domain.id.apply(lambda id: print('LOG Domain.id:', id))
returned
Copy code
LOG Domain.id: dzd_62uq1o7u4q0tfv
    Project.id: dzd_62uq1o7u4q0tfv|aonq6vkkxwixor
    Project.aws_id: None
So the
project.aws_id
is unset
a
Ok, but does using
.result
help?
d
Ahh, that worked perfectly! Thanks you very much for your help @adventurous-butcher-54166!
I was able to do:
Copy code
project_identifier=pstr.trim_prefix(string=datazone_bank_project_produzent.id,prefix=pulumi.Output.concat(datazone_bank_domain.id,'|')).result,
a
A potentially simpler approach, which doesn't require the pulumi-str provider:
Copy code
project_identifier: Output[str] = project.id.apply(lambda id: id.split("|")[1])
d
Thats beautifully concise and works liek a charm, thanks!