Skip to content

Commit

Permalink
feat: add deployment workflow
Browse files Browse the repository at this point in the history
Add terraform job to deal with the lifecycle of Terraform sources.
Add helm job to deploy the aws-cli chart.
Add AWS configuration file for AWS credentials.
  • Loading branch information
taufort committed Nov 23, 2022
1 parent c839641 commit 20d90aa
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/aws-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[default]
region = eu-west-3
output = json

[profile ippon-sandbox]
aws_access_key_id = __AWS_ACCESS_KEY_ID__
aws_secret_access_key = __AWS_SECRET_ACCESS_KEY__
86 changes: 86 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---

name: Deployment

on:
push:
branches: [main]
pull_request:
branches: [main]

defaults:
run:
shell: bash

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
terraform:
name: Terraform
runs-on: ubuntu-latest
defaults:
run:
working-directory: terraform
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ~1.0

- name: Setup Terragrunt
uses: autero1/action-terragrunt@v1.2.0
with:
terragrunt_version: 0.40.2

- name: Set up AWS configuration file
run: |
sed
sed -i "s/__AWS_ACCESS_KEY_ID__/${{ secrets.AWS_ACCESS_KEY_ID }}/g" "${{ github.workspace }}/.github/aws-config"
sed -i "s/__AWS_SECRET_ACCESS_KEY__/${{ secrets.AWS_SECRET_ACCESS_KEY }}/g" "${{ github.workspace }}/.github/aws-config"
echo "AWS_CONFIG_FILE=${{ github.workspace }}/.github/aws-config" >> $GITHUB_ENV
- name: Terragrunt run-all init
run: terragrunt run-all init

- name: Terragrunt run-all plan
run: terragrunt run-all plan

- name: Terragrunt run-all apply
if: github.ref == 'refs/heads/main'
run: terragrunt run-all apply

helm:
name: Helm
runs-on: ubuntu-latest
needs: terraform
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Helm
uses: azure/setup-helm@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup AWS CLI
uses: unfor19/install-aws-cli-action@v1
with:
version: 2

- name: Get kubernetes configuration file
run: |
aws eks --region eu-west-3 update-kubeconfig --name aws-eks-irsa
- name: Helm install AWS CLI chart
run: |
helm upgrade \
--install \
--create-namespace \
--namespace aws-eks-irsa \
--set awsAccountId=${{ secrets.AWS_ACCOUNT_ID }} \
aws-cli helm/aws-cli
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ kubectl get pods -n kube-system

You can install the `aws-cli` Helm chart as such (after replacing `<YOUR_AWS_ACCOUNT_ID>` with your account ID):
```bash
helm install --create-namespace --namespace aws-eks-irsa --set awsAccountId=<YOUR_AWS_ACCOUNT_ID> aws-cli helm/aws-cli
helm upgrade --install --create-namespace --namespace aws-eks-irsa --set awsAccountId=<YOUR_AWS_ACCOUNT_ID> aws-cli helm/aws-cli
```

Then, you can check your resources were created into the EKS cluster:
Expand Down

0 comments on commit 20d90aa

Please sign in to comment.