From 41f4c5083d6bb12d2adc8f5b9f58e99e3dfb193e Mon Sep 17 00:00:00 2001 From: bryan-aguilar <46550959+bryan-aguilar@users.noreply.github.com> Date: Tue, 9 Jan 2024 15:11:47 -0800 Subject: [PATCH] Fix usage of input variable in workflows (#703) * remove unncessary build output * Fix region in app signal e2e workflow * Fix incorrect usage of env var * fix nightly build wf also --- .github/workflows/appsignals-e2e-ec2-test.yml | 19 +++++----- .github/workflows/appsignals-e2e-eks-test.yml | 35 +++++++++---------- .../e2e-tests-app-with-java-agent.yml | 11 +++--- .github/workflows/e2e-tests-with-operator.yml | 3 +- .github/workflows/main-build.yml | 7 ++-- .../nightly-upstream-snapshot-build.yml | 5 ++- 6 files changed, 36 insertions(+), 44 deletions(-) diff --git a/.github/workflows/appsignals-e2e-ec2-test.yml b/.github/workflows/appsignals-e2e-ec2-test.yml index 4f9b739549..ba7da719db 100644 --- a/.github/workflows/appsignals-e2e-ec2-test.yml +++ b/.github/workflows/appsignals-e2e-ec2-test.yml @@ -17,7 +17,6 @@ permissions: contents: read env: - AWS_DEFAULT_REGION: ${{ inputs.aws-region }} # Used by terraform and AWS CLI commands TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }} SAMPLE_APP_FRONTEND_SERVICE_JAR: "s3://aws-appsignals-sample-app/main-service.jar" SAMPLE_APP_REMOTE_SERVICE_JAR: "s3://aws-appsignals-sample-app/remote-service.jar" @@ -40,10 +39,10 @@ jobs: - name: Set CW Agent RPM environment variable run: | - if [ ${{ env.AWS_DEFAULT_REGION }} == "us-east-1" ]; then + if [ ${{ inputs.aws-region }} == "us-east-1" ]; then echo APP_SIGNALS_CW_AGENT_RPM="https://amazoncloudwatch-agent-us-east-1.s3.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV else - echo APP_SIGNALS_CW_AGENT_RPM="https://amazoncloudwatch-agent-${{ env.AWS_DEFAULT_REGION }}.s3.${{ env.AWS_DEFAULT_REGION }}.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV + echo APP_SIGNALS_CW_AGENT_RPM="https://amazoncloudwatch-agent-${{ inputs.aws-region }}.s3.${{ inputs.aws-region }}.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV fi @@ -54,7 +53,7 @@ jobs: uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.E2E_TEST_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + aws-region: ${{ inputs.aws-region }} - name: Set up terraform uses: hashicorp/setup-terraform@v3 @@ -77,7 +76,7 @@ jobs: echo "Attempt $retry_counter" deployment_failed=0 terraform apply -auto-approve \ - -var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \ + -var="aws_region=${{ inputs.aws-region }}" \ -var="test_id=${{ env.TESTING_ID }}" \ -var="sample_app_jar=${{ env.SAMPLE_APP_FRONTEND_SERVICE_JAR }}" \ -var="sample_remote_app_jar=${{ env.SAMPLE_APP_REMOTE_SERVICE_JAR }}" \ @@ -171,7 +170,7 @@ jobs: --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }} --remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080 - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} --account-id ${{ env.TEST_ACCOUNT }} --metric-namespace ${{ env.METRIC_NAMESPACE }} --log-group ${{ env.LOG_GROUP_NAME }} @@ -188,7 +187,7 @@ jobs: --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }} --remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080 - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} --account-id ${{ env.TEST_ACCOUNT }} --metric-namespace ${{ env.METRIC_NAMESPACE }} --log-group ${{ env.LOG_GROUP_NAME }} @@ -205,7 +204,7 @@ jobs: --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }} --remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080 - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} --account-id ${{ env.TEST_ACCOUNT }} --metric-namespace ${{ env.METRIC_NAMESPACE }} --log-group ${{ env.LOG_GROUP_NAME }} @@ -223,13 +222,13 @@ jobs: --metric-name Failure \ --dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \ --value 0.0 \ - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} else aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \ --metric-name Failure \ --dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \ --value 1.0 \ - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} fi diff --git a/.github/workflows/appsignals-e2e-eks-test.yml b/.github/workflows/appsignals-e2e-eks-test.yml index 7729bfad6a..303fe20542 100644 --- a/.github/workflows/appsignals-e2e-eks-test.yml +++ b/.github/workflows/appsignals-e2e-eks-test.yml @@ -23,7 +23,6 @@ permissions: contents: read env: - AWS_DEFAULT_REGION: ${{ inputs.aws-region }} # Used by terraform and AWS CLI commands TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }} ENABLEMENT_SCRIPT_S3_BUCKET: ${{ secrets.APP_SIGNALS_E2E_ENABLEMENT_SCRIPT }} SAMPLE_APP_NAMESPACE: sample-app-namespace @@ -46,13 +45,13 @@ jobs: distribution: temurin - name: Generate testing id - run: echo TESTING_ID="${{ env.AWS_DEFAULT_REGION }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV + run: echo TESTING_ID="${{ inputs.aws-region }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.E2E_TEST_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + aws-region: ${{ inputs.aws-region }} # local directory to store the kubernetes config - name: Create kubeconfig directory @@ -62,7 +61,7 @@ jobs: run: echo KUBECONFIG="${{ github.workspace }}/.kube/config" >> $GITHUB_ENV - name: Set up kubeconfig - run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ env.AWS_DEFAULT_REGION }} + run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }} - name: Install eksctl run: | @@ -80,7 +79,7 @@ jobs: --cluster ${{ inputs.test-cluster-name }} \ --role-name eks-s3-access-${{ env.TESTING_ID }} \ --attach-policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess \ - --region ${{ env.AWS_DEFAULT_REGION }} \ + --region ${{ inputs.aws-region }} \ --approve - name: Set up terraform @@ -118,7 +117,7 @@ jobs: deployment_failed=0 terraform apply -auto-approve \ -var="test_id=${{ env.TESTING_ID }}" \ - -var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \ + -var="aws_region=${{ inputs.aws-region }}" \ -var="kube_directory_path=${{ github.workspace }}/.kube" \ -var="eks_cluster_name=${{ inputs.test-cluster-name }}" \ -var="eks_cluster_context_name=$(kubectl config current-context)" \ @@ -138,7 +137,7 @@ jobs: echo "Installing app signals to the sample app" ./enable-app-signals.sh \ ${{ inputs.test-cluster-name }} \ - ${{ env.AWS_DEFAULT_REGION }} \ + ${{ inputs.aws-region }} \ ${{ env.SAMPLE_APP_NAMESPACE }} # If the workflow provides a specific ADOT image to test, patch the deployment and restart CW agent related pods @@ -176,16 +175,16 @@ jobs: echo "Cleaning up App Signal" ./clean-app-signals.sh \ ${{ inputs.test-cluster-name }} \ - ${{ env.AWS_DEFAULT_REGION }} \ + ${{ inputs.aws-region }} \ ${{ env.SAMPLE_APP_NAMESPACE }} # Running clean-app-signal.sh removes the current cluster from the config. Update the cluster again for subsequent runs. - aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ env.AWS_DEFAULT_REGION }} + aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ inputs.aws-region }} echo "Destroying terraform" terraform destroy -auto-approve \ -var="test_id=${{ env.TESTING_ID }}" \ - -var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \ + -var="aws_region=${{ inputs.aws-region }}" \ -var="kube_directory_path=${{ github.workspace }}/.kube" \ -var="eks_cluster_name=${{ inputs.test-cluster-name }}" \ -var="test_namespace=${{ env.SAMPLE_APP_NAMESPACE }}" \ @@ -255,7 +254,7 @@ jobs: run: ./gradlew testing:validator:run --args='-c eks/log-validation.yml --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.APP_ENDPOINT }} - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} --account-id ${{ env.TEST_ACCOUNT }} --metric-namespace ${{ env.METRIC_NAMESPACE }} --log-group ${{ env.LOG_GROUP_NAME }} @@ -272,7 +271,7 @@ jobs: run: ./gradlew testing:validator:run --args='-c eks/metric-validation.yml --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.APP_ENDPOINT }} - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} --account-id ${{ env.TEST_ACCOUNT }} --metric-namespace ${{ env.METRIC_NAMESPACE }} --log-group ${{ env.LOG_GROUP_NAME }} @@ -290,7 +289,7 @@ jobs: run: ./gradlew testing:validator:run --args='-c eks/trace-validation.yml --testing-id ${{ env.TESTING_ID }} --endpoint http://${{ env.APP_ENDPOINT }} - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} --account-id ${{ env.TEST_ACCOUNT }} --metric-namespace ${{ env.METRIC_NAMESPACE }} --log-group ${{ env.LOG_GROUP_NAME }} @@ -309,13 +308,13 @@ jobs: --metric-name Failure \ --dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \ --value 0.0 \ - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} else aws cloudwatch put-metric-data --namespace 'ADOT/GitHubActions' \ --metric-name Failure \ --dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \ --value 1.0 \ - --region ${{ env.AWS_DEFAULT_REGION }} + --region ${{ inputs.aws-region }} fi # Clean up Procedures @@ -327,7 +326,7 @@ jobs: run: | ./clean-app-signals.sh \ ${{ inputs.test-cluster-name }} \ - ${{ env.AWS_DEFAULT_REGION }} \ + ${{ inputs.aws-region }} \ ${{ env.SAMPLE_APP_NAMESPACE }} # This step also deletes lingering resources from previous test runs @@ -344,7 +343,7 @@ jobs: run: | terraform destroy -auto-approve \ -var="test_id=${{ env.TESTING_ID }}" \ - -var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \ + -var="aws_region=${{ inputs.aws-region }}" \ -var="kube_directory_path=${{ github.workspace }}/.kube" \ -var="eks_cluster_name=${{ inputs.test-cluster-name }}" \ -var="test_namespace=${{ env.SAMPLE_APP_NAMESPACE }}" \ @@ -359,4 +358,4 @@ jobs: --name service-account-${{ env.TESTING_ID }} \ --namespace ${{ env.SAMPLE_APP_NAMESPACE }} \ --cluster ${{ inputs.test-cluster-name }} \ - --region ${{ env.AWS_DEFAULT_REGION }} \ No newline at end of file + --region ${{ inputs.aws-region }} \ No newline at end of file diff --git a/.github/workflows/e2e-tests-app-with-java-agent.yml b/.github/workflows/e2e-tests-app-with-java-agent.yml index 985a65c303..36d4f5b698 100644 --- a/.github/workflows/e2e-tests-app-with-java-agent.yml +++ b/.github/workflows/e2e-tests-app-with-java-agent.yml @@ -12,9 +12,6 @@ on: required: true type: string -env: - AWS_DEFAULT_REGION: ${{ inputs.aws-region }} - permissions: id-token: write contents: read @@ -56,7 +53,7 @@ jobs: uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + aws-region: ${{ inputs.aws-region }} - name: Log in to AWS ECR uses: docker/login-action@v3 @@ -88,7 +85,7 @@ jobs: uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + aws-region: ${{ inputs.aws-region }} - name: Log in to AWS ECR uses: docker/login-action@v3 with: @@ -119,7 +116,7 @@ jobs: uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + aws-region: ${{ inputs.aws-region }} - name: Log in to AWS ECR uses: docker/login-action@v3 with: @@ -150,7 +147,7 @@ jobs: uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + aws-region: ${{ inputs.aws-region }} - name: Log in to AWS ECR uses: docker/login-action@v3 with: diff --git a/.github/workflows/e2e-tests-with-operator.yml b/.github/workflows/e2e-tests-with-operator.yml index 5267198029..ed9d19b40f 100644 --- a/.github/workflows/e2e-tests-with-operator.yml +++ b/.github/workflows/e2e-tests-with-operator.yml @@ -19,7 +19,6 @@ on: type: string env: - AWS_DEFAULT_REGION: ${{ inputs.aws-region }} TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework NUM_BATCHES: 2 DDB_TABLE_NAME: BatchTestCache @@ -62,7 +61,7 @@ jobs: uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} - aws-region: ${{ env.AWS_DEFAULT_REGION }} + aws-region: ${{ inputs.aws-region }} - name: Log in to AWS ECR uses: docker/login-action@v3 diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index 4869451c6c..edf91d9de2 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -53,7 +53,6 @@ jobs: staging-image: ${{ steps.imageOutput.outputs.stagingImage }} staging_registry: ${{ steps.imageOutput.outputs.stagingRegistry }} staging_repository: ${{ steps.imageOutput.outputs.stagingRepository }} - aws_default_region: ${{ env.AWS_DEFAULT_REGION }} steps: - uses: actions/checkout@v4 with: @@ -156,7 +155,7 @@ jobs: uses: ./.github/workflows/e2e-tests-with-operator.yml secrets: inherit with: - aws-region: ${{ needs.build.outputs.aws_default_region }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} image_tag: ${{ needs.build.outputs.java_agent_tag }} image_uri: ${{ needs.build.outputs.staging_registry }}/${{ needs.build.outputs.staging_repository }} test_ref: ${{ needs.create-test-ref.outputs.testRef }} @@ -168,7 +167,7 @@ jobs: uses: ./.github/workflows/e2e-tests-app-with-java-agent.yml secrets: inherit with: - aws-region: ${{ needs.build.outputs.aws_default_region }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} image_tag: ${{ github.sha }} caller-workflow-name: 'main-build' @@ -223,7 +222,7 @@ jobs: uses: ./.github/workflows/appsignals-e2e-eks-test.yml secrets: inherit with: - aws-region: ${{ needs.build.outputs.aws_default_region }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} test-cluster-name: "e2e-adot-test" appsignals-adot-image-name: ${{ needs.build.outputs.staging-image }} caller-workflow-name: 'main-build' diff --git a/.github/workflows/nightly-upstream-snapshot-build.yml b/.github/workflows/nightly-upstream-snapshot-build.yml index d73fb11056..09850ec61b 100644 --- a/.github/workflows/nightly-upstream-snapshot-build.yml +++ b/.github/workflows/nightly-upstream-snapshot-build.yml @@ -21,7 +21,6 @@ jobs: release-candidate-image: ${{ steps.imageOutput.outputs.rcImage }} image_registry: ${{ steps.imageOutput.outputs.imageRegistry }} image_name: ${{ steps.imageOutput.outputs.imageName }} - aws_default_region: ${{ env.AWS_DEFAULT_REGION }} steps: - uses: actions/checkout@v4 with: @@ -94,7 +93,7 @@ jobs: uses: ./.github/workflows/e2e-tests-with-operator.yml secrets: inherit with: - aws-region: ${{ needs.build.outputs.aws_default_region }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} image_tag: ${{ needs.build.outputs.time_stamp_tag }} image_uri: ${{ needs.build.outputs.image_registry }}/${{ needs.build.outputs.image_name }} test_ref: 'terraform' @@ -142,7 +141,7 @@ jobs: uses: ./.github/workflows/appsignals-e2e-eks-test.yml secrets: inherit with: - aws-region: ${{ needs.build.outputs.aws_default_region }} + aws-region: ${{ env.AWS_DEFAULT_REGION }} test-cluster-name: "e2e-adot-test" appsignals-adot-image-name: ${{ needs.build.outputs.release-candidate-image }} caller-workflow-name: 'nightly-upstream-snapshot-build'