-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
d/ssm_parameter: Return a default value if parameter cannot be found in AWS (optional) #3945
Conversation
@radeksimko this is super useful! please merge! |
aws/data_source_aws_ssm_parameter.go
Outdated
Optional: true, | ||
Default: "", | ||
}, | ||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielRis Have you noticed the merge conflicts in several files?
@@ -29,7 +29,8 @@ The following arguments are supported: | |||
|
|||
* `name` - (Required) The name of the parameter. | |||
* `with_decryption` - (Optional) Whether to return decrypted `SecureString` value. Defaults to `true`. | |||
|
|||
* `with_default` - (Optional) Whether to return a default value if no parameter can be found. Defaults to `false`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think with_default
is not needed. Don't provide default
if you don't need to get a default value back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm unsure how this can be implemented without breaking the actual behavior of failing if a SSM parameter cannot be found in SSM. Thats the reason why i created this "with_default" parameter.
If I skip "with_default" and set the Default value of "default" to be an empty string, I currently have no idea how to catch that in my code without returning a default value every time the parameter cannot be found. Any idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I figured it out by my self.
4374f1c
to
c1eb34d
Compare
@antonbabenko Hi, any news on getting this merged? |
It would be super useful if this could get merged, please. |
Hi @DanielRis - great PR, we could really do with this! Any chance you could please fix the conflict? |
@bflad Could you tell what is missing here other than fixing conflicting file? We can't wait for the next Terraform Gardering event to get this merged, can we? :) |
d56f3b4
to
d57b17e
Compare
I updated the PR to reflect that latest change that was implemented into this Data Resource. The lookup method was changed from GetParameters to GetParameter which caused the merge conflicts.
|
I did some additional tests and I still have not found a good way to determine if a property has been set in a configuration.
works fine.
does not. Is there any good way to check if a property is set in the configuration, independent of the value it has? I thought GetOkExist will do the job but this does not work for empty string values. |
Hi Folks 👋 It would be helpful to understand some of the expected use cases for this functionality. Outside of the None of this is to say that we won't accept a change like this; its just a different class of problem and it would be nice to know some of the reasoning behind why the behavior change should be allowed. 😄 |
Hi @bflad, here is my use case: We're using blue/green deployment and the active environment name is currently stored in Consul. The resource The You'll find some other cases here: hashicorp/terraform#16380 @AndHei @aliusmiles @jakowicz @ixalon : Can you add your use cases to help merging this PR ? Thanks ! |
@gdlx I am also facing the same issue :-( |
@sharmaanshul2102 Can you please explain your use case as requested by @bflad ? This will help merging or fixing the PR. Thanks ! |
It tries to read data and fails because aws_ssm_parameter doesn't exist in first run :-( |
We are using SSM Parameters to store config variables in order to:
Having default value for |
Hey folks thanks for shedding a little light on the need. Unfortunately, given that the provided usage cases are specific to solving a particular build/deploy process we are unable to accept this change, as it is not a use case that is valid to the provider. Data sources are expected to require existing infrastructure. Changing the behaviour of this one data source would make it inconsistent with the other data sources in the provider, and in most other providers (minus the Consul provider). In general, Terraform prefers the use of explicit configuration that represents the true state of the reference infrastructure over conditionally defined defaults. If you still feel like this is something worth discussing I recommend starting a discussion on our community forum https://discuss.hashicorp.com/c/terraform-providers as a next step. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
I tried to make it comparable with the behavior of d/consul_keys (https://www.terraform.io/docs/providers/consul/d/keys.html) but with an option to enable/disable this behavior to avoid any compatibility issues
Use case description
I only want to build a AWS resource if a parameter was configured by operations or terraform.