Last active
July 17, 2020 16:43
-
-
Save wesley-dean/9e9f6f9f64fed7b2c5a1ee50cbf3a6c8 to your computer and use it in GitHub Desktop.
This is a shell script that may be used to acquire the time from now using Terraform's External provider
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
#!/bin/sh | |
# Terraform's External provider: | |
# https://www.terraform.io/docs/providers/external/data_source.html | |
# | |
# Sample usage (Terraform): | |
# data "external" "nextmonth" { | |
# program = ["sh", "${path.module}date_from_now_terraform.sh"] | |
# | |
# query = { | |
# date = "next month" | |
# } | |
# } | |
# | |
# ... "${data.nextmonth.result.date}" ... | |
# | |
# Sample usage (shell): | |
# | |
# jq -n "{\"query\":{\"date\":\"next month\"}}" | sh ./date_from_now_terraform.sh | |
# | |
# Sample output: | |
# { | |
# "result": { | |
# "date": "2020-12-07" | |
# } | |
# } | |
jq -n "{\"result\":{\"date\":\"$(date -d "$(jq -r ".query.date")" +%Y-%m-%d)\"}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment