{"id":28143623,"url":"https://github.com/libre-devops/terraform-external-timestamp","last_synced_at":"2025-05-14T21:19:21.820Z","repository":{"id":291332167,"uuid":"977298761","full_name":"libre-devops/terraform-external-timestamp","owner":"libre-devops","description":"A module used to generate a timestamp.  This is useful due to the fact it runs at plan time rather than apply ⌚","archived":false,"fork":false,"pushed_at":"2025-05-03T22:35:11.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-05-03T23:25:24.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libre-devops.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-03T21:52:46.000Z","updated_at":"2025-05-03T22:35:13.000Z","dependencies_parsed_at":"2025-05-03T23:25:27.266Z","dependency_job_id":null,"html_url":"https://github.com/libre-devops/terraform-external-timestamp","commit_stats":null,"previous_names":["libre-devops/terraform-external-timestamp"],"tags_count":1,"template":false,"template_full_name":"libre-devops/terraform-module-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libre-devops%2Fterraform-external-timestamp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libre-devops%2Fterraform-external-timestamp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libre-devops%2Fterraform-external-timestamp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libre-devops%2Fterraform-external-timestamp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libre-devops","download_url":"https://codeload.github.com/libre-devops/terraform-external-timestamp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227580,"owners_count":22035675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-14T21:19:15.611Z","updated_at":"2025-05-14T21:19:21.814Z","avatar_url":"https://github.com/libre-devops.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"```hcl\n###############################################################################\n# Detect the OS\n###############################################################################\n\n# Full path to the helper that exists only on Windows\nlocals {\n  windows_helper = \"${abspath(path.module)}\\\\printf.cmd\"\n}\n\n# If the helper file exists, we’re on Windows; otherwise assume Linux\ndata \"external\" \"detect_os\" {\n  program = fileexists(local.windows_helper) ? [local.windows_helper, \"{\\\"os\\\":\\\"Windows\\\"}\"] : [\"printf\", \"{\\\"os\\\":\\\"Linux\\\"}\"]\n}\n\nlocals {\n  os         = data.external.detect_os.result.os\n  is_windows = lower(local.os) == \"windows\"\n  is_linux   = lower(local.os) == \"linux\"\n}\n\n\n# Linux branch\ndata \"external\" \"generate_linux_timestamp\" {\n  count       = local.is_linux ? 1 : 0\n  working_dir = var.working_dir == null ? path.module : var.working_dir\n\n  program = [\n    \"bash\",\n    \"-c\",\n    \"DATE=$(date '${var.linux_timestamp_format}'); printf '{\\\"id\\\":\\\"%s\\\",\\\"timestamp\\\":\\\"%s\\\"}' \\\"$DATE\\\" \\\"$DATE\\\"\"\n  ]\n}\n\n\n# Windows branch\ndata \"external\" \"generate_windows_timestamp\" {\n  count       = local.is_windows ? 1 : 0\n  working_dir = var.working_dir == null ? path.module : var.working_dir\n\n  program = [\n    \"powershell\",\n    \"-Command\",\n    \"$date = Get-Date -Format '${var.windows_timestamp_format}'; $json = @{ id = $date; timestamp = $date } | ConvertTo-Json -Compress; Write-Output $json\"\n  ]\n\n}\n\n\n###############################################################################\n# Normalise the result\n###############################################################################\n\nlocals {\n  timestamp = local.is_linux ? lower(data.external.generate_linux_timestamp[0].result.timestamp) : lower(data.external.generate_windows_timestamp[0].result.timestamp)\n}\n```\n## Requirements\n\nNo requirements.\n\n## Providers\n\n| Name | Version |\n|------|---------|\n| \u003ca name=\"provider_external\"\u003e\u003c/a\u003e [external](#provider\\_external) | n/a |\n\n## Modules\n\nNo modules.\n\n## Resources\n\n| Name | Type |\n|------|------|\n| [external_external.detect_os](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source |\n| [external_external.generate_linux_timestamp](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source |\n| [external_external.generate_windows_timestamp](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source |\n\n## Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| \u003ca name=\"input_linux_timestamp_format\"\u003e\u003c/a\u003e [linux\\_timestamp\\_format](#input\\_linux\\_timestamp\\_format) | The format of the timestamp to generate on Linux | `string` | `\"+%d-%m-%Y:%H:%M\"` | no |\n| \u003ca name=\"input_windows_timestamp_format\"\u003e\u003c/a\u003e [windows\\_timestamp\\_format](#input\\_windows\\_timestamp\\_format) | The format of the timestamp to generate on Windows | `string` | `\"dd-MM-yyyy:HH:mm\"` | no |\n| \u003ca name=\"input_working_dir\"\u003e\u003c/a\u003e [working\\_dir](#input\\_working\\_dir) | The working directory for the module | `string` | `null` | no |\n\n## Outputs\n\n| Name | Description |\n|------|-------------|\n| \u003ca name=\"output_is_linux\"\u003e\u003c/a\u003e [is\\_linux](#output\\_is\\_linux) | True if the OS is Linux |\n| \u003ca name=\"output_is_windows\"\u003e\u003c/a\u003e [is\\_windows](#output\\_is\\_windows) | True if the OS is Windows |\n| \u003ca name=\"output_os\"\u003e\u003c/a\u003e [os](#output\\_os) | The OS that is running the commands |\n| \u003ca name=\"output_timestamp\"\u003e\u003c/a\u003e [timestamp](#output\\_timestamp) | A random string generated by the external data source |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibre-devops%2Fterraform-external-timestamp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibre-devops%2Fterraform-external-timestamp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibre-devops%2Fterraform-external-timestamp/lists"}