Skip to content

Conversation

@Xepheryy
Copy link

@Xepheryy Xepheryy commented Feb 10, 2026

Description

Adds a new use_existing configuration option to the Google Cloud Storage exporter that allows it to skip bucket creation entirely and assume the bucket already exists.

Motivation

This is useful when:

  • Bucket creation is managed externally (Terraform, CloudFormation, etc.) & service account lacks bucket creation permissions
  • Organization policy requires bucket creation through separate processes

Changes

  • Added use_existing boolean field to bucket configuration
  • Implemented two distinct code paths:
    • If use_existing=true: Skip creation entirely
    • If use_existing=false: Attempt creation with existing reuse_if_exists fallback behavior
  • Updated documentation with configuration details and example
  • Added test case for the new behavior
  • Created changelog entry
  • Updated config schema

Backward Compatibility

The existing reuse_if_exists behavior is preserved for backward compatibility. When use_existing is true, it takes precedence and skips creation entirely.

Testing

  • All existing tests pass
  • New test case added: use_existing_bucket_without_creation
  • Linting passes

Link to tracking Issue

Fixes #45971

@Xepheryy Xepheryy requested review from a team and braydonk as code owners February 10, 2026 08:23
@github-actions github-actions bot added the first-time contributor PRs made by new contributors label Feb 10, 2026
@github-actions
Copy link
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better!

@github-actions github-actions bot requested a review from constanca-m February 10, 2026 08:23
@Xepheryy Xepheryy force-pushed the feature/gcs-use-existing-bucket branch 3 times, most recently from 83f2b0a to 781274e Compare February 12, 2026 02:26
Copy link
Contributor

@constanca-m constanca-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right.

Bucket creation is managed externally (Terraform, CloudFormation, etc.)

I have tried with a TF bucket and this works fine. What errors are you getting?

// exists. If it is set to false, an error will be thrown if the
// bucket already exists. Otherwise, the existent bucket will be
// used.
// used. This flag is ignored if UseExisting is true.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag is ignored if UseExisting is true.

Why is this flag no enough?

Copy link
Author

@Xepheryy Xepheryy Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @constanca-m , are you referring to the ReuseIfExists flag ?

The issue I am facing when using this exporter is that ReuseIfExists is not single responsibility as it relies on an error message after it tries to create the bucket on a project level.

For security reasons, I am granting permission on an object level which makes this current implementation require excessive permissions (project level vs object level).

Does that answer your above question ? I can provide more context if necessary

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense. Can you then improve the reuseifexists implementation to your use case? I feel we are just basically adding a flag for the same use case

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me refactor it then!

…creation

Add a new use_existing configuration option that allows the exporter to skip
bucket creation entirely and assume the bucket already exists. This is useful
when:
- Bucket creation is managed externally (Terraform, CloudFormation, etc.)
- Service account lacks bucket creation permissions
- Organization policy requires bucket creation through separate processes

The existing reuse_if_exists behavior is preserved for backward compatibility.
When use_existing is true, it takes precedence and skips creation entirely.

Assisted-by: Claude Sonnet 4.5
@Xepheryy Xepheryy force-pushed the feature/gcs-use-existing-bucket branch from 781274e to ceb17f7 Compare February 12, 2026 09:00
@Xepheryy Xepheryy requested a review from constanca-m February 12, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants