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

orange-airport-64592

04/21/2023, 3:10 AM
Hi team. When I use
aws.apigateway.get_resource
, I want to know how to wait for a resource to be created before obtaining its attribute using Pulumi. Here is my code.
Copy code
rest_api = aws.apigateway.RestApi(
    resource_name="login",
    name="login",
    body=ApiFile("login.yaml").body,
)

# This may be failed , I think is caused by the resource had not been created
resource = aws.apigateway.get_resource(
    rest_api_id=rest_api.id,
    path="/login",     
)
b

brave-planet-10645

04/21/2023, 9:18 AM
Is this in the same Pulumi program?
o

orange-airport-64592

04/23/2023, 2:57 AM
yes, it is . My objective is: I need to create an API for API Gateway using a standard OpenAI file that without the x-amazon extension, and after it is successfully created, I will use Pulumi to retrieve the resources of the created API and add integrations to each resource using the Pulumi API.
b

billowy-army-68599

04/23/2023, 2:40 PM
why arer you using
get_resource
? it returns the same properties as the creation of the resource
r

rhythmic-secretary-1287

04/23/2023, 11:54 PM
Im guessing you are in a similar situation than
initialize a database
described here https://www.pulumi.com/blog/deploying-mysql-schemas-using-dynamic-providers/
o

orange-airport-64592

04/24/2023, 9:05 AM
@billowy-army-68599 good question! Actually, I created the
apigateway
API
using an
openapi
file, as shown in my previous code. so I cannot access
api.resource
from the returned API object because it was not created using the method
aws.apigateway.resource()
. Next, I need to create an integration for a specific resource, like this:
Copy code
aws.apigateway.integration(
    rest_api=rest_api,       resource=HERE_I_NEED_A_RESOURCE_OBJECT,
    xxx,
)
@rhythmic-secretary-1287 I am reading you page, when I finshed , I will reply you
Hi, all , I found a simple way to do this , just use
apigateway.get_resource_output
instead of
apigateway.get_resource
, but this docs don’t make this clear.
Copy code
rest_api = aws.apigateway.RestApi(
    resource_name="login",
    name="login",
    body=ApiFile("login.yaml").body,
)

resource = aws.apigateway.get_resource_output(
    rest_api_id=rest_api.id,
    path="/login",     
)
3 Views