Amazon API Gateway offers faster, cheaper, simpler APIs using HTTP APIs.
The API Gateway HTTP API is in preview.
resource "aws_api_gateway_v2_api" "example" {
protocol_type = "HTTP"
}
Announcement.
Blog post.
Developer guide.
Requires AWS SDK v1.25.48:
Related:
This is an apigatewayv2 resource just like the websockets API
here is the line of code which designates the api type:
https://github.com/aws/aws-sdk-go/blob/2dfbfbc3d3a60ab6ef72537b890eff246f6cb1f2/models/apis/apigatewayv2/2018-11-29/api-2.json#L4575
seems like a big job to build this, but users (self included) would appreciate websockets and cheaper/faster/simpler api
I am interested to contribute but not sure where to start ... how do you decide what counts as a data source, resource, etc?
HTTP APIs are now GA.
Requires AWS SDK v1.29.23:
@ewbankkit looking at this it seems that your other PRs with the constituent resources to build on top of the gateway are still pending. Is there any help that you need on those? I haven't contributed here yet but definitely willing to.
Thanks for the great PR and getting this out there day 1 of GA. Many people are looking forward to leveraging HTTP APIs and your work helps make this possible 🎉
Preview functionality:
aws_apigatewayv2_api
resource - https://github.com/terraform-providers/terraform-provider-aws/pull/12452cors_configuration
attributecredentials_arn
, route_key
and target
attributes to support _quick create_.aws_apigatewayv2_integration
, aws_apigatewayv2_route
and aws_apigatewayv2_stage
resources.aws_apigatewayv2_authorizer
resourcejwt_configuration
attribute to support JSON Web Tokens. This also impacts the aws_apigatewayv2_route
resourceaws_apigatewayv2_stage
resourceauto_deploy
attributeDeleteRouteSettings
APIaws_apigatewayv2_integration
resourcepayload_format_version
attributeGA functionality:
aws_apigatewayv2_vpc_link
resource - https://github.com/terraform-providers/terraform-provider-aws/pull/12577aws_apigatewayv2_stage
resourceDeleteAccessLogSettings
APIaws_apigatewayv2_route
resourceDeleteRouteRequestParameter
APIHi, any idea on providing a body attribute for the aws_api_gateway_v2_api resource. It has similar behaviour to the body attribute in resource_aws_api_gateway_rest_api.go
, but here we have to call different API to create (ImportApi) and update(ReImportApi) the API.
Is there any plan for that, it will help the developers like me who want to migrate the RestAPIGateway based infra to the new version. (I haven't developed GoLang for a long while, I will try to create an MR for that too)
@vincenting My initial thinking around this was to recommend using the instructions in the developer guide to import the API using the AWS CLI and then use terraform import
to adopt the API into Terraform. Either way I think you would have to write the HCL code for the resource.
Sorry for the comment, but i am trying to understanding some things,
I want to use Terraform to create resources for HTTP API Gateway (which got in GA recently).
Is that supported in terraform yet? If so what version of terraform i need for that?
I am using 0.11.2 atm
Thanks a lot
@AleksandarTokarev The ability to manage the base HTTP API resource was released in v2.53.0.
See this comment on support for the additional relevant resources.
@AleksandarTokarev There are no required resources from this comment in Terraform yet. AWS is working on it, but WebSockets are higher on the priority list(as they said in the comment linked in above comment). I wouldn't expect HTTP API to be available in the next few months.
Hi there, I'm currently having an issue with the aws_apigatewayv2_stage
resource type, used for an HTTP API, where on initial create it succeeds but when trying to make any kind of change to any resource (not necessarily even this resource) it tries to update the logging_level
property to "OFF" (which is the default) but it doesn't succeed because of error "Execution logs are not supported on protocolType HTTP". Should I open an issue for this problem or will this be fixed as part of this PR? Is there any workaround for this? Thanks!
@podrezo
See this issue: #12893
There is a PR open too.
@LaurenceGA amazing - thanks so much!
@podrezo @LaurenceGA Please upvote the linked issue if you haven't already.
I am also having issues with aws_apigatewayv2_integration, when creating it is ok, but when updating it is always trying to set passthrough_behavior = WHEN_NO_MATCH when doing integration with VPC_LINK
To bypass the aws_apigatewayv2_stage error I had to add:
lifecycle {
ignore_changes = [deployment_id, default_route_settings]
}
And to also stop receiving changes to passthrough_behavior in aws_apigatewayv2_integration had to add:
lifecycle {
ignore_changes = [passthrough_behavior]
}
@luneo7 same thing for us with the passthrough_behavior on each update.
Created https://github.com/terraform-providers/terraform-provider-aws/pull/13062 to address the passthrough_behavior issue 😄
I have to use an ignore_changes block on my aws_apigatewayv2_stage resource with AWS provider 2.70.0 -- this has no other fix currently?
lifecycle {
ignore_changes = [deployment_id]
}
@warrenstephens The issue with perpetual diffs on deployment_id
has been raised in #13633 and fixed in #13644 - scheduled to be released in v3.0.0 of the provider.
@ewbankkit Thank you. I have my first stabilized aws_apigatewayv2_api with WEBSOCKET protocol -- after a few days of ramping up on AWS gateway.
I was happy to learn that I can get JSON responses from both my $default route and named route despite the AWS docs that seemed to hint otherwise.
@ewbankkit I have been fighting for a week since my post above to get my aws_apigatewayv2_api with WEBSOCKET protocol working with Cognito (OAuth "client_credentials") having no luck, only 403 errors -- is there some sample code having that integration available somewhere? I am willing to clean gutters, chop firewood, etc, to get it working!
I found the fix. The "Action" part of the policy that is returned by the authorizer lambda must be an array of string, not a single string. Like this:
"Action": [ "execute-api:Invoke" ],
With the merge of #12567, scheduled for release with v3.3.0 of the Terraform AWS Provider, I am going to close this original API Gateway HTTP APIs issue.
Please open new issues for any feature requests or bug reports.
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!
Most helpful comment
Preview functionality:
aws_apigatewayv2_api
resource - https://github.com/terraform-providers/terraform-provider-aws/pull/12452cors_configuration
attributecredentials_arn
,route_key
andtarget
attributes to support _quick create_.This will create API Gateway managed
aws_apigatewayv2_integration
,aws_apigatewayv2_route
andaws_apigatewayv2_stage
resources.aws_apigatewayv2_authorizer
resourcejwt_configuration
attribute to support JSON Web Tokens. This also impacts theaws_apigatewayv2_route
resourceaws_apigatewayv2_stage
resourceauto_deploy
attributeDeleteRouteSettings
APIaws_apigatewayv2_integration
resourcepayload_format_version
attributeGA functionality:
aws_apigatewayv2_vpc_link
resource - https://github.com/terraform-providers/terraform-provider-aws/pull/12577aws_apigatewayv2_stage
resourceDeleteAccessLogSettings
APIaws_apigatewayv2_route
resourceDeleteRouteRequestParameter
API