aws-cloudformation / cloudformation-guard

Guard offers a policy-as-code domain-specific language (DSL) to write rules and validate JSON- and YAML-formatted data such as CloudFormation Templates, K8s configurations, and Terraform JSON plans/configurations against those rules. Take this survey to provide feedback about cfn-guard: https://amazonmr.au1.qualtrics.com/jfe/form/SV_bpyzpfoYGGuuUl0
Apache License 2.0
1.3k stars 180 forks source link

[Enhancement] Introduce date-time and or parse_timestamp (to epoch) function (parser). #521

Closed justinmburrous closed 1 month ago

justinmburrous commented 5 months ago

Is your feature request related to a problem? Please describe.

We would like to have the ability to parse date-time values to epoch for comparison purposes. For example...

Describe the solution you'd like

It would be be nice if there were a way to parse timestamps (represented as strings) in templates now into values we would use. The simplest approach would be to introduce a parse_epoch or parse_iso8601_epoch function to the existing set of functions which would enable simple numbers comparisons at the very least.

Describe alternatives you've considered

In theory all sorts of date-time functions could be supported within Guard, however a simple parser for epoch time would be a reasonable start.

Additional context

N/A for the moment.

dannyvassallo commented 3 months ago

@justinmburrous Thanks for opening up the issue. We're looking into this.

dannyvassallo commented 2 months ago

@justinmburrous Please see the linked pull request for my date function proposal. Does this implementation meet your use cases?

Thanks!