diff --git a/.github/actions/api-deploy-ecs/action.yml b/.github/actions/api-deploy-ecs/action.yml index 0c58c89a984d..b27b398f9441 100644 --- a/.github/actions/api-deploy-ecs/action.yml +++ b/.github/actions/api-deploy-ecs/action.yml @@ -2,11 +2,8 @@ name: API Deploy to ECS description: Deploy the Flagsmith API to ECS inputs: - aws_access_key_id: - description: The AWS access key ID to use for deploying to ECS. - required: true - aws_secret_access_key: - description: The AWS secret access key to use for deploying to ECS. + aws_role_arn: + description: The ARN of the AWS role to use for deploying to ECS required: true # TODO: do we need cluster name and ARN aws_ecs_cluster_name: @@ -55,8 +52,7 @@ runs: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 with: - aws-access-key-id: ${{ inputs.aws_access_key_id }} - aws-secret-access-key: ${{ inputs.aws_secret_access_key }} + role-to-assume: ${{ inputs.aws_role_arn }} aws-region: eu-west-2 - name: Render SDK API task definition @@ -87,9 +83,6 @@ runs: - name: Register and perform SQL schema migration id: register-migrate-task env: - AWS_ACCESS_KEY_ID: ${{ inputs.aws_access_key_id }} - AWS_SECRET_ACCESS_KEY: ${{ inputs.aws_secret_access_key }} - AWS_DEFAULT_REGION: eu-west-2 TASK_DEFINITION: ${{ steps.task-def-migration.outputs.task-definition }} run: | echo "task_definition_arn=$(aws ecs register-task-definition --cli-input-json file://$TASK_DEFINITION | jq '.taskDefinition.taskDefinitionArn')" >> $GITHUB_OUTPUT diff --git a/.github/actions/task-processor-deploy-ecs/action.yml b/.github/actions/task-processor-deploy-ecs/action.yml index feea24590283..87bb91a437de 100644 --- a/.github/actions/task-processor-deploy-ecs/action.yml +++ b/.github/actions/task-processor-deploy-ecs/action.yml @@ -2,11 +2,8 @@ name: Task Processor Deploy to ECS description: Deploy the Flagsmith Task Processor to ECS inputs: - aws_access_key_id: - description: The AWS access key ID to use for deploying to ECS. - required: true - aws_secret_access_key: - description: The AWS secret access key to use for deploying to ECS. + aws_role_arn: + description: The ARN of the AWS role to use for deploying to ECS required: true aws_ecs_cluster_name: description: The name of the ECS cluster to deploy to. @@ -28,8 +25,7 @@ runs: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 with: - aws-access-key-id: ${{ inputs.aws_access_key_id }} - aws-secret-access-key: ${{ inputs.aws_secret_access_key }} + role-to-assume: ${{ inputs.aws_role_arn }} aws-region: eu-west-2 - name: Fill in the new image ID in the Amazon ECS Task Processor task definition diff --git a/.github/workflows/.reusable-deploy-ecs.yml b/.github/workflows/.reusable-deploy-ecs.yml index d5ed11e0ce08..1b66b3034cc3 100644 --- a/.github/workflows/.reusable-deploy-ecs.yml +++ b/.github/workflows/.reusable-deploy-ecs.yml @@ -35,10 +35,8 @@ jobs: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 with: - aws-access-key-id: ${{ vars.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + role-to-assume: ${{ vars.AWS_ROLE_ARN }} aws-region: eu-west-2 - mask-aws-account-id: 'no' - name: Login to Amazon ECR id: login-ecr @@ -76,6 +74,9 @@ jobs: needs: docker-build-saas-api environment: ${{ inputs.environment }} runs-on: depot-ubuntu-latest + permissions: + contents: read + id-token: write steps: - name: Cloning repo uses: actions/checkout@v5 @@ -84,8 +85,7 @@ jobs: id: deploy-api uses: ./.github/actions/api-deploy-ecs with: - aws_access_key_id: ${{ vars.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws_role_arn: ${{ vars.AWS_ROLE_ARN }} aws_ecs_cluster_name: ${{ vars.AWS_ECS_CLUSTER_NAME }} aws_ecs_cluster_arn: ${{ vars.AWS_ECS_CLUSTER_ARN }} aws_ecs_service_name: ${{ vars.AWS_ECS_SERVICE_NAME }} @@ -101,8 +101,7 @@ jobs: - name: Deploy Task processor to ${{ inputs.environment }} uses: ./.github/actions/task-processor-deploy-ecs with: - aws_access_key_id: ${{ vars.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws_role_arn: ${{ vars.AWS_ROLE_ARN }} aws_ecs_cluster_name: ${{ vars.AWS_ECS_CLUSTER_NAME }} aws_ecs_service_name: ${{ vars.AWS_ECS_TASK_PROCESSOR_SERVICE_NAME }} aws_task_definitions_directory_path: infrastructure/aws/${{ inputs.environment }} @@ -127,13 +126,11 @@ jobs: run: | sudo apt-get remove -y firefox || true sudo rm -rf /usr/bin/firefox /usr/lib/firefox* - ARCH=$(uname -m) wget -O /tmp/firefox.tar.xz "https://ftp.mozilla.org/pub/firefox/releases/143.0/linux-${ARCH}/en-US/firefox-143.0.tar.xz" sudo tar -xJf /tmp/firefox.tar.xz -C /opt sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox rm /tmp/firefox.tar.xz - firefox --version - name: Run E2E tests against ${{ inputs.environment }}