Getting the current week number

Is there a way to get the current week number without having to resort to running date or some external program? I don’t see any function defined for it.

Hi @bloudraak,

Assuming you mean a “week of the year” number, I don’t think there’s any built-in way to get that in the Terraform language.

Terraform’s formatdate function was designed primarily to produce standardized machine-readable date formats like the RFC 822 format, so it only includes substitutions for components that contribute to at least one of those standardized formats.

There is also ISO 8601 which deals with machine readable formats, including week dates amongst others I was hoping Terraform supported these standards.

Then there’s RFC 3339 which mentions both ISO 8601 and RFC 822.

If there is a specific standard format you need to use which includes elements that are not in the current formatdate vocabulary then the Terraform team would like to hear about it as a feature request issue in the GitHub repository.

The current functionality was built around what was necessary to generate typical RFC 822, 2822, 850, 1123, and 3339 timestamps, along with some other variations of the same elements that completed a consistent matrix of variations such as zero padding. So far I don’t think anyone requested a format that included a week number, but if you share an example in your feature request of the specific format you need to generate and what standard it is based on then the team can consider how best to support it.