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

Delay availability of bucket ID until bucket is fully configured #228

Open
Nuru opened this issue Apr 15, 2024 · 1 comment
Open

Delay availability of bucket ID until bucket is fully configured #228

Nuru opened this issue Apr 15, 2024 · 1 comment

Comments

@Nuru
Copy link
Contributor

Nuru commented Apr 15, 2024

Describe the Feature

Terraform does not treat modules like black boxes, it incorporates their code and looks at all the code at once. In doing so, any other modules that consume this module's bucket_id output will only wait for the bucket to be created before they start using it. However, in many cases if not most cases, the bucket should not be used in other resources until after it is fully configured with access policies, lifecycle policies, etc. See cloudposse/terraform-aws-cloudtrail-s3-bucket#90 for an example.

Therefore, it would be helpful to delay the availability of bucket_id until after all of the configuration is completed.

Expected Behavior

One would expect that any resource the uses bucket_id would be free to use it once it is provided, and Terraform proceeds as such. However, some uses require certain configuration to be applied before use, and bucket_id is available well before the requested configuration is applied, causing those uses to fail.

Use Case

See cloudposse/terraform-aws-cloudtrail-s3-bucket#90 for an example.

Describe Ideal Solution

bucket_id would be delayed until the bucket is fully configured. Possibly another output (bucket_id_early?) would be provided for use cases where the delayed bucket_id is not appropriate.

Alternatives Considered

No response

Additional Context

No response

@andreineculau
Copy link

andreineculau commented Jul 25, 2024

I observed this just now.
Another alternative is to add an output "done" or "final" or similar that has a static value "true" that depends on all the module's resources. Downstream one can reference this output to make sure the module has been fully deployed.

EDIT: I wrote the above since https://github.com/cloudposse/terraform-aws-cloudtrail-s3-bucket/pull/91/files is supposed to fix this by adding a depends_on referencing the module, but I still experienced the race condition...
EDIT2: I take it back. The cloudtrail module was missing a depends_on cloudtrail_s3_bucket, due to s3_bucket_name being static.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants