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

chore/nixify terra #10

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .envrc.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# legacy nix
use_nix

# 👇 uncomment when you want to use flake
# use flake

export TF_VAR_do_token=
export TF_VAR_linode_token=
export TF_VAR_namecheap_username=
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.envrc
.terraform
terraform.tfstate
terraform.tfstate.*
Expand All @@ -7,6 +6,11 @@ terraform.tfstate.*
# Edit at https://www.toptal.com/developers/gitignore?templates=direnv

### direnv ###
.envrc
.direnv

# End of https://www.toptal.com/developers/gitignore/api/direnv
result

# ignored generated precommit config by nix-precommit
/.pre-commit-config.yaml
2 changes: 2 additions & 0 deletions atlantis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ workflows:
default:
plan:
steps:
- run: rm ./config.tf.json || true
Copy link
Member Author

Choose a reason for hiding this comment

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

when run nix build di current repo diremove kok

Copy link
Member

Choose a reason for hiding this comment

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

kaga bro

CleanShot 2022-12-28 at 12 37 33

Copy link
Member Author

@r17x r17x Dec 28, 2022

Choose a reason for hiding this comment

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

@faultables tambahkan ini di atas apps.apply

// file:flake.nix
+          # nix run ".#build"
+          apps.build = {
+            type = "app";
+            program = toString (pkgs.writers.writeBash "apply" ''
+              if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi
+              cp ${terraformConfiguration} config.tf.json
+            '');
+          };
+

           # nix run ".#apply"
           apps.apply = {

Copy link
Member Author

@r17x r17x Dec 28, 2022

Choose a reason for hiding this comment

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

@faultables sehingga steps

// file:atlantis.yml
- - run: rm ./config.tf.json || true
- - run: export PATH=/root/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH; echo $PATH; nix build -o config.tf.json
+ - run: export PATH=/root/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH; echo $PATH; nix build; nix run .#build;

Copy link
Member

Choose a reason for hiding this comment

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

jadi ada nix build dan nix run .#build?

Copy link
Member Author

Choose a reason for hiding this comment

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

@faultables bener sekali mang

Copy link
Member

Choose a reason for hiding this comment

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

lol wtf ok

- run: export PATH=/root/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH; nix build; nix run .#build
- init
- plan:
extra_args: ["-var-file", "/etc/atlantis/area13.tfvars"]
1 change: 1 addition & 0 deletions config.tf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's a file will be used for terraform apply @faultables

Copy link
Member Author

Choose a reason for hiding this comment

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

{} bakalan terisi berdasarkan modules = [] pada flake.nix:31:33 @faultables

Copy link
Member

Choose a reason for hiding this comment

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

nah eventually harus jalanin nix build ini somewhere kan (local/CI/atlantis server)

Copy link
Member Author

Choose a reason for hiding this comment

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

@faultables development mode generated config.tf.json trus push ke repository ini.

atlantis referensinya kerepo ini. so, terraform apply jadi possible diatlantis.

7 changes: 7 additions & 0 deletions do_vpc.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
resource.digitalocean_vpc.dummy_sgp = {
name = "dummy-sgp";
ip_range = "10.105.69.0/20";
region = "sgp1";
};
}
255 changes: 255 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading