There is an article on Building a Konnect Environment with Terraform, which describes how to set up a Konnect environment using Terraform. In this article, I will leave a memo on how to configure Kong Gateway for an on-premises environment, not Konnect.
The Terraform provider used this time is as follows:
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# kong-gateway_route.hello will be created + resource "kong-gateway_route""hello"{ + created_at=(known after apply) + destinations=(known after apply) + headers=(known after apply) + hosts=(known after apply) + https_redirect_status_code=(known after apply) + id=(known after apply) + methods=[ + "GET",
] + name="Anything" + path_handling=(known after apply) + paths=[ + "/anything",
] + preserve_host=(known after apply) + protocols=(known after apply) + regex_priority=(known after apply) + request_buffering=(known after apply) + response_buffering=(known after apply) + service={ + id=(known after apply)} + snis=(known after apply) + sources=(known after apply) + strip_path=false + tags=(known after apply) + updated_at=(known after apply)}# kong-gateway_service.httpbin will be created + resource "kong-gateway_service""httpbin"{ + ca_certificates=(known after apply) + client_certificate=(known after apply) + connect_timeout=(known after apply) + created_at=(known after apply) + enabled=(known after apply) + host="httpbin.org" + id=(known after apply) + name="HTTPBin" + path="/" + port=80 + protocol="http" + read_timeout=(known after apply) + retries=(known after apply) + tags=(known after apply) + tls_verify=(known after apply) + tls_verify_depth=(known after apply) + updated_at=(known after apply) + write_timeout=(known after apply)}Plan: 2 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
kong-gateway_service.httpbin: Creating...
kong-gateway_service.httpbin: Creation complete after 0s [id=13137290-ba88-432c-a9ea-d10465ffaa8f]kong-gateway_route.hello: Creating...
kong-gateway_route.hello: Creation complete after 0s [id=152c5f85-cf3b-466a-8d0f-ead33de8f6ca]Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
terraform destroy
...
Plan: 0 to add, 0 to change, 5 to destroy.
Do you really want to destroy all resources?
Terraform will destroy all your managed infrastructure, as shown above.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
kong-gateway_basic_auth.my_basicauth: Destroying... [id=9f419547-0b9b-41c9-a595-f22c1539ff34]kong-gateway_route.hello: Destroying... [id=152c5f85-cf3b-466a-8d0f-ead33de8f6ca]kong-gateway_plugin_basic_auth.my_pluginbasicauth: Destroying... [id=741a6c67-5ef0-4c4e-94ec-f8597ce89992]kong-gateway_basic_auth.my_basicauth: Destruction complete after 0s
kong-gateway_plugin_basic_auth.my_pluginbasicauth: Destruction complete after 0s
kong-gateway_consumer.alice: Destroying... [id=5a32c0e9-035a-404c-95d1-1df3313a768d]kong-gateway_route.hello: Destruction complete after 0s
kong-gateway_service.httpbin: Destroying... [id=13137290-ba88-432c-a9ea-d10465ffaa8f]kong-gateway_consumer.alice: Destruction complete after 0s
kong-gateway_service.httpbin: Destruction complete after 0s
Destroy complete! Resources: 5 destroyed.