-
Notifications
You must be signed in to change notification settings - Fork 0
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
r17x
wants to merge
18
commits into
main
Choose a base branch
from
chore/nixify-terra
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4c0ec2d
chore: update git ignores
r17x 49d7eb2
feat: use flake and terranix
r17x af9d13f
chore: add nix flake check for check source
r17x d738118
chore: enable pre-commit when run nix-shell or nix develop
r17x 4ddad67
chore: commit config.tf.json
r17x c35b459
chore: fix terraform pre-commit attributes
r17x bcf7ac8
chore: add validate terraform config
r17x 0fa3aad
refactor: nixify do_vpc
faultables f70a7d5
chore: update atlantis
faultables dc1b416
chore: for debugging delete later
faultables dfdc883
chore: lfgggg
faultables 502a729
fix: why not
faultables 8449ae6
feat: just testing
faultables 8240f55
feat: yes
faultables eeeb3b5
feat: change something
faultables 6917421
fix: my bad
faultables 60b183b
feat: create dummy vpc
faultables d159a64
fix: duplicates
faultables File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs"; | ||
|
||
# terranix modules | ||
terranix = { | ||
url = "github:terranix/terranix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
# Other sources / nix utilities | ||
|
||
# pre-commit-hooks | ||
pre-commit-hooks = { | ||
url = "github:cachix/pre-commit-hooks.nix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
nix-filter.url = "github:numtide/nix-filter"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, terranix, flake-compat, nix-filter, pre-commit-hooks }: | ||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
terraform = pkgs.terraform; | ||
terraformConfiguration = terranix.lib.terranixConfiguration { | ||
inherit system; | ||
modules = [ | ||
# TODO rewrite *.tf to .nix | ||
# see https://terranix.org/documentation/terranix-vs-hcl/ | ||
]; | ||
}; | ||
sources.nix = nix-filter.lib { | ||
root = ./.; | ||
include = [ | ||
(nix-filter.lib.matchExt "nix") | ||
]; | ||
}; | ||
in | ||
{ | ||
defaultPackage = terraformConfiguration; | ||
|
||
# nix develop | ||
devShells.default = pkgs.mkShell { | ||
inherit (self.checks.${system}.pre-commit-check) shellHook; | ||
buildInputs = with pkgs;[ | ||
terraform | ||
terranix.defaultPackage.${system} | ||
|
||
tfsec | ||
terrascan | ||
|
||
ripgrep | ||
bat | ||
]; | ||
}; | ||
|
||
# nix run ".#apply" | ||
apps.apply = { | ||
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 \ | ||
&& ${terraform}/bin/terraform init \ | ||
&& ${terraform}/bin/terraform apply | ||
''); | ||
}; | ||
|
||
# nix run ".#destroy" | ||
apps.destroy = { | ||
type = "app"; | ||
program = toString (pkgs.writers.writeBash "destroy" '' | ||
if [[ -e config.tf.json ]]; then rm -f config.tf.json; fi | ||
cp ${terraformConfiguration} config.tf.json \ | ||
&& ${terraform}/bin/terraform init \ | ||
&& ${terraform}/bin/terraform destroy | ||
''); | ||
}; | ||
|
||
# nix flake check | ||
checks = { | ||
pre-commit-check = pre-commit-hooks.lib.${system}.run { | ||
src = ./.; | ||
hooks = { | ||
nixpkgs-fmt.enable = true; | ||
terraform-format = true; | ||
}; | ||
}; | ||
}; | ||
|
||
|
||
# nix run | ||
# every run will be generated config.tf.json | ||
defaultApp = self.apps.${system}.apply; | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example pre-commit @faultables