Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
harrryr committed Jul 26, 2024
1 parent 4c8887a commit cc56ced
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/java-ec2-default-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ jobs:
-var="canary_type=${{ github.job }}" \
|| deployment_failed=$?
echo $(terraform output private_key_content)
echo $(terraform state show aws_key_pair.aws_ssh_key)
echo $(terraform output -json private_key_content)
if [ $deployment_failed -eq 1 ]; then
Expand Down
43 changes: 38 additions & 5 deletions .github/workflows/traffic-generator-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ name: Create and Push Traffic Generator Image
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'traffic-generator/**'
# branches:
# - main
# paths:
# - 'traffic-generator/**'

permissions:
id-token: write
Expand Down Expand Up @@ -58,4 +58,37 @@ jobs:
IMAGE_TAG: traffic-generator
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
upload-files:
runs-on: ubuntu-latest
strategy:
matrix:
aws-region: [ 'us-east-1' ]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.E2E_TEST_ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
aws-region: us-east-1

- name: Retrieve account
uses: aws-actions/aws-secretsmanager-get-secrets@v1
with:
secret-ids: |
ACCOUNT_ID, region-account/${{ matrix.aws-region }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ env.ACCOUNT_ID }}:role/${{ env.E2E_TEST_ROLE_NAME }}
aws-region: ${{ matrix.aws-region }}

- name: Upload traffic generator files
working-directory: traffic-generator
run: |
zip traffic-generator.zip ./index.js ./package.json
aws s3 cp traffic-generator.zip s3://aws-appsignals-sample-app-prod-${{ matrix.aws-region }}/traffic-generator.zip
16 changes: 8 additions & 8 deletions terraform/java/ec2/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ locals {
output "private_key_content" {
description = "The SSH private key content"
value = local.private_key_content
sensitive = false # Mark as sensitive to prevent it from being exposed in logs or outputs
sensitive = true # Mark as sensitive to prevent it from being exposed in logs or outputs
}

data "aws_ami" "ami" {
Expand Down Expand Up @@ -232,7 +232,13 @@ resource "null_resource" "traffic_generator_setup" {
provisioner "remote-exec" {
inline = [
<<-EOF
sudo yum install tmux nodejs -y
# Export the environment variables
export MAIN_ENDPOINT="localhost:8080"
export REMOTE_ENDPOINT="${aws_instance.remote_service_instance.public_ip}"
export ID="${var.test_id}"
export CANARY_TYPE="${var.canary_type}"
sudo yum install nodejs -y
# Bring in the traffic generator files to EC2 Instance
traffic_generator_index='${file("../../../../traffic-generator/index.js")}'
Expand All @@ -244,12 +250,6 @@ resource "null_resource" "traffic_generator_setup" {
# Install the traffic generator dependencies
npm install
# Export the environment variables
export MAIN_ENDPOINT="localhost:8080"
export REMOTE_ENDPOINT="${aws_instance.remote_service_instance.public_ip}"
export ID="${var.test_id}"
export CANARY_TYPE="${var.canary_type}"
# Start the application
npm start
Expand Down

0 comments on commit cc56ced

Please sign in to comment.