This module parses a given URL into seperate components.
Say you want to configure an S3 bucket as redirecting website. You can use
url-parser for setting hostname
, protocol
and path
in your
routing_rules
.
This repository uses pre-commit to ensure consistent documentation. This is accomplished by running "pre-commit" before committing your changes and will then execute the hooks defined in the .pre-commit-config.yaml
file.
You can install "pre-commit" by running "pip install pre-commit"
module "target_url" {
source = "TechNative-B-V/terraform-null-url-parser/null"
version = "0.1.0"
url = "https://registry.terraform.io/namespaces/TechNative-B-V"
}
resource "aws_s3_bucket_website_configuration" "bucket_webconf" {
...
routing_rules = <<EOF
[{
"Redirect": {
"Hostname": "${module.target_url.hostname}",
"Protocol": "${module.target_url.protocol}",
"ReplaceKeyWith": "${module.target_url.path_and_param}"
}
}]
EOF
}
This generates:
[{
"Redirect": {
"Hostname": "registry.terraform.io",
"Protocol": "https",
"ReplaceKeyWith": "/namespaces/TechNative-B-V"
}
}]
No resources.
Name | Description | Type | Default | Required |
---|---|---|---|---|
url | URL to parse | string |
n/a | yes |
Name | Description |
---|---|
anchor | Anchor component of URL. E.g http://test.com/index.html#second-paragrapth -> 'second-paragraph' |
hostname | Hostname component of URL. E.g http://dev.test.com -> 'dev.test.com' |
parsed_url | All URL components as map of strings |
path | Path component of URL. E.g http://test.com/blog/one -> '/blog/one' |
path_and_param | The path, query string and anchor components combined as one string. |
protocol | Protocol component of URL. E.g http://test.com -> 'http' |
query | Query string component of URL. E.g http://test.com/index.html?a=1&b=2 -> 'a=1&b2' |