-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Konnect Terraform tab to plugin examples (#7244)
- Loading branch information
Showing
10 changed files
with
177 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% if include.hub_example.auth_plugin? %} | ||
|
||
As this is an auth plugin, you need to create a consumer and attach a credential to it. | ||
|
||
Create a consumer: | ||
|
||
```bash | ||
resource "konnect_gateway_consumer" "alex" { | ||
username = "alex" | ||
custom_id = "alex-custom" | ||
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id | ||
} | ||
``` | ||
|
||
Create a {{ include.hub_example.plugin_name }} credential attached to this consumer: | ||
|
||
{% assign plugin_name = include.hub_example.plugin_name | replace: "-","_" %} | ||
```hcl | ||
resource "konnect_gateway_{{ plugin_name }}" "my_{{ plugin_name }}" { | ||
{%- for field in include.hub_example.auth_fields %} | ||
{{ field[0] }} = {{ field[1] | quote }}{% endfor %} | ||
|
||
consumer_id = konnect_gateway_consumer.alex.id | ||
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id | ||
} | ||
``` | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<details markdown="1"> | ||
<summary><strong>Prerequisite:</strong> Configure your Personal Access Token</summary> | ||
|
||
```hcl | ||
terraform { | ||
required_providers { | ||
konnect = { | ||
source = "kong/konnect" | ||
} | ||
} | ||
} | ||
|
||
provider "konnect" { | ||
personal_access_token = "kpat_YOUR_TOKEN" | ||
server_url = "https://us.api.konghq.com/v2" | ||
} | ||
``` | ||
</details> | ||
|
||
Add the following to your Terraform configuration to create a Konnect Gateway Plugin: | ||
|
||
{% assign plugin_name = include.example.plugin_name | replace: "-","_" %} | ||
```hcl | ||
resource "konnect_gateway_plugin_{{ plugin_name }}" "my_{{ plugin_name }}" { | ||
enabled = true | ||
|
||
config = { | ||
{%- for item in include.example.example.config %} | ||
{{ item[0] }} = {{ item[1] | quote }}{%- endfor %} | ||
} | ||
|
||
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id{% if include.parent %} | ||
{{ include.parent }} = { | ||
id = konnect_gateway_{{ include.parent }}.my_{{ include.parent }}.id | ||
} | ||
{%- endif %} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module QuoteFilter | ||
def quote(input) | ||
if input.is_a?(Numeric) | ||
input | ||
else | ||
"\"#{input}\"" | ||
end | ||
end | ||
end | ||
|
||
Liquid::Template.register_filter(QuoteFilter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters