Terraform-provider-aws: Error creating API Gateway: BadRequestException: Configuring API Key Source is not currently supported.

Created on 14 Oct 2018  ·  10Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.8

  • provider.aws v1.25.0

Affected Resource(s)

aws_api_gateway_rest_api

Terraform Configuration Files

resource "aws_api_gateway_rest_api" "api" {
  name        = "API - ${terraform.workspace}"
  description = "${terraform.workspace} - https://${aws_api_gateway_domain_name.main.domain_name}/${terraform.workspace}"
  binary_media_types = ["*/*", "image/jpeg", "image/png"]
}

Debug Output

Do you want to perform these actions in workspace "ci"?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

module.apigateway.aws_api_gateway_rest_api.api: Creating...
api_key_source: "" => "HEADER"
binary_media_types.#: "0" => "3"
binary_media_types.0: "" => "/"
binary_media_types.1: "" => "image/jpeg"
binary_media_types.2: "" => "image/png"
created_date: "" => ""
description: "" => "ci - https://ci.api.domain.com/ci"
endpoint_configuration.#: "" => ""
execution_arn: "" => ""
minimum_compression_size: "" => "-1"
name: "" => "API - ci"
root_resource_id: "" => ""

Error: Error applying plan:

1 error(s) occurred:

  • module.apigateway.aws_api_gateway_rest_api.api: 1 error(s) occurred:

  • aws_api_gateway_rest_api.api: Error creating API Gateway: BadRequestException: Configuring API Key Source is not currently supported.
    status code: 400, request id: b158b59b-cf34-11e8-9a9c-9f5859b759d5

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Expected Behavior

This was working fine until last week. Something has changed. We'd expect the result to be a created API.

Steps to Reproduce

  1. terraform destroy
  2. terraform apply
servicapigateway upstream

Most helpful comment

Looks to be an issue with AWS's API at the moment for the us-west-1 region. See the two commands below for creating a basic API Gateway:

08:55 $ aws apigateway create-rest-api --name "DELETEME_TEST" --region us-east-1
{
    "apiKeySource": "HEADER",
    "name": "DELETEME_TEST",
    "createdDate": 1539611787,
    "endpointConfiguration": {
        "types": [
            "EDGE"
        ]
    },
    "id": "hpve23gttd"
}

```json
09:00 $ aws apigateway create-rest-api --name "DELETEME_TEST" --region us-west-1
{
"apiKeySource": "XAPIKEY_HEADER",
"name": "DELETEME_TEST",
"createdDate": 1539612032,
"endpointConfiguration": {
"types": [
"EDGE"
]
},
"id": "wfzqj7y267"
}

Then trying to emulate the result of `us-east-1` in the `us-west-1` call
```json
09:07 $ aws apigateway create-rest-api --name "DELETEME" --api-key-source "HEADER"

An error occurred (BadRequestException) when calling the CreateRestApi operation: Configuring API Key Source is not currently supported.

All 10 comments

updated the provider, still no joy.

Initializing the backend...

Initializing provider plugins...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

  • provider.aws: version = "~> 1.40"

Error: Error applying plan:

1 error(s) occurred:

  • module.apigateway.aws_api_gateway_rest_api.api: 1 error(s) occurred:

  • aws_api_gateway_rest_api.api: Error creating API Gateway: BadRequestException: Configuring API Key Source is not currently supported.
    status code: 400, request id: 47fe6e76-cfbf-11e8-b13c-69169d4c3b49

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

I'm also seeing this issue, but only in us-west-1. It seems fine in all other regions.

Looks to be an issue with AWS's API at the moment for the us-west-1 region. See the two commands below for creating a basic API Gateway:

08:55 $ aws apigateway create-rest-api --name "DELETEME_TEST" --region us-east-1
{
    "apiKeySource": "HEADER",
    "name": "DELETEME_TEST",
    "createdDate": 1539611787,
    "endpointConfiguration": {
        "types": [
            "EDGE"
        ]
    },
    "id": "hpve23gttd"
}

```json
09:00 $ aws apigateway create-rest-api --name "DELETEME_TEST" --region us-west-1
{
"apiKeySource": "XAPIKEY_HEADER",
"name": "DELETEME_TEST",
"createdDate": 1539612032,
"endpointConfiguration": {
"types": [
"EDGE"
]
},
"id": "wfzqj7y267"
}

Then trying to emulate the result of `us-east-1` in the `us-west-1` call
```json
09:07 $ aws apigateway create-rest-api --name "DELETEME" --api-key-source "HEADER"

An error occurred (BadRequestException) when calling the CreateRestApi operation: Configuring API Key Source is not currently supported.

I tried this workaround and it works for me:

  • Set terraform provider to 1.21
  • terraform apply to create the resources
  • Add api_key_source = "XAPIKEY_HEADER" to your aws_api_gateway_rest_api resources and swap your terraform provider back to the latest (or desired) version

Wait for AWS to fix this issue, then remove the api_key_source.

Has anyone reached out to AWS Support regarding this? If we're doing something wrong in the Terraform resource, it would be really good to know. Thanks!

@choongchay - that did the trick, thanks for helping us with that.

@bflad I have reached out through AWS premium support, and this was their reply I just got.

Thank you for contacting AWS Premium Support. My name is XXXXXXXX and I will be assisting you with this case today.

I understand that you are receiving 'BadRequestException' error while creating an API using Terraform as well as AWS CLI in the 'us-west-1' region.
Please accept our apologies for the inconvenience it is causing.

I tried to replicate the same error on my end and was able to, using the AWS CLI command :

>> aws apigateway create-rest-api --name 'Simple PetStore (AWS CLI)' --region us-west-1 --api-key-source HEADER

However, when I tried to create the API in other regions e.g. ‘us-east-1’ for testing purpose, the command worked just fine and the API got created in my environment. Additionally, while testing, the API got created in the ‘us-west-1’ region itself using the CLI command when I did not provide the 'api-key-source’ parameter.

aws apigateway create-rest-api --name 'Simple PetStore (AWS CLI)' --region us-west-1

So, in order to find out the exact cause behind this, I have reached out to our internal API Gateway team with this information as they are better equipped to answer these behaviors. Rest assured, I will update the case as soon as I receive any information from them.

Meanwhile, please feel free to reach back to us if you have any additional queries or concerns. We will be glad to assist you.

my team had the same issue in Tokyo region (ap-northeast-1) yesterday.
It seems to be fixed today.

works for me now too

Since there hasn't been any recent activity on this issue, it seems the AWS service team fixed this issue upstream and I'm going to close this. If there is actually anything wrong in the Terraform AWS Provider, please open a new GitHub issue. Thanks!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings