Hi team. When I use `aws.apigateway.get_resource`...
# python
o
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
Is this in the same Pulumi program?
o
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
why arer you using
get_resource
? it returns the same properties as the creation of the resource
r
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
@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",     
)