Skip to content
Merged
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
1 change: 1 addition & 0 deletions .aliases
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ alias tfp='terraform init || terraform providers && terraform validate && terraf
alias tfr='terraform destroy --auto-approve; terraform apply --auto-approve'
alias k='kubectl'
alias tt='cd tests; go test -v -parallel=10 -timeout=80m'
alias nix='nix --extra-experimental-features nix-command --extra-experimental-features flakes'
30 changes: 28 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
if [ -z "${name}" ]; then
echo "entering dev environment..."

nix develop . --extra-experimental-features nix-command --extra-experimental-features flakes
nix develop \
--ignore-environment \
--extra-experimental-features nix-command \
--extra-experimental-features flakes \
--keep HOME \
--keep SSH_AUTH_SOCK \
--keep GITHUB_TOKEN \
--keep AWS_ROLE \
--keep AWS_REGION \
--keep AWS_DEFAULT_REGION \
--keep AWS_ACCESS_KEY_ID \
--keep AWS_SECRET_ACCESS_KEY \
--keep AWS_SESSION_TOKEN \
--keep TERM \
$(pwd)
else
echo "setting up dev environment..."

source .aliases
source .functions
source .variables
source .rcs
fi
fi
if [ -z "$SSH_AUTH_SOCK" ]; then
echo "Unable to find SSH_AUTH_SOCK, is your agent running?";
fi
if [ -z "$(ssh-add -l | grep -v 'The agent has no identities.')" ]; then
echo "Your agent doesn't appear to have any identities loaded, please load a key or forward your agent.";
fi
if [ -z "$(env | grep 'AWS')" ]; then
echo "Unable to find AWS authentication information in the environment, please make sure you authenticate with AWS.";
fi
if [ -z "$(env | grep 'GITHUB_TOKEN')" ]; then
echo "Unable to find GITHUB authentication information in the environment, please make sure you authenticate with GITHUB.";
fi
60 changes: 40 additions & 20 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
env:
AWS_REGION: us-west-1
AWS_ROLE: arn:aws:iam::270074865685:role/terraform-module-ci-test
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

permissions: write-all

Expand All @@ -19,7 +20,6 @@ jobs:
id: release-please
with:
release-type: terraform-module
pull-request-title-pattern: "chore${scope}: release${component} ${version}"
- uses: peter-evans/create-or-update-comment@v3
name: 'Remind to wait'
if: steps.release-please.outputs.pr
Expand All @@ -32,52 +32,72 @@ jobs:
if: steps.release-please.outputs.pr
with:
token: ${{secrets.GITHUB_TOKEN}}
- uses: DeterminateSystems/nix-installer-action@main
- run: sudo rm -rf /nix/store
if: steps.release-please.outputs.pr
- run: sudo install -d /nix/store
if: steps.release-please.outputs.pr
- run: sudo chown -R "$(whoami)" /nix/store
if: steps.release-please.outputs.pr
- name: 'Restore Nix Store Cache'
- run: sudo chmod 0755 /nix/store
if: steps.release-please.outputs.pr
- uses: actions/cache/restore@v3
id: cache-nix-restore
if: steps.release-please.outputs.pr
id: cache-nix-store-restore
uses: actions/cache/restore@v3
with:
path: /nix/store
key: nix-store
- uses: nicknovitski/nix-develop@v1
key: nix-${{ hashFiles('**/flake.nix') }}
- uses: DeterminateSystems/nix-installer-action@main
if: steps.release-please.outputs.pr
- name: 'Cache Nix Store'
- uses: nicknovitski/nix-develop@v1.1.0
if: steps.release-please.outputs.pr
with:
arguments: |
--ignore-environment \
--extra-experimental-features nix-command \
--extra-experimental-features flakes \
--keep HOME \
--keep SSH_AUTH_SOCK \
--keep GITHUB_TOKEN \
--keep AWS_ROLE \
--keep AWS_REGION \
--keep AWS_DEFAULT_REGION \
--keep AWS_ACCESS_KEY_ID \
--keep AWS_SECRET_ACCESS_KEY \
--keep AWS_SESSION_TOKEN \
--keep TERM \
${{ github.workspace }}
- uses: actions/cache/save@v3
id: cache-nix-save
if: steps.release-please.outputs.pr
id: cache-nix-store-save
uses: actions/cache/save@v3
with:
path: /nix/store
key: ${{ steps.cache-nix-store-restore.outputs.cache-primary-key }}
key: ${{ steps.cache-nix-restore.outputs.cache-primary-key }}
- uses: aws-actions/configure-aws-credentials@v4
if: steps.release-please.outputs.pr
with:
role-to-assume: ${{env.AWS_ROLE}}
role-session-name: ${{github.job}}-${{github.run_id}}-${{github.run_number}}-${{github.run_attempt}}
aws-region: ${{env.AWS_REGION}}
- name: 'Restore Terraform Cache'
if: steps.release-please.outputs.pr
- uses: actions/cache/restore@v3
id: cache-terraform-restore
uses: actions/cache/restore@v3
if: steps.release-please.outputs.pr
with:
path: ${{ github.workspace }}/.terraform
key: terraform
key: terraform-${{hashFiles('**/versions.tf','**/main.tf')}}
- run: terraform init -upgrade
if: steps.release-please.outputs.pr
- name: 'Cache Terraform'
if: steps.release-please.outputs.pr
- uses: actions/cache/save@v3
id: cache-terraform-save
uses: actions/cache/save@v3
if: steps.release-please.outputs.pr
with:
path: ${{ github.workspace }}/.terraform
key: ${{ steps.cache-terraform-restore.outputs.cache-primary-key }}
- run: cd ./tests && go test -v -timeout=40m -parallel=10
name: 'Terratest'
- run: go version && cd ${{github.workspace}}/tests && go test -v -timeout=40m -parallel=10 && cd ${{github.workspace}}
if: steps.release-please.outputs.pr
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_OWNER: rancher
IDENTIFIER: ${{github.job}}-${{github.run_id}}-${{github.run_number}}-${{github.run_attempt}}
- uses: peter-evans/create-or-update-comment@v3
name: 'Report Success'
if: steps.release-please.outputs.pr
Expand Down
52 changes: 47 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,60 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: nicknovitski/nix-develop@v1
- run: cd examples/basic && terraform version && terraform init -upgrade && terraform validate
- uses: nicknovitski/nix-develop@v1.1.0
with:
arguments: |
--ignore-environment \
--extra-experimental-features nix-command \
--extra-experimental-features flakes \
--keep HOME \
--keep SSH_AUTH_SOCK \
--keep GITHUB_TOKEN \
--keep AWS_ROLE \
--keep AWS_REGION \
--keep AWS_DEFAULT_REGION \
--keep AWS_ACCESS_KEY_ID \
--keep AWS_SECRET_ACCESS_KEY \
--keep AWS_SESSION_TOKEN \
--keep TERM \
${{ github.workspace }}
- uses: actions/cache/restore@v3
id: cache-terraform-restore
with:
path: ${{ github.workspace }}/.terraform
key: terraform
- run: terraform init -upgrade
- uses: actions/cache/save@v3
id: cache-terraform-save
with:
path: ${{ github.workspace }}/.terraform
key: ${{ steps.cache-terraform-restore.outputs.cache-primary-key }}
- run: cd ${{ github.workspace }}/examples/basic && terraform version && terraform init -upgrade && terraform validate && cd ${{ github.workspace }}
- run: terraform fmt -check -recursive

actionlint:
name: 'Lint Workflows'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: nicknovitski/nix-develop@v1
- uses: nicknovitski/nix-develop@v1.1.0
with:
arguments: |
--ignore-environment \
--extra-experimental-features nix-command \
--extra-experimental-features flakes \
--keep HOME \
--keep SSH_AUTH_SOCK \
--keep GITHUB_TOKEN \
--keep AWS_ROLE \
--keep AWS_REGION \
--keep AWS_DEFAULT_REGION \
--keep AWS_ACCESS_KEY_ID \
--keep AWS_SECRET_ACCESS_KEY \
--keep AWS_SESSION_TOKEN \
--keep TERM \
${{ github.workspace }}
- run: actionlint

tflint:
Expand Down
24 changes: 7 additions & 17 deletions .github/workflows/updatecli.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Updatecli: Dependency Management"
name: "Updatecli"

on:
schedule:
Expand All @@ -7,28 +7,19 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: write
issues: write
pull-requests: write
permissions: write-all

jobs:
updatecli:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 'stable'

- name: Install Updatecli
uses: updatecli/updatecli-action@v2

- name: Delete leftover UpdateCLI branches
- uses: updatecli/updatecli-action@v2
- name: 'Delete leftover UpdateCLI branches'
run: |
gh pr list \
--search "is:closed is:pr head:updatecli_" \
Expand All @@ -46,10 +37,9 @@ jobs:
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Apply Updatecli
# Never use '--debug' option, because it might leak the access tokens.
run: "updatecli apply --clean --config ./updatecli/updatecli.d/ --values ./updatecli/values.yaml"
env:
UPDATECLI_GITHUB_ACTOR: ${{ github.actor }}
UPDATECLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPDATECLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 2 additions & 4 deletions .rcs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# load aws config
source ~/.config/aws/default/rc
# load personal aliases
source ~/.config/alias/default/rc
source ~/.config/aws/default/rc # add personal aws auth vars
source ~/.config/alias/default/rc # add personal aliases
8 changes: 4 additions & 4 deletions examples/basic/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ output "vpc" {
}

output "subnet" {
value = module.TestBasic.subnet
value = module.TestBasic.subnet
}

output "cidr" {
value = module.TestBasic.cidr
value = module.TestBasic.cidr
}

output "security_group" {
value = module.TestBasic.security_group
value = module.TestBasic.security_group
}

output "ssh_key" {
value = module.TestBasic.ssh_key
value = module.TestBasic.ssh_key
}
8 changes: 4 additions & 4 deletions examples/override/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ output "vpc" {
}

output "subnet" {
value = module.TestOverride.subnet
value = module.TestOverride.subnet
}

output "cidr" {
value = module.TestOverride.cidr
value = module.TestOverride.cidr
}

output "security_group" {
value = module.TestOverride.security_group
value = module.TestOverride.security_group
}

output "ssh_key" {
value = module.TestOverride.ssh_key
value = module.TestOverride.ssh_key
}
8 changes: 4 additions & 4 deletions examples/personal/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ output "vpc" {
}

output "subnet" {
value = module.TestPersonal.subnet
value = module.TestPersonal.subnet
}

output "cidr" {
value = module.TestPersonal.cidr
value = module.TestPersonal.cidr
}

output "security_group" {
value = module.TestPersonal.security_group
value = module.TestPersonal.security_group
}

output "ssh_key" {
value = module.TestPersonal.ssh_key
value = module.TestPersonal.ssh_key
}
8 changes: 4 additions & 4 deletions examples/project/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ output "vpc" {
}

output "subnet" {
value = module.TestProject.subnet
value = module.TestProject.subnet
}

output "cidr" {
value = module.TestProject.cidr
value = module.TestProject.cidr
}

output "security_group" {
value = module.TestProject.security_group
value = module.TestProject.security_group
}

output "ssh_key" {
value = module.TestProject.ssh_key
value = module.TestProject.ssh_key
}
Loading