sparse-intern-71089
10/31/2023, 6:43 PMancient-policeman-24615
11/02/2023, 12:47 AMerr
is non-nil, then you are already using ApplyT
correctly:
policyDocument := saml.Arn.ApplyT(yourFunction)
If you want to handle the error and keep going, you will need to do so inside the `ApplyT`:
policyDocument := saml.Arn.ApplyT(func(arn string) (*iam.GetPolicyDocumentResult, error) {
doc, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
Statements: []iam.GetPolicyDocumentStatement{
{
Principals: []iam.GetPolicyDocumentStatementPrincipal{
{
Type: "Federated",
Identifiers: []string{arn},
},
},
},
},
if err != nil {
return defaultDocument(arn)
}
return doc
})
})
The first option is more common in Pulumi programs, but both are available.