Skip to content

Commit

Permalink
initial iac validation code
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbass committed Mar 26, 2024
1 parent edb07b3 commit 60c634a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
31 changes: 2 additions & 29 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
deploy:
name: Build & Deploy
runs-on: ubuntu-latest
environment:
name: staging
url: https://stage.appointment.day

steps:
- name: Checkout
Expand All @@ -50,7 +47,7 @@ jobs:
with:
mask-password: 'true'

- name: Build, tag, and push backend to Amazon ECR
- name: Build, tag, and push backend image to Amazon ECR
id: build-backend
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
Expand All @@ -62,19 +59,6 @@ jobs:
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./backend -f ./backend/deploy.dockerfile
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image_backend=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Build, tag, and push frontend to Amazon ECR
id: build-frontend
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: frontend-${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./frontend -f ./frontend/deploy.dockerfile
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image_frontend=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new backend image ID in the Amazon ECS task definition
id: task-def-backend
Expand All @@ -85,18 +69,7 @@ jobs:
image: ${{ steps.build-backend.outputs.image_backend }}
environment-variables: "RELEASE_VERSION=${{ github.sha }}"

- name: Fill in the new frontend image ID in the Amazon ECS task definition
id: task-def-frontend
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.task-def-backend.outputs.task-definition }}
container-name: ${{ env.CONTAINER_FRONTEND }}
image: ${{ steps.build-frontend.outputs.image_frontend }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def-frontend.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
task-definition: ${{ steps.task-def-backend.outputs.task-definition }}
Empty file added .github/workflows/deploy.yaml
Empty file.
Empty file added .github/workflows/iac_plan.yaml
Empty file.
26 changes: 26 additions & 0 deletions .github/workflows/iac_validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: validate-iac
on:
push:
workflow_call:
env:
tf_version: '1.6.2'
tg_version: '0.55.15'
environment: 'stage'

jobs:
validate-iac:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ env.tf_version }}
- run: |
git clone --depth 1 --branch main https://github.com/tgenv/tgenv.git ~/.tgenv
sudo ln -s ~/.tgenv/bin* /usr/local/bin
tgenv install ${{ env.tg_version }}
- run: |
cd ./tofu/environments/${{ env.environment }}/terraform/tfbackend
terragrun init
terragrunt validate
Empty file added .github/workflows/main.yaml
Empty file.

0 comments on commit 60c634a

Please sign in to comment.