How can I resolve "HTTP 403 Forbidden" errors when invoking my API with cross-account IAM authentication for API Gateway?
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.
"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.ResolutionREST APIsFor 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:{  "Version": "2012-10-17",  "Statement": [    {      "Effect": "Allow",      "Action": [        "execute-api:Invoke",        "execute-api:ManageConnections"      ],      "Resource": "arn:aws:execute-api:us-east-1:111111111:AB12CDEF34/*/*/*"    }  ]}To allow the IAM user for account B in account A to invoke cross-account access, use a resource policy similar to the following:{  "Version": "2012-10-17",  "Statement": [    {      "Effect": "Allow",      "Principal": {        "AWS": "arn:aws:iam::999999999:user/User1"      },      "Action": "execute-api:Invoke",      "Resource": "arn:aws:execute-api:us-east-1:111111111:AB12CDEF34/stage/*/*"    }  ]}For more information, see How do I activate IAM authentication for API Gateway REST APIs?HTTP APIsFor 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?Related informationAPI Gateway resource policy examplesFollow"