<!-- Love localstack? Please consider supporting our collective:
:point_right:  https://opencollective.com/localstack/donate -->

When creating an API Gateway with Lambda integration using Terraform, I am expecting the configuration to be idempotent but running `plan` immediately after `apply`ing my configuration results in the following changes:


```
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # aws_api_gateway_integration.integration will be updated in-place
  ~ resource "aws_api_gateway_integration" "integration" {
        cache_key_parameters    = []
        connection_type         = "INTERNET"
        http_method             = "GET"
        id                      = "agi-h7of9y60on-2q0jndr0cq-GET"
        integration_http_method = "GET"
        request_parameters      = {}
        request_templates       = {}
        resource_id             = "2q0jndr0cq"
        rest_api_id             = "h7of9y60on"
      ~ timeout_milliseconds    = 0 -> 29000
        type                    = "AWS_PROXY"
        uri                     = "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:000000000000:function:first_lambda_function/invocations"
    }

  # aws_api_gateway_rest_api.api will be updated in-place
  ~ resource "aws_api_gateway_rest_api" "api" {
      + api_key_source           = "HEADER"
        arn                      = "arn:aws:apigateway:eu-west-1::/restapis/h7of9y60on"
        binary_media_types       = []
        created_date             = "2020-01-26T09:26:18Z"
        execution_arn            = "arn:aws:execute-api:eu-west-1::h7of9y60on"
        id                       = "h7of9y60on"
        minimum_compression_size = -1
        name                     = "test_api"
        root_resource_id         = "tss4whwqxe"
        tags                     = {}
    }

  # aws_lambda_permission.lambda must be replaced
-/+ resource "aws_lambda_permission" "lambda" {
        action        = "lambda:InvokeFunction"
        function_name = "first_lambda_function"
      ~ id            = "AllowExecutionFromAPIGateway" -> (known after apply)
      ~ principal     = "000000000000" -> "apigateway.amazonaws.com" # forces replacement
        source_arn    = "arn:aws:execute-api:eu-west-1:123456789012:h7of9y60on/*/GET/hello"
        statement_id  = "AllowExecutionFromAPIGateway"
    }

Plan: 1 to add, 2 to change, 1 to destroy.
```

If I apply the changes, Terraform times out modifying the `aws_api_gateway_rest_api.api` resource. Below is the `docker-compose.yml` and Terraform configuration to reproduce:

docker-compose.yml:


```
version: '2.1'

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack
    ports:
      - "4567-4597:4567-4597"
      - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=${SERVICES- }
      - DEBUG=${DEBUG- }
      - DATA_DIR=${DATA_DIR- }
      - PORT_WEB_UI=${PORT_WEB_UI- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-local }
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
      - DEFAULT_REGION=eu-west-1
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
```

main.tf


```
provider "aws" {
  access_key                  = "mock_access_key"
  region                      = "eu-west-1"
  s3_force_path_style         = true
  secret_key                  = "mock_secret_key"
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  skip_requesting_account_id  = true

  endpoints {
    apigateway     = "http://localhost:4567"
    cloudformation = "http://localhost:4581"
    cloudwatch     = "http://localhost:4582"
    dynamodb       = "http://localhost:4569"
    es             = "http://localhost:4578"
    firehose       = "http://localhost:4573"
    iam            = "http://localhost:4593"
    kinesis        = "http://localhost:4568"
    lambda         = "http://localhost:4574"
    route53        = "http://localhost:4580"
    redshift       = "http://localhost:4577"
    s3             = "http://localhost:4572"
    secretsmanager = "http://localhost:4584"
    ses            = "http://localhost:4579"
    sns            = "http://localhost:4575"
    sqs            = "http://localhost:4576"
    ssm            = "http://localhost:4583"
    stepfunctions  = "http://localhost:4585"
    sts            = "http://localhost:4592"
  }
}

data "aws_caller_identity" "current" {}

data "aws_region" "current" {}

data "archive_file" "dummy" {
  type        = "zip"
  output_path = ".terraform/artifact.zip"

  source {
    filename = "dummy.py"
    content  = <<EOF
import json
def main(event, context):
    return {
        'statusCode': 200,
        'headers': {'Content-Type': 'application/json'},
        'body': json.dumps('Hello, World!')
    }
EOF
  }
}

locals {
  lambda_function_name = "first_lambda_function"
  account_id           = data.aws_caller_identity.current.account_id
  region               = data.aws_region.current.name
}

resource "aws_s3_bucket" "artifacts_bucket" {
  bucket = "artifacts-bucket"
}

resource "aws_lambda_function" "first_lambda" {
  filename      = data.archive_file.dummy.output_path
  function_name = local.lambda_function_name
  handler       = "dummy.main"
  role          = aws_iam_role.iam_for_lambda.arn
  runtime       = "python3.7"

  depends_on = [aws_iam_role.iam_for_lambda, aws_iam_role_policy_attachment.lambda_logs]
}

resource "aws_iam_role" "iam_for_lambda" {
  name = "iam_for_lambda"

  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource "aws_iam_policy" "lambda_logging" {
  name        = "lambda_logging"
  path        = "/"
  description = "IAM policy for logging from a lambda"

  policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
      ],
      "Resource": "arn:aws:logs:*:*:*",
      "Effect": "Allow"
    }
  ]
}
EOF
}

resource "aws_iam_role_policy_attachment" "lambda_logs" {
  role       = aws_iam_role.iam_for_lambda.name
  policy_arn = aws_iam_policy.lambda_logging.arn
}

resource "aws_api_gateway_rest_api" "api" {
  name = "test_api"
}

resource "aws_api_gateway_resource" "resource" {
  path_part   = "hello"
  parent_id   = aws_api_gateway_rest_api.api.root_resource_id
  rest_api_id = aws_api_gateway_rest_api.api.id
}

resource "aws_api_gateway_method" "method" {
  rest_api_id   = aws_api_gateway_rest_api.api.id
  resource_id   = aws_api_gateway_resource.resource.id
  http_method   = "GET"
  authorization = "NONE"
}

resource "aws_api_gateway_integration" "integration" {
  rest_api_id             = aws_api_gateway_rest_api.api.id
  resource_id             = aws_api_gateway_resource.resource.id
  http_method             = aws_api_gateway_method.method.http_method
  integration_http_method = "GET"
  type                    = "AWS_PROXY"
  uri                     = aws_lambda_function.first_lambda.invoke_arn
  timeout_milliseconds    = 29000
}

# Lambda
resource "aws_lambda_permission" "lambda" {
  statement_id  = "AllowExecutionFromAPIGateway"
  action        = "lambda:InvokeFunction"
  function_name = aws_lambda_function.first_lambda.function_name
  principal     = "apigateway.amazonaws.com"

  # More: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-invoke-api.html
  source_arn = "arn:aws:execute-api:${local.region}:${local.account_id}:${aws_api_gateway_rest_api.api.id}/*/${aws_api_gateway_method.method.http_method}${aws_api_gateway_resource.resource.path}"
}

resource "aws_api_gateway_deployment" "test_stage_deplyment" {
  depends_on = [aws_api_gateway_integration.integration]

  rest_api_id = aws_api_gateway_rest_api.api.id
  stage_name  = "testing"
}

output "url" {
  value = aws_api_gateway_deployment.test_stage_deplyment.invoke_url
}

output "localstack_url" {
  value = "http://localhost:4567/restapis/${aws_api_gateway_rest_api.api.id}/${aws_api_gateway_deployment.test_stage_deplyment.stage_name}/_user_request_/${aws_api_gateway_resource.resource.path_part}"
}
```

I'm not sure if this is related to #1822.



┆Issue is synchronized with this [Jira Bug](https://localstack.atlassian.net/browse/LOC-148) by [Unito](https://www.unito.io/learn-more)

uri=payload.get('uri'),
                    integration_type=payload['type'],
                    pass_through_behavior=payload.get('passthroughBehavior'),
                    request_templates=payload.get('requestTemplates') or {}
                )
                integration.create_integration_response(
                    status_code=payload.get('responses', {}).get('default', {}).get('statusCode', 200),
                    selection_pattern=None,
                    response_templates=None,
                    content_handling=None
                )
                child.resource_methods[m]['methodIntegration'] = integration
            rest_api.resources[child_id] = child
        return rest_api
    
    
    def apigateway_response_restapis_individual(self, request, full_url, headers):
        if request.method in ['GET', 'DELETE']:
            return apigateway_response_restapis_individual_orig(self, request, full_url, headers)
        self.setup_class(request, full_url, headers)
        function_id = self.path.replace('/restapis/', '', 1).split('/')[0]
        
        if self.method == 'PUT':
            body = json.loads(to_str(self.body))
            if not body.get('paths'):
                return 400, {}, ''
            rest_api = self.backend.put_rest_api(function_id, body)
            return 200, {}, json.dumps(rest_api.to_dict())
        return 400, {}, ''
    def apigateway_response_resource_methods(self, request, *args, **kwargs):