hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
262 stars 120 forks source link

Support regex as CloudFormation schema property `format` #377

Open ewbankkit opened 2 years ago

ewbankkit commented 2 years ago

Community Note

Description

JSON Schema allows a string property to have a format value that is a regular expression. A recent (#378) Terraform schema generation run raised

error generating Terraform awscc_rekognition_collection resource: emitting schema code: Arn has unsupported format: (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:collection\/([a-zA-Z0-9_.\-]+){1,255})

from the CFN schema

        "Arn": {
            "$comment": "Use the `definitions` block to provide shared resource property schemas",
            "type": "string",
            "maxLength": 2048,
            "format": "(^arn:[a-z\\d-]+:rekognition:[a-z\\d-]+:\\d{12}:collection\\/([a-zA-Z0-9_.\\-]+){1,255})"
        },

Temporarily the code that returns the error was commented out. We should do something better than this:

ewbankkit commented 2 years ago

Pragmatically we can check whether a format pattern is a valid Go regexp pattern and log a warning if it's not and emit a validator if it is.