Skip to content
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
16 changes: 16 additions & 0 deletions .github/actions/terraform-apply/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: terraform apply

inputs:
working-directory:
required: true

runs:
using: "composite"
steps:
- name: Terraform Init
run: terraform -chdir=${{ inputs.working-directory }} init
shell: bash

- name: Terraform Apply
run: terraform -chdir=${{ inputs.working-directory }} apply -auto-approve
shell: bash
16 changes: 16 additions & 0 deletions .github/actions/terraform-destroy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: terraform destroy

inputs:
working-directory:
required: true

runs:
using: "composite"
steps:
- name: Terraform Init
run: terraform -chdir=${{ inputs.working-directory }} init
shell: bash

- name: Terraform Destroy
run: terraform -chdir=${{ inputs.working-directory }} destroy -auto-approve
shell: bash
20 changes: 20 additions & 0 deletions .github/actions/terraform-validate/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: terraform validate

inputs:
working-directory:
required: true

runs:
using: "composite"
steps:
- name: Terraform Init
run: terraform -chdir=${{ inputs.working-directory }} init
shell: bash

- name: Terraform Format
run: terraform -chdir=${{ inputs.working-directory }} fmt -check -recursive
shell: bash

- name: Terraform Validate
run: terraform -chdir=${{ inputs.working-directory }} validate
shell: bash
74 changes: 74 additions & 0 deletions .github/workflows/aws-eks-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: aws eks terraform verification

on:
push:
paths:
- ".github/actions/terraform-*/action.yml"
- ".github/workflows/aws-eks-verify.yml"
- "aws/eks/eks-terraform-scripts/**"
- "!**.md"
pull_request:
paths:
- ".github/actions/terraform-*/action.yml"
- ".github/workflows/aws-eks-verify.yml"
- "aws/eks/eks-terraform-scripts/**"
- "!**.md"
workflow_dispatch:

env:
TF_IN_AUTOMATION: true
TF_INPUT: false
TF_CLI_ARGS: "-no-color"
WORKING_DIRECTORY: aws/eks/eks-terraform-scripts

jobs:
validate:
runs-on: ubuntu-latest
outputs:
eks-ok: ${{ steps.check-eks-secrets.outputs.eks-ok }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup terraform
uses: hashicorp/setup-terraform@v1.3.2
- name: Validate eks terraform
uses: ./.github/actions/terraform-validate
with:
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: check for secrets needed for eks deploy
id: check-eks-secrets
run: |
if [ ! -z "${{ secrets.AWS_ACCESS_KEY_ID }}" ]; then
echo "::set-output name=eks-ok::true"
fi

ephemeral-deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
needs: validate
if: ${{ needs.validate.outputs.eks-ok == 'true' }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup terraform
uses: hashicorp/setup-terraform@v1.3.2
- name: Setup kubectl
uses: azure/setup-kubectl@v1
- name: Make sure we have destroyed any leftover resources from previous runs
uses: ./.github/actions/terraform-destroy
with:
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Apply eks terraform
uses: ./.github/actions/terraform-apply
with:
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Destroy eks terraform
if: always()
uses: ./.github/actions/terraform-destroy
with:
working-directory: ${{ env.WORKING_DIRECTORY }}
3 changes: 1 addition & 2 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ jobs:
- uses: actions/checkout@v2

- name: Setup Terraform
# Long commit hash of v1.2.1
uses: hashicorp/setup-terraform@d22444889af304a44b997011fbabb81ff705a7b4
uses: hashicorp/setup-terraform@v1.3.2

- name: Terraform Format
id: fmt
Expand Down
13 changes: 2 additions & 11 deletions aws/eks/eks-terraform-scripts/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@

provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
token = data.aws_eks_cluster_auth.cluster.token
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
exec {
api_version = "client.authentication.k8s.io/v1alpha1"
command = "aws"
args = [
"eks",
"get-token",
"--cluster-name",
data.aws_eks_cluster.cluster.name
]
}
}
}