Skip to content
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

Add the possibility to check if a file exist in a bucket #4823

Closed
sylvainar opened this issue Nov 6, 2019 · 2 comments
Closed

Add the possibility to check if a file exist in a bucket #4823

sylvainar opened this issue Nov 6, 2019 · 2 comments

Comments

@sylvainar
Copy link

sylvainar commented Nov 6, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Currently, if we're using data source google_storage_bucket_object on a file that does not exist, the terraform plan exits with a 404 error. Could it be possible that we let this call return a null value, or something we can exploit in order to conditionally do things in the plan?

For better understanding, here's my usecase: I have a cloud function on GCP, its code is send via gsutil on our CI/CD platform, but I still want to provision this cloud function with terraform. I'd like to check if the source code of this function is present in the bucket. If not, I'd like to be able to skip the creation of the cloud function.

New or Affected Resource(s)

  • google_storage_bucket_object

Potential Terraform Configuration

data "google_storage_bucket_object" "cf_source" {
  name   = "${terraform.workspace}/src.zip"
  bucket = "cf_bucket"
}

resource "whatever" "example" {
    count = "${data.google_storage_bucket_object.cf_source != null ? 1 : 0}"
}

References

@ghost ghost added the enhancement label Nov 6, 2019
@paddycarver paddycarver added this to the Backlog milestone Dec 3, 2019
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Jun 2, 2021
* fixed default for max_throughput

* updated a test

Signed-off-by: Modular Magician <[email protected]>
modular-magician added a commit that referenced this issue Jun 2, 2021
* fixed default for max_throughput

* updated a test

Signed-off-by: Modular Magician <[email protected]>
@rileykarson
Copy link
Collaborator

What's being asked for here is the opposite of intended behaviour for datasources nowadays, see #12873. At the time of this issue getting filed the behaviour was undefined, and we weren't sure what was best. Since then, datasources implicitly returning nulls has proven to cause hard-to-diagnose issues for customers, and the behaviour of the GCS object resource is consistent with current practices.

Additionally, given the evolving stance of the Terraform Core team at HashiCorp in hashicorp/terraform#16380 (comment) (and in numerous updates since then!), I don't believe kind of conditional configuration is an intended use case.

@rileykarson rileykarson closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2023
@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants