Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

TechNative-B-V/terraform-null-url-parser

Repository files navigation

terraform-null-url-parser

This module parses a given URL into seperate components.

What is it good for?

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.

Release workflow

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"

Usage

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" } }] 

Resources

No resources.

Inputs

NameDescriptionTypeDefaultRequired
urlURL to parsestringn/ayes

Outputs

NameDescription
anchorAnchor component of URL. E.g http://test.com/index.html#second-paragrapth -> 'second-paragraph'
hostnameHostname component of URL. E.g http://dev.test.com -> 'dev.test.com'
parsed_urlAll URL components as map of strings
pathPath component of URL. E.g http://test.com/blog/one -> '/blog/one'
path_and_paramThe path, query string and anchor components combined as one string.
protocolProtocol component of URL. E.g http://test.com -> 'http'
queryQuery string component of URL. E.g http://test.com/index.html?a=1&b=2 -> 'a=1&b2'

Contributors 2

  •  
  •