Skip to content

Commit

Permalink
more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jburns24 committed Sep 11, 2023
1 parent a9ea840 commit c6a6ea0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/build-infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ jobs:
run: |
sudo apt install jq tree
- name: Get ECR arn
## Fetch output from our terraform
- name: Pull Terrafrom output into GitHub Action ENV
run: |
pwd
tree -dL 2
echo "ecr_repository_url=$(terragrunt output --json | jq .ecr_repository_url.value -r)" >> $GITHUB_ENV
echo "ecs_task_arn=$(terragrunt output --json | jq .ecs_task_arn.value -r)" >> $GITHUB_ENV
echo "ecs_service_arn=$(terragrunt output --json | jq .ecs_service_arn.value -r)" >> $GITHUB_ENV
echo "ecs_cluster_arn=$(terragrunt output --json | jq .ecs_cluster_arn.value -r)" >> $GITHUB_ENV
working-directory: terraform

- name: Fetch ECS Repo Url
Expand All @@ -62,3 +64,24 @@ jobs:
with:
push: true
tags: ${{ env.ecr_repository_url }}:latest , ${{ env.ecr_repository_url }}:${{ github.sha }}

- name: Pull task-definition.json to update ECS cluster
id: pull-ecs-task-definition
run: |
aws ecs describe-task-definition --task-definition ${{ env.ecs_task_arn }} --region ${{ env.AWS_REGION }} --output json >> task-definition.json
- name: Render Amazon ECS task definition
id: render-web-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: knowledgeshare-ui
image: ${{ env.ecr_repository_url }}:latest
environment-variables: "LOG_LEVEL=info"

- name: Deploy to Amazon ECS service
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-web-container.outputs.task-definition }}
service: ${{ env.ecs_service_arn }}
cluster: ${{ env.ecs_cluster_arn }}
4 changes: 2 additions & 2 deletions terraform/_outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ output "ecs_task_arn" {
description = "ARN of the ECS task definition"
}

output "ecs_service_id" {
output "ecs_service_arn" {
value = aws_ecs_service.knowledgeshare_ui_service.id
description = "ID of the ECS Service"
description = "ARN of the ECS Service"
}
2 changes: 1 addition & 1 deletion terraform/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resource "aws_ecs_cluster" "knowledgeshare_ui_ecs_cluster" {
resource "aws_ecs_task_definition" "knowledgeshare_ui_task" {
family = "knowledgeshare-service"
container_definitions = jsonencode([{
name = "knowledgeshare-ui"
name = "knowledgeshare-ui" # TODO make this a variable that can be made into output so we can fetch programatically
image = "${aws_ecr_repository.knowledgeshare_ui_ecr.repository_url}:latest"
memory = 512
essential = true
Expand Down

0 comments on commit c6a6ea0

Please sign in to comment.