API Gateway Usage Plan: NotFoundException: Invalid API Stage

Hi everybody,

Hope you can help me out.
I configured our AWS API Gateway with Terraform using remote S3 states. It’s working great but when i change the stagename I have to run Terraform twice to make the changes.
After the first run i get:
API Gateway Usage Plan: NotFoundException: Invalid API Stage

I have the following code:
resource “aws_api_gateway_stage” “apiStage” {
stage_name = var.aws_stageName
rest_api_id = aws_api_gateway_rest_api.api.id
deployment_id = aws_api_gateway_deployment.apiDeployment.id
}

resource “aws_api_gateway_usage_plan” “apiUsagePlan” {
name = var.aws_domainName
description = “${var.aws_domainName} usage plan”

api_stages {
    api_id = aws_api_gateway_rest_api.api.id
    stage = aws_api_gateway_stage.apiStage.stage_name
}

}

When i check the AWS webconsole I can see the stage is changed.
When running again there are no problems and the usage plan is changed.
I already tried to add a depends_on to the aws_api_gateway_usage_plan resource but that didn’t help.

What else can I try?