Skip to content

Commit

Permalink
Reinsert aws default region env var (#708)
Browse files Browse the repository at this point in the history
* Reinsert aws default region env var

* Use explicit job for setting env var output

* Fix tab spacing

* revert region changes to app signal wfs

* revert 703 changes fully
  • Loading branch information
bryan-aguilar authored Jan 10, 2024
1 parent 6c850da commit 2c9c129
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 43 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/appsignals-e2e-ec2-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ permissions:
contents: read

env:
# The precense of this env var is required for use by terraform and AWS CLI commands
# It is not redundant
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}
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"
Expand All @@ -39,10 +42,10 @@ jobs:

- name: Set CW Agent RPM environment variable
run: |
if [ ${{ inputs.aws-region }} == "us-east-1" ]; then
if [ ${{ env.AWS_DEFAULT_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-${{ inputs.aws-region }}.s3.${{ inputs.aws-region }}.amazonaws.com/amazon_linux/amd64/1.300031.0b313/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV
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
fi
Expand All @@ -53,7 +56,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.E2E_TEST_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Set up terraform
uses: hashicorp/setup-terraform@v3
Expand All @@ -76,7 +79,7 @@ jobs:
echo "Attempt $retry_counter"
deployment_failed=0
terraform apply -auto-approve \
-var="aws_region=${{ inputs.aws-region }}" \
-var="aws_region=${{ env.AWS_DEFAULT_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 }}" \
Expand Down Expand Up @@ -170,7 +173,7 @@ jobs:
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -187,7 +190,7 @@ jobs:
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -204,7 +207,7 @@ jobs:
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.MAIN_SERVICE_ENDPOINT }}
--remote-service-deployment-name ${{ env.REMOTE_SERVICE_IP }}:8080
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -222,13 +225,13 @@ jobs:
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
--value 0.0 \
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_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 ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
fi
Expand Down
37 changes: 20 additions & 17 deletions .github/workflows/appsignals-e2e-eks-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ permissions:
contents: read

env:
# The precense of this env var is required for use by terraform and AWS CLI commands
# It is not redundant
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}
TEST_ACCOUNT: ${{ secrets.APP_SIGNALS_E2E_TEST_ACC }}
ENABLEMENT_SCRIPT_S3_BUCKET: ${{ secrets.APP_SIGNALS_E2E_ENABLEMENT_SCRIPT }}
SAMPLE_APP_NAMESPACE: sample-app-namespace
Expand All @@ -45,13 +48,13 @@ jobs:
distribution: temurin

- name: Generate testing id
run: echo TESTING_ID="${{ inputs.aws-region }}-${{ github.run_id }}-${{ github.run_number }}" >> $GITHUB_ENV
run: echo TESTING_ID="${{ env.AWS_DEFAULT_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: ${{ inputs.aws-region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

# local directory to store the kubernetes config
- name: Create kubeconfig directory
Expand All @@ -61,7 +64,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 ${{ inputs.aws-region }}
run: aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ env.AWS_DEFAULT_REGION }}

- name: Install eksctl
run: |
Expand All @@ -79,7 +82,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 ${{ inputs.aws-region }} \
--region ${{ env.AWS_DEFAULT_REGION }} \
--approve
- name: Set up terraform
Expand Down Expand Up @@ -117,7 +120,7 @@ jobs:
deployment_failed=0
terraform apply -auto-approve \
-var="test_id=${{ env.TESTING_ID }}" \
-var="aws_region=${{ inputs.aws-region }}" \
-var="aws_region=${{ env.AWS_DEFAULT_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)" \
Expand All @@ -137,7 +140,7 @@ jobs:
echo "Installing app signals to the sample app"
./enable-app-signals.sh \
${{ inputs.test-cluster-name }} \
${{ inputs.aws-region }} \
${{ env.AWS_DEFAULT_REGION }} \
${{ env.SAMPLE_APP_NAMESPACE }}
# If the workflow provides a specific ADOT image to test, patch the deployment and restart CW agent related pods
Expand Down Expand Up @@ -175,16 +178,16 @@ jobs:
echo "Cleaning up App Signal"
./clean-app-signals.sh \
${{ inputs.test-cluster-name }} \
${{ inputs.aws-region }} \
${{ env.AWS_DEFAULT_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 ${{ inputs.aws-region }}
aws eks update-kubeconfig --name ${{ inputs.test-cluster-name }} --region ${{ env.AWS_DEFAULT_REGION }}
echo "Destroying terraform"
terraform destroy -auto-approve \
-var="test_id=${{ env.TESTING_ID }}" \
-var="aws_region=${{ inputs.aws-region }}" \
-var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
-var="kube_directory_path=${{ github.workspace }}/.kube" \
-var="eks_cluster_name=${{ inputs.test-cluster-name }}" \
-var="test_namespace=${{ env.SAMPLE_APP_NAMESPACE }}" \
Expand Down Expand Up @@ -254,7 +257,7 @@ jobs:
run: ./gradlew testing:validator:run --args='-c eks/log-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.APP_ENDPOINT }}
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -271,7 +274,7 @@ jobs:
run: ./gradlew testing:validator:run --args='-c eks/metric-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.APP_ENDPOINT }}
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -289,7 +292,7 @@ jobs:
run: ./gradlew testing:validator:run --args='-c eks/trace-validation.yml
--testing-id ${{ env.TESTING_ID }}
--endpoint http://${{ env.APP_ENDPOINT }}
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
--account-id ${{ env.TEST_ACCOUNT }}
--metric-namespace ${{ env.METRIC_NAMESPACE }}
--log-group ${{ env.LOG_GROUP_NAME }}
Expand All @@ -308,13 +311,13 @@ jobs:
--metric-name Failure \
--dimensions repository=${{ github.repository }},branch=${{ github.ref_name }},workflow=${{ inputs.caller-workflow-name }} \
--value 0.0 \
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_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 ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
fi
# Clean up Procedures
Expand All @@ -326,7 +329,7 @@ jobs:
run: |
./clean-app-signals.sh \
${{ inputs.test-cluster-name }} \
${{ inputs.aws-region }} \
${{ env.AWS_DEFAULT_REGION }} \
${{ env.SAMPLE_APP_NAMESPACE }}
# This step also deletes lingering resources from previous test runs
Expand All @@ -343,7 +346,7 @@ jobs:
run: |
terraform destroy -auto-approve \
-var="test_id=${{ env.TESTING_ID }}" \
-var="aws_region=${{ inputs.aws-region }}" \
-var="aws_region=${{ env.AWS_DEFAULT_REGION }}" \
-var="kube_directory_path=${{ github.workspace }}/.kube" \
-var="eks_cluster_name=${{ inputs.test-cluster-name }}" \
-var="test_namespace=${{ env.SAMPLE_APP_NAMESPACE }}" \
Expand All @@ -358,4 +361,4 @@ jobs:
--name service-account-${{ env.TESTING_ID }} \
--namespace ${{ env.SAMPLE_APP_NAMESPACE }} \
--cluster ${{ inputs.test-cluster-name }} \
--region ${{ inputs.aws-region }}
--region ${{ env.AWS_DEFAULT_REGION }}
12 changes: 8 additions & 4 deletions .github/workflows/e2e-tests-app-with-java-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ permissions:
id-token: write
contents: read

env:
# The precense of this env var is required. It is not redundant
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}

jobs:
build_Images_For_Testing_Sample_App_With_Java_Agent:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -53,7 +57,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Log in to AWS ECR
uses: docker/login-action@v3
Expand Down Expand Up @@ -85,7 +89,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -116,7 +120,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -147,7 +151,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Log in to AWS ECR
uses: docker/login-action@v3
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/e2e-tests-with-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ env:
TESTING_FRAMEWORK_REPO: aws-observability/aws-otel-test-framework
NUM_BATCHES: 2
DDB_TABLE_NAME: BatchTestCache
# The precense of this env var is required. It is not redundant
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}

permissions:
id-token: write
Expand Down Expand Up @@ -61,7 +63,7 @@ jobs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
aws-region: ${{ inputs.aws-region }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Log in to AWS ECR
uses: docker/login-action@v3
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ${{ steps.default_region_output.outputs.aws_default_region }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -134,6 +133,11 @@ jobs:
name: aws-opentelemetry-agent.jar
path: otelagent/build/libs/aws-opentelemetry-agent-*.jar

default-region-output:
runs-on: ubuntu-latest
outputs:
aws_default_region: ${{ steps.default_region_output.outputs.aws_default_region }}
steps:
- name: Set default region output
id: default_region_output
run: |
Expand All @@ -157,23 +161,23 @@ jobs:
concurrency:
group: e2e-adot-agent-operator-test
cancel-in-progress: false
needs: [ build, create-test-ref ]
needs: [ build, create-test-ref, default-region-output ]
uses: ./.github/workflows/e2e-tests-with-operator.yml
secrets: inherit
with:
aws-region: ${{ needs.build.outputs.aws_default_region }}
aws-region: ${{ needs.default-region-output.outputs.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 }}
caller-workflow-name: 'main-build'

# E2E tests where SampleApp has Java Agent
e2e-test:
needs: build
needs: [build, default-region-output]
uses: ./.github/workflows/e2e-tests-app-with-java-agent.yml
secrets: inherit
with:
aws-region: ${{ needs.build.outputs.aws_default_region }}
aws-region: ${{ needs.default-region-output.outputs.aws_default_region }}
image_tag: ${{ github.sha }}
caller-workflow-name: 'main-build'

Expand Down Expand Up @@ -224,11 +228,11 @@ jobs:
concurrency:
group: e2e-adot-test
cancel-in-progress: false
needs: build
needs: [build, default-region-output]
uses: ./.github/workflows/appsignals-e2e-eks-test.yml
secrets: inherit
with:
aws-region: ${{ needs.build.outputs.aws_default_region }}
aws-region: ${{ needs.default-region-output.outputs.aws_default_region }}
test-cluster-name: "e2e-adot-test"
appsignals-adot-image-name: ${{ needs.build.outputs.staging-image }}
caller-workflow-name: 'main-build'
Expand Down
Loading

0 comments on commit 2c9c129

Please sign in to comment.