diff --git a/.github/actions/cdktf/action.yml b/.github/actions/cdktf/action.yml index f44eafb42..ac5560b87 100644 --- a/.github/actions/cdktf/action.yml +++ b/.github/actions/cdktf/action.yml @@ -90,7 +90,7 @@ runs: cd ${{ inputs.stack-output-path }} if [ "${{ inputs.behavior }}" = "apply" ]; then echo "Apply behavior specified, applying terraform configuration in ${{ inputs.environment }}." - terraform apply + terraform apply --auto-approve else echo "Plan behavior specified, planning terraform configuration in ${{ inputs.environment }}." tfcmt --var target:${{ inputs.scope }}-${{ inputs.environment }} plan --skip-no-changes --patch -- terraform plan -lock-timeout=10m diff --git a/.github/actions/containerize/action.yml b/.github/actions/containerize/action.yml index 311dbe4c5..381be5d4d 100644 --- a/.github/actions/containerize/action.yml +++ b/.github/actions/containerize/action.yml @@ -79,5 +79,4 @@ runs: id: get-build-name shell: bash run: | - imageName=${{ fromJSON(steps.docker-build-push.outputs.metadata)['image.name'] }} - echo "::set-output name=docker-image-name::$imageName" \ No newline at end of file + echo "docker-image-name=${{inputs.docker-repo-name}}:${{ github.sha }}" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/actions/ecs-codedeploy/action.yml b/.github/actions/ecs-codedeploy/action.yml index 43e056456..2493ae2e2 100644 --- a/.github/actions/ecs-codedeploy/action.yml +++ b/.github/actions/ecs-codedeploy/action.yml @@ -10,32 +10,13 @@ inputs: runs: using: 'composite' - steps: - # Pulls out the terraform params needed for CodeDeploy and then re-saves them to be used in the CodeDeploy ORB - # - name: Load CodeDeploy Params from Terraform Output - # shell: bash - # run: | - # TF_OUTPUT=${{inputs.terraform-output}} - # ECS_TASK_ARN=$(echo "$TF_OUTPUT" | jq -r '.["ecs-task-arn"].value') - # ECS_TASK_CONTAINER_NAME=$(echo "$TF_OUTPUT" | jq -r '.["ecs-task-containerName"].value') - # ECS_TASK_CONTAINER_PORT=$(echo "$TF_OUTPUT" | jq -r '.["ecs-task-containerPort"].value') - # ECS_TASK_FAMILY=$(echo "$TF_OUTPUT" | jq -r '.["ecs-task-family"].value') - # ECS_CODEDEPLOY_GROUP=$(echo "$TF_OUTPUT" | jq -r '.["ecs-codedeploy-group"].value') - # ECS_CODEDEPLOY_APP=$(echo "$TF_OUTPUT" | jq -r '.["ecs-codedeploy-app"].value') - - # echo "export ECS_TASK_ARN=$ECS_TASK_ARN" >> $GITHUB_ENV - # echo "export ECS_TASK_CONTAINER_NAME=$ECS_TASK_CONTAINER_NAME" >> $GITHUB_ENV - # echo "export ECS_TASK_CONTAINER_PORT=$ECS_TASK_CONTAINER_PORT" >> $GITHUB_ENV - # echo "export ECS_TASK_FAMILY=$ECS_TASK_FAMILY" >> $GITHUB_ENV - # echo "export ECS_CODEDEPLOY_GROUP=$ECS_CODEDEPLOY_GROUP" >> $GITHUB_ENV - # echo "export ECS_CODEDEPLOY_APP=$ECS_CODEDEPLOY_APP" >> $GITHUB_ENV - + steps: - name: Render Amazon ECS task definition id: task-def uses: aws-actions/amazon-ecs-render-task-definition@v1 with: - task-definition-family: ${{ fromJSON(inputs.terraform-output).ecs-task-family }} - container-name: ${{ fromJSON(inputs.terraform-output).ecs-task-containerName }} + task-definition-family: ${{ fromJSON(inputs.terraform-output).ecs-task-family.value }} + container-name: ${{ fromJSON(inputs.terraform-output).ecs-task-containerName.value }} image: ${{ inputs.docker-image-name }} - name: Render Amazon ECS App Spec shell: bash @@ -50,8 +31,8 @@ runs: "Properties": { "TaskDefinition": "", "LoadBalancerInfo": { - "ContainerName": "${{ fromJSON(inputs.terraform-output).ecs-task-containerName }}", - "ContainerPort": ${{ fromJSON(inputs.terraform-output).ecs-task-containerPort }} + "ContainerName": "${{ fromJSON(inputs.terraform-output).ecs-task-containerName.value }}", + "ContainerPort": ${{ fromJSON(inputs.terraform-output).ecs-task-containerPort.value }} } } } @@ -63,8 +44,9 @@ runs: uses: aws-actions/amazon-ecs-deploy-task-definition@v2 with: task-definition: ${{ steps.task-def.outputs.task-definition }} - wait-for-service-stability: true - wait-for-task-stopped: false + service: ${{ fromJSON(inputs.terraform-output).ecs-serviceName.value }} + cluster: ${{ fromJSON(inputs.terraform-output).ecs-clusterName.value }} + wait-for-service-stability: false codedeploy-appspec: appspec.json - codedeploy-application: ${{ fromJSON(inputs.terraform-output).ecs-codedeploy-app }} - codedeploy-deployment-group: ${{ env.ecs-codedeploy-group }} \ No newline at end of file + codedeploy-application: ${{ fromJSON(inputs.terraform-output).ecs-codedeploy-app.value }} + codedeploy-deployment-group: ${{ env.ecs-codedeploy-group.value }} \ No newline at end of file diff --git a/.github/actions/raw-terraform/action.yml b/.github/actions/raw-terraform/action.yml index a452f974c..67156337b 100644 --- a/.github/actions/raw-terraform/action.yml +++ b/.github/actions/raw-terraform/action.yml @@ -90,7 +90,7 @@ runs: cd ${{ inputs.stack-output-path }} if [ "${{ inputs.behavior }}" = "apply" ]; then echo "Apply behavior specified, applying terraform configuration in ${{ inputs.environment }}." - terraform apply + terraform apply --auto-approve else echo "Plan behavior specified, planning terraform configuration in ${{ inputs.environment }}." tfcmt --var target:${{ inputs.scope }}-${{ inputs.environment }} plan --skip-no-changes --patch -- terraform plan -lock-timeout=10m diff --git a/.github/workflows/account-data-deleter.yml b/.github/workflows/account-data-deleter.yml index c336c61cd..662290b5d 100644 --- a/.github/workflows/account-data-deleter.yml +++ b/.github/workflows/account-data-deleter.yml @@ -40,7 +40,7 @@ jobs: secrets: inherit # Let's try building and conidtionally pushing our docker image to the necessary account. - build-and-push-image: + api: uses: ./.github/workflows/reuse-build-and-push-image.yml needs: [infrastructure] with: @@ -49,10 +49,11 @@ jobs: app-port: 4015 sentry-project: account-data-deleter docker-repo-name-pattern: accountdatadeleter-{0}-app + terraform-output: ${{needs.infrastructure.outputs.terraform-output}} # Ensure the re-usable workflow is allowed to access the secrets secrets: inherit - build-and-push-lambda-events: + events-lambda: uses: ./.github/workflows/reuse-build-and-push-lambda.yml needs: [infrastructure] with: @@ -62,7 +63,7 @@ jobs: # Ensure the re-usable workflow is allowed to access the secrets secrets: inherit - build-and-push-lambda-batch-delete: + batch-delete-lambda: uses: ./.github/workflows/reuse-build-and-push-lambda.yml needs: [infrastructure] with: diff --git a/.github/workflows/list-api.yml b/.github/workflows/list-api.yml index f7c2b5a97..d57aa4dc4 100644 --- a/.github/workflows/list-api.yml +++ b/.github/workflows/list-api.yml @@ -33,13 +33,15 @@ jobs: # Ensure the re-usable workflow is allowed to access the secrets secrets: inherit - build-and-push-image: + api: uses: ./.github/workflows/reuse-build-and-push-image.yml + needs: [infrastructure] with: scope: list-api app-path: servers/list-api app-port: 4005 sentry-project: list-api docker-repo-name-pattern: listapi-{0}-app + terraform-output: ${{needs.infrastructure.outputs.terraform-output}} # Ensure the re-usable workflow is allowed to access the secrets secrets: inherit \ No newline at end of file diff --git a/.github/workflows/reuse-infrastructure.yml b/.github/workflows/reuse-infrastructure.yml index 22bc636cd..ae0b3b896 100644 --- a/.github/workflows/reuse-infrastructure.yml +++ b/.github/workflows/reuse-infrastructure.yml @@ -135,11 +135,10 @@ jobs: pagerduty-token: ${{ secrets.PAGERDUTY_TOKEN }} terraform-token: ${{ secrets.TERRAFORM_TOKEN }} - - name: Set Output Based on Condition + - name: Set terraform output id: set_output run: | echo "Grabbing Terraform Output" cd ${{inputs['stack-output-path']}} - echo "terraform-output=$(terraform output -json)" >> $GITHUB_OUTPUT - echo '::set-output name=terraform-output::' + echo "terraform-output=$(terraform output -json | jq -c)" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/workflows/user-api.yml b/.github/workflows/user-api.yml index 5cb9f464c..db4399c1e 100644 --- a/.github/workflows/user-api.yml +++ b/.github/workflows/user-api.yml @@ -38,7 +38,7 @@ jobs: secrets: inherit # Let's try building and conidtionally pushing our docker image to the necessary account. - build-and-push-image: + api: uses: ./.github/workflows/reuse-build-and-push-image.yml needs: [infrastructure] with: @@ -47,6 +47,7 @@ jobs: app-port: 4006 sentry-project: user-api docker-repo-name-pattern: userapi-{0}-app + terraform-output: ${{needs.infrastructure.outputs.terraform-output}} # Ensure the re-usable workflow is allowed to access the secrets secrets: inherit diff --git a/infrastructure/user-list-search/apollo_ecs.tf b/infrastructure/user-list-search/apollo_ecs.tf index 1d3d46e02..519daa036 100644 --- a/infrastructure/user-list-search/apollo_ecs.tf +++ b/infrastructure/user-list-search/apollo_ecs.tf @@ -141,6 +141,21 @@ output "ecs-task-arn" { value = aws_ecs_task_definition.apollo.arn } +output "ecs-serviceName" { + description = "ECS Service Name" + value = aws_ecs_service.apollo.name +} + +output "ecs-task-arn" { + description = "ECS Task Arn" + value = aws_ecs_task_definition.apollo.arn +} + +output "ecs-clusterName" { + description = "ECS Cluster Name" + value = aws_ecs_service.apollo.cluster.name +} + resource "aws_ecs_service" "apollo" { name = "Apollo" task_definition = aws_ecs_task_definition.apollo.arn diff --git a/packages/terraform-modules/src/base/ApplicationECSService.ts b/packages/terraform-modules/src/base/ApplicationECSService.ts index a6f1d4a2b..b2b499542 100644 --- a/packages/terraform-modules/src/base/ApplicationECSService.ts +++ b/packages/terraform-modules/src/base/ApplicationECSService.ts @@ -368,6 +368,18 @@ export class ApplicationECSService extends Construct { value: taskDef.family, staticId: true, }); + + new TerraformOutput(this, 'ecs-clusterName', { + description: 'ECS Cluster Name', + value: config.ecsClusterName, + staticId: true, + }); + + new TerraformOutput(this, 'ecs-serviceName', { + description: 'ECS Service Name', + value: this.service.name, + staticId: true, + }); } /**