Skip to content

Commit f81b604

Browse files
committed
add examples and updating readme
1 parent 5b53f59 commit f81b604

File tree

13 files changed

+218
-0
lines changed

13 files changed

+218
-0
lines changed

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# terraform-http-echoip
22

3+
[![GitHub release](https://img.shields.io/github/v/release/tobiasehlert/terraform-http-echoip?sort=semver&logo=github)](https://github.com/tobiasehlert/terraform-http-echoip/releases)
34
[![GitHub license](https://img.shields.io/github/license/tobiasehlert/terraform-http-echoip)](https://github.com/tobiasehlert/terraform-http-echoip/blob/main/LICENSE)
45

56
Terraform module that returns your external information by any echoip API.
@@ -9,6 +10,89 @@ Terraform module that returns your external information by any echoip API.
910
1. Get your external public IP address (and other related information).
1011
1. Use any echoip APIs ([ipconfig.io](https://ipconfig.io), [ifconfig.co](https://ifconfig.co), etc.).
1112

13+
## Usage
14+
15+
Example mininal usage:
16+
17+
```hcl
18+
module "echoip" {
19+
source = "tobiasehlert/echoip/http"
20+
}
21+
```
22+
23+
The modules output can then be used in some other module or resource.
24+
25+
Example of use with DigitalOcean firewall:
26+
27+
```hcl
28+
resource digitalocean_firewall "home_ssh" {
29+
name = "home_ssh"
30+
inbound_rule {
31+
protocol = "tcp"
32+
port_range = "22"
33+
source_addresses = ["${module.echoip.ip}/32"]
34+
}
35+
}
36+
```
37+
38+
## Examples
39+
40+
- [default](https://github.com/tobiasehlert/terraform-http-echoip/blob/main/examples/default/README.md) – This is an example of how to use the module with the defaults.
41+
- [ifconfig.co](https://github.com/tobiasehlert/terraform-http-echoip/blob/main/examples/ifconfig.co/README.md) – This is an example of how to use the module with another echoip service.
42+
43+
<!-- BEGIN_TF_DOCS -->
44+
## Requirements
45+
46+
| Name | Version |
47+
|------|---------|
48+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2 |
49+
| <a name="requirement_http"></a> [http](#requirement\_http) | ~> 3.4.0 |
50+
51+
## Providers
52+
53+
| Name | Version |
54+
|------|---------|
55+
| <a name="provider_http"></a> [http](#provider\_http) | ~> 3.4.0 |
56+
57+
## Modules
58+
59+
No modules.
60+
61+
## Resources
62+
63+
| Name | Type |
64+
|------|------|
65+
| [http_http.echoip](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source |
66+
67+
## Inputs
68+
69+
| Name | Description | Type | Default | Required |
70+
|------|-------------|------|---------|:--------:|
71+
| <a name="input_http_method"></a> [http\_method](#input\_http\_method) | HTTP method to use for the request | `string` | `"GET"` | no |
72+
| <a name="input_http_request_headers"></a> [http\_request\_headers](#input\_http\_request\_headers) | HTTP headers to send with the request | `map(any)` | <pre>{<br> "Accept": "application/json"<br>}</pre> | no |
73+
| <a name="input_http_url"></a> [http\_url](#input\_http\_url) | URL for echoip service to use. | `string` | `"https://ipconfig.io"` | no |
74+
75+
## Outputs
76+
77+
| Name | Description |
78+
|------|-------------|
79+
| <a name="output_asn"></a> [asn](#output\_asn) | The `asn` field of the echoip response. |
80+
| <a name="output_asn_org"></a> [asn\_org](#output\_asn\_org) | The `asn_org` field of the echoip response. |
81+
| <a name="output_city"></a> [city](#output\_city) | The `city` field of the echoip response. |
82+
| <a name="output_country"></a> [country](#output\_country) | The `country` field of the echoip response. |
83+
| <a name="output_country_eu"></a> [country\_eu](#output\_country\_eu) | The `country_eu` field of the echoip response. |
84+
| <a name="output_country_iso"></a> [country\_iso](#output\_country\_iso) | The `country_iso` field of the echoip response. |
85+
| <a name="output_ip"></a> [ip](#output\_ip) | The `ip` field of the echoip response. |
86+
| <a name="output_ip_decimal"></a> [ip\_decimal](#output\_ip\_decimal) | The `ip_decimal` field of the echoip response. |
87+
| <a name="output_latitude"></a> [latitude](#output\_latitude) | The `latitude` field of the echoip response. |
88+
| <a name="output_longitude"></a> [longitude](#output\_longitude) | The `longitude` field of the echoip response. |
89+
| <a name="output_region_code"></a> [region\_code](#output\_region\_code) | The `region_code` field of the echoip response. |
90+
| <a name="output_region_name"></a> [region\_name](#output\_region\_name) | The `region_name` field of the echoip response. |
91+
| <a name="output_time_zone"></a> [time\_zone](#output\_time\_zone) | The `time_zone` field of the echoip response. |
92+
| <a name="output_user_agent"></a> [user\_agent](#output\_user\_agent) | The `user_agent` field of the echoip response. |
93+
| <a name="output_zip_code"></a> [zip\_code](#output\_zip\_code) | The `zip_code` field of the echoip response. |
94+
<!-- END_TF_DOCS -->
95+
1296
## Credits
1397

1498
- Authors: Tobias Lindberg – [List of contributors](https://github.com/tobiasehlert/terraform-http-echoip/graphs/contributors)

examples/default/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Default example
2+
3+
This is an example of how to use the module with the defaults to get information about your IP address.
4+
5+
The default configuration uses [ipconfig.io](https://ipconfig.io) as the echoip source of data.
6+
7+
# Usage
8+
9+
To run this example you need to execute:
10+
11+
```bash
12+
$ terraform init
13+
$ terraform plan
14+
$ terraform apply
15+
```
16+
17+
Run `terraform destroy` when you don't need these resources.
18+
19+
<!-- BEGIN_TF_DOCS -->
20+
## Requirements
21+
22+
| Name | Version |
23+
|------|---------|
24+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2 |
25+
| <a name="requirement_http"></a> [http](#requirement\_http) | ~> 3.4.0 |
26+
27+
## Providers
28+
29+
No providers.
30+
31+
## Modules
32+
33+
| Name | Source | Version |
34+
|------|--------|---------|
35+
| <a name="module_example"></a> [example](#module\_example) | ../../ | n/a |
36+
37+
## Resources
38+
39+
No resources.
40+
41+
## Inputs
42+
43+
No inputs.
44+
45+
## Outputs
46+
47+
| Name | Description |
48+
|------|-------------|
49+
| <a name="output_example_output"></a> [example\_output](#output\_example\_output) | The output fields of the example. |
50+
<!-- END_TF_DOCS -->

examples/default/main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module "example" {
2+
source = "../../"
3+
}

examples/default/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "example_output" {
2+
description = "The output fields of the example."
3+
value = module.example
4+
}

examples/default/providers.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
provider "http" {
2+
}

examples/default/variables.tf

Whitespace-only changes.

examples/default/versions.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
terraform {
2+
required_version = ">= 1.2"
3+
4+
required_providers {
5+
http = "~> 3.4.0"
6+
}
7+
}

examples/ifconfig.co/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Default example
2+
3+
This is an example of how to use the module with another echoip service to get information about your IP address.
4+
5+
The configuration in this example is the same as the default example, but the echoip service used is [ifconfig.co](https://ifconfig.co) instead.
6+
7+
# Usage
8+
9+
To run this example you need to execute:
10+
11+
```bash
12+
$ terraform init
13+
$ terraform plan
14+
$ terraform apply
15+
```
16+
17+
Run `terraform destroy` when you don't need these resources.
18+
19+
<!-- BEGIN_TF_DOCS -->
20+
## Requirements
21+
22+
| Name | Version |
23+
|------|---------|
24+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2 |
25+
| <a name="requirement_http"></a> [http](#requirement\_http) | ~> 3.4.0 |
26+
27+
## Providers
28+
29+
No providers.
30+
31+
## Modules
32+
33+
| Name | Source | Version |
34+
|------|--------|---------|
35+
| <a name="module_example"></a> [example](#module\_example) | ../../ | n/a |
36+
37+
## Resources
38+
39+
No resources.
40+
41+
## Inputs
42+
43+
No inputs.
44+
45+
## Outputs
46+
47+
| Name | Description |
48+
|------|-------------|
49+
| <a name="output_example_output"></a> [example\_output](#output\_example\_output) | The output fields of the example. |
50+
<!-- END_TF_DOCS -->

examples/ifconfig.co/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module "example" {
2+
source = "../../"
3+
4+
host_url = "https://ifconfig.co"
5+
}

examples/ifconfig.co/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "example_output" {
2+
description = "The output fields of the example."
3+
value = module.example
4+
}

0 commit comments

Comments
 (0)