https://pulumi.com logo
#python
Title
# python
f

few-pillow-1133

03/12/2024, 11:12 AM
Hi How can we use InvokeOptions to associate a dependent resource Using
opts=ResourceOptions(depends_on=[xxx])
seems to be giving a new type of error ``TypeError: Expected opts2 to be a InvokeOptions instance``
a

adventurous-butcher-54166

03/12/2024, 11:37 AM
What is it that you're passing in as xxx? Are you by any chance using
ResourceOptions.merge(opts1=x, opts2=y)
somewhere?
f

few-pillow-1133

03/12/2024, 11:49 AM
Nope ... trying to get a resource, and was thinking of using the depends_on flag in the ResourceOption before the resource is fetched
a

adventurous-butcher-54166

03/12/2024, 11:50 AM
Can you share how you're getting the resource?
f

few-pillow-1133

03/12/2024, 11:51 AM
Copy code
lambda args: aws.iam.get_policy_document(
    version='2012-10-17',
    # version='2008-10-17',
    policy_id='PolicyForCloudFrontPrivateContent',
    statements=[
        aws.iam.GetPolicyDocumentStatementArgs(
            sid=1,
            effect='Allow',
            actions=["s3:GetObject"],
            resources=[f'{args[0]}/*'],
            principals=[
                aws.iam.GetPolicyDocumentStatementPrincipalArgs(
                    type='AWS',
                    identifiers=[args[1].iam_arn],
                )
            ]
        )
    ],
    opts=ResourceOptions(depends_on=[cf])
)
cf
is CloudFront Resource in this case
a

adventurous-butcher-54166

03/12/2024, 12:08 PM
opts for that getter isn't actually a ResourceOption but InvokeOption - which don't have depends_on https://www.pulumi.com/registry/packages/aws/api-docs/iam/getpolicydocument/ See feature request issue: https://github.com/pulumi/pulumi/issues/14243
2 Views