terraform-nixos
terraform-nixos copied to clipboard
How to pass parameters to Nix script from Terraform?
Hi! Let's say I want to pass PublicIP and other parameters from Terraform to Nix file, how should I do that? I tried using
extra_eval_args = ["--argstr", "some_arg", aws_instance.node.public_ip] or extra_build_args = ["--argstr", "some_arg", aws_instance.node.public_ip]
but none of those are shown in the Nix file as arguments.
What other approach should I use?
Thanks
Let's say I want to pass PublicIP and other parameters from Terraform to Nix file, how should I do that?
which nix file? Do you mean one of these scripts:
- https://github.com/nix-community/terraform-nixos/blob/646cacb12439ca477c05315a7bfd49e9832bc4e3/deploy_nixos/nixos-instantiate.sh
- https://github.com/nix-community/terraform-nixos/blob/646cacb12439ca477c05315a7bfd49e9832bc4e3/deploy_nixos/nixos-deploy.sh
I tried using
extra_eval_args = ["--argstr", "some_arg", aws_instance.node.public_ip] or
How are you setting these? Would you mind sharing repo with a minimal repro? Thanks!
Thanks for help @adrian-gierakowski ! In my case I would like to pass a parameter from lets say from https://github.com/nix-community/terraform-nixos/blob/646cacb12439ca477c05315a7bfd49e9832bc4e3/examples/hermetic_config/default.tf#L20 to here https://github.com/nix-community/terraform-nixos/blob/646cacb12439ca477c05315a7bfd49e9832bc4e3/examples/hermetic_config/configuration.nix#L35
I hope it makes things more clear. I can make a minimal repo tomorrow. Thanks again!
@adrian-gierakowski I created a mini repo: I want to pass argument from TF:
https://github.com/smulikHakipod/mini-nix-terraform-/blob/2cdc1645fabb50efbe579b6195dd25dbac00b421/default.tf#L27
To nix config:
https://github.com/smulikHakipod/mini-nix-terraform-/blob/2cdc1645fabb50efbe579b6195dd25dbac00b421/configuration.nix#L38
What is the best way to achieve this?
Thanks!!