:question: Is there a way, to combine JIT and gen...
# atmos
z
❓ Is there a way, to combine JIT and generating overrides files like this? https://developer.hashicorp.com/terraform/language/files/override#merging-locals-blocks Starting to dig into this feature https://atmos.tools/stacks/generate
Getting into monkeypatch land...
🙈 1
e
Yes, exactly you can generate overrides this way
z
How exactly do I get it into the .workdir, though?
err, maybe I'll just try something 🙁 I'm going to have to override an entire module call I think
e
You shouldn't have to do anything special. If it's not going into the workdir automatically it's a bug
z
Ok cool. I think I just need to see if tofu allows overriding a module
e
Yes, we use it for that
You can't override what's inside the module
You can override the
module "..." {.. }
itself
z
Does it have to be the entire thing?
Or can I just do a single input
e
ya
z
😭
e
Er.. you mean adding an input to the module?
I think maybe?
z
changing an input
lol
we have this huge block of data I need to change a single boolean inside
it's not a local
so I suspect I need to atleast override the entire input into the module
atmos terraform shell doesn't produce the files from the
generate
block 🥲
this is without any JIT TTL crap
also - it seems like it doesn't select the terraform workspace either
facing a few weird issues
will put in an issue after I get this thing fixed
e
I don't think I tested it with shell 😃
Yep, you know the drill 😉
z
It is a cool feature though
Didn't know about overrides files until yesterday
now I can just do whatever I want on the fly 😈
e
Yea, it's powerful stuff. Just be careful 😃 The atmos terraform backend generation is based on overrides. We also have this little snippet https://atmos.tools/best-practices/terraform#use-terraform-overrides-to-extend-monkey-patch-vendored-components
z
yeah for sure - it's the only option other than creating an entirely new component due to the upstream module we have to use
we were using the provider generation feature before
seems like it's the same sauce
oof I think I found a big bug with JIT, backend generation, and output stores
Not respecting workdir provisioning on apply/plan 😕
🙈 1
Copy code
hooks:
        store-outputs:
          outputs:
            vpc_properties: .vpc_properties
Copy code
ℹ Executing command: atmos terraform apply demo-vpc -auto-approve
 INFO  Running hooks event=before.terraform.apply
Fetching vpc_properties output from demo-vpc in dev

x Fetching vpc_properties output from demo-vpc in dev
# Error

**Error:** terraform output returned nil: failed to get terraform output for key
vpc_properties: failed to execute terraform output for component demo-vpc in
stack
dev: failed to generate backend file: open
/tmp/gitrepo.fFs98Y/components/terraform/demo-vpc/backend.tf.json: no such file
or
directory
I removed the hooks and it provisioned the workdir successfully
for some reason init works fine, I'm guessing because it skips something where it needs to run the terraform output command which also needs it to generate the backend.tf. I'm not sure.
I put a couple issues in and am throwing claude at them in my fork
👍 1
It found a few logic errors with the store hooks, JIT components with generate using base_path AND the workdir. Then for some reason atmos uses the base_path instead of the workdir and fails because it's running apply on a mostly empty directory
Running a local redis container to be my atmos store
e
Thanks, @Zack!
Big help
z
I hope it's not slop 😂
Doing a little more testing but I think this might be working
e
I'm sure it'll be fine. Throw it up, we'll review it with CodeRabbit and take a look over.
We're very AI friendly and understanding. 😃
z
Alright, I think this is ready after some coderabbit suggestions https://github.com/cloudposse/atmos/pull/2309
turned out bigger than I thought
but I tested this against my repro, and my real codebase and it seems to handle all of the variables/features cleanly JIT, TTL, workdirs, atmos stores with different event types, terraform base dirs...
e
I left some more comments
@Andriy Knysh (Cloud Posse) you should also review
👀 1
(also, we should use #C07RMALBX7V for core changes)
👍 1