-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TerraformVariable: unclear how to use validation conditions in python #3571
Labels
Comments
MartinLoeper
added
documentation
Improvements or additions to documentation
new
Un-triaged issue
labels
Mar 30, 2024
If you check your resulting configuration, you see that the Either add expression syntax to the condition string: env = TerraformVariable(self, "env", type="string")
env.add_validation(
condition=f"${{contains(['production', 'staging'], {env.string_value})}}",
error_message="ERROR: Valid types are production and staging"
) or use the CDKTF equivalent of the from cdktf import TerraformVariable, FnGenerated
env = TerraformVariable(self, "env", type="string")
env.add_validation(
condition=FnGenerated.contains(["production", "staging"], env.string_value),
error_message="ERROR: Valid types are production and staging"
) |
I'll give it a try! Thanks @nbaju1 !! |
ارجو الحل
في أربعاء، 29 مايو، 2024 في 2:29 م، كتب Martin Löper <
***@***.***>:
… I'll give it a try! Thanks @nbaju1 <https://github.com/nbaju1> !!
—
Reply to this email directly, view it on GitHub
<#3571 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A5IDPXF6UFP7LJARUQVRMS3ZEW3ZRAVCNFSM6AAAAABFPPVPVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZXGE4DKNJYGA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
I am a fairly new cdktf user and try to add a validation condition on the env variable s.t. it can only be set to "staging" or "production". However, no matter what I try, cdktf refuses to evaluate my expression.
I searched the docs and could not find any information on how to specify the condition property.
What I expected to work:
However, it failed with:
I also tried to reference the input variable as follows:
... which failed with:
Does not make sense to me, as I included
var.env
into the condition and it looks similar as examples in the non-cdk docs.Could someone please shed some light on that topic?
Links
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: