https://pulumi.com logo
#general
Title
# general
b

brief-car-60542

05/24/2023, 12:08 AM
How do you depensOn a resource that is in the array? such as:
Copy code
{
      dependsOn: [
        restApiPolicys[region]
      ],
      provider: config.providers[configEnvironment] as aws.Provider,
    },
l

little-cartoon-10569

05/24/2023, 12:59 AM
So long it's a resource, it will work. Assuming that
restApiPolicys
is a variable (and not a property of the resource).
n

narrow-nightfall-92022

05/24/2023, 1:43 AM
RestapiPolicy is a Record<string, aws..policy>[]
l

little-cartoon-10569

05/24/2023, 2:16 AM
So is restApiPolicys[region] an instance of
aws.iam.Policy
? That will work. I've never see a need to depend on a Policy though. The only reason to need a Policy would be for its ARN, and that is (afaik) only ever used directly. Is it used directly in this object? We can't see the resource inputs.
n

narrow-nightfall-92022

05/24/2023, 3:24 AM
It is a list of records, which contains policy obj.
Restapi needs to deploy after the api policy
l

little-cartoon-10569

05/24/2023, 3:25 AM
So long as the resource object is what's in the dependOn array, it'll work. Is it not working?
b

brief-car-60542

05/24/2023, 4:18 AM
This is how the var is defined:
restApiPolicys: Record<string, aws.apigateway.RestApiPolicy> = {};
l

little-cartoon-10569

05/24/2023, 4:40 AM
Is it working?
b

brief-car-60542

05/24/2023, 4:41 AM
no, I can't depends it.
l

little-cartoon-10569

05/24/2023, 5:05 AM
Need more information. Error message? Unexpected behaviour? Also, a snippet of code would be good.