I called my Amazon API Gateway API with a cross-account AWS Identity and Access Management (IAM) entity (user or role). I get an "HTTP 403 Forbidden" error.
For accessing API Gateway REST APIs, turn on IAM authentication for an API method in the API Gateway console. Then, use IAM policies and resource policies to designate permissions for your API's users.
Make sure that the cross-account IAM entity has permissions to invoke the API and is allowed access in the resource policy.
In this example, the REST API for account A 111111111 has IAM authentication enabled. User1 tries to invoke from account B 999999999. User1 in account B has the following IAM policy attached:
To allow the IAM user for account B in account A to invoke cross-account access, use a resource policy similar to the following:
For more information, see How do I activate IAM authentication for API Gateway REST APIs?
For accessing API Gateway HTTP APIs, you can use the sts:AssumeRole API action to assume a role for the HTTP API account. The assumed role provides temporary security credentials that can be used to invoke the HTTP API in another account.
Make sure that the temporary security credentials used to invoke the HTTP API are correct and not expired.
For more information, see How can I provide cross-account IAM authorization for API Gateway HTTP APIs?
API Gateway resource policy examples