Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/node-ec2-default-retry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ on:
caller-workflow-name:
required: true
type: string
node-version:
description: "Currently support version 14, 16, 18, 20, 22"
required: false
type: string
# 'none' means to use the node version come with the OS
default: 'none'
cpu-architecture:
description: "Permitted values: x86_64 or arm64"
required: false
type: string
default: "x86_64"

permissions:
id-token: write
Expand All @@ -26,6 +37,8 @@ jobs:
with:
aws-region: ${{ inputs.aws-region }}
caller-workflow-name: ${{ inputs.caller-workflow-name }}
node-version: ${{ inputs.node-version }}
cpu-architecture: ${{ inputs.cpu-architecture }}

node-ec2-default-attempt-2:
needs: [ node-ec2-default-attempt-1 ]
Expand All @@ -35,6 +48,8 @@ jobs:
with:
aws-region: ${{ inputs.aws-region }}
caller-workflow-name: ${{ inputs.caller-workflow-name }}
node-version: ${{ inputs.node-version }}
cpu-architecture: ${{ inputs.cpu-architecture }}

publish-metric-attempt-1:
needs: [ node-ec2-default-attempt-1, node-ec2-default-attempt-2 ]
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/node-ec2-default-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ on:
caller-workflow-name:
required: true
type: string
node-version:
description: "Currently support version 14, 16, 18, 20, 22"
required: false
type: string
# 'none' means to use the node version come with the OS
default: 'none'
cpu-architecture:
description: "Permitted values: x86_64 or arm64"
required: false
type: string
default: "x86_64"
staging-instrumentation-name:
required: false
default: '@aws/aws-distro-opentelemetry-node-autoinstrumentation'
Expand All @@ -31,6 +42,8 @@ permissions:
env:
E2E_TEST_AWS_REGION: ${{ inputs.aws-region }}
CALLER_WORKFLOW_NAME: ${{ inputs.caller-workflow-name }}
NODE_VERSION: ${{ inputs.node-version }}
CPU_ARCHITECTURE: ${{ inputs.cpu-architecture }}
ADOT_INSTRUMENTATION_NAME: ${{ inputs.staging-instrumentation-name }}
SAMPLE_APP_ZIP: s3://aws-appsignals-sample-app-prod-${{ inputs.aws-region }}/node-sample-app.zip
E2E_TEST_ACCOUNT_ID: ${{ secrets.APPLICATION_SIGNALS_E2E_TEST_ACCOUNT_ID }}
Expand All @@ -52,7 +65,7 @@ jobs:
run: echo "job-started=true" >> $GITHUB_OUTPUT

- name: Generate testing id
run: echo TESTING_ID="${{ github.job }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" >> $GITHUB_ENV
run: echo TESTING_ID="${{ github.job }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}-${{ inputs.node-version }}-${{ inputs.cpu-architecture }}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -105,7 +118,11 @@ jobs:
if [ "${{ github.event.repository.name }}" = "amazon-cloudwatch-agent" ]; then
echo GET_CW_AGENT_RPM_COMMAND="aws s3 cp s3://${{ secrets.S3_INTEGRATION_BUCKET }}/integration-test/binary/${{ github.sha }}/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm ./cw-agent.rpm" >> $GITHUB_ENV
else
echo GET_CW_AGENT_RPM_COMMAND="wget -O cw-agent.rpm https://amazoncloudwatch-agent-${{ env.E2E_TEST_AWS_REGION }}.s3.${{ env.E2E_TEST_AWS_REGION }}.amazonaws.com/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV
architecture="amd64"
if [ "${{ inputs.cpu-architecture }}" = "arm64" ]; then
architecture="arm64"
fi
echo GET_CW_AGENT_RPM_COMMAND="wget -O cw-agent.rpm https://amazoncloudwatch-agent-${{ env.E2E_TEST_AWS_REGION }}.s3.${{ env.E2E_TEST_AWS_REGION }}.amazonaws.com/amazon_linux/${architecture}/latest/amazon-cloudwatch-agent.rpm" >> $GITHUB_ENV
fi

- name: Set up terraform
Expand Down Expand Up @@ -142,6 +159,8 @@ jobs:
-var="sample_app_zip=${{ env.SAMPLE_APP_ZIP }}" \
-var="get_cw_agent_rpm_command=${{ env.GET_CW_AGENT_RPM_COMMAND }}" \
-var="get_adot_instrumentation_command=${{ env.GET_ADOT_INSTRUMENTATION_COMMAND }}" \
-var="language_version=${{ env.NODE_VERSION }}" \
-var="cpu_architecture=${{ env.CPU_ARCHITECTURE }}" \
|| deployment_failed=$?

if [ $deployment_failed -eq 1 ]; then
Expand Down
40 changes: 34 additions & 6 deletions terraform/node/ec2/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ data "aws_ami" "ami" {
most_recent = true
filter {
name = "name"
values = ["al20*-ami-minimal-*-x86_64"]
values = ["al20*-ami-minimal-*-${var.cpu_architecture}"]
}
filter {
name = "state"
values = ["available"]
}
filter {
name = "architecture"
values = ["x86_64"]
values = ["${var.cpu_architecture}"]
}
filter {
name = "image-type"
Expand All @@ -79,7 +79,7 @@ data "aws_ami" "ami" {

resource "aws_instance" "main_service_instance" {
ami = data.aws_ami.ami.id # Amazon Linux 2 (free tier)
instance_type = "t3.small"
instance_type = var.cpu_architecture == "arm64" ? "t4g.small" : "t3.small"
key_name = local.ssh_key_name
iam_instance_profile = "APP_SIGNALS_EC2_TEST_ROLE"
vpc_security_group_ids = [aws_default_vpc.default.default_security_group_id]
Expand Down Expand Up @@ -108,7 +108,21 @@ resource "null_resource" "main_service_setup" {
#!/bin/bash

# Set up environment
sudo yum install nodejs unzip wget tmux aws-cli -y
sudo yum install unzip wget tmux aws-cli -y

# Install nvm
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

# Install the specified Node.js version, or use the system's version if 'none'
if [[ "${var.language_version}" != "none" ]]; then
nvm install ${var.language_version}
nvm use ${var.language_version}
else
sudo yum install nodejs -y
echo "Using the default Node.js version provided by the OS"
fi

echo "Node version in use: $(node -v)"

Expand Down Expand Up @@ -176,7 +190,7 @@ resource "null_resource" "main_service_setup" {

resource "aws_instance" "remote_service_instance" {
ami = data.aws_ami.ami.id # Amazon Linux 2 (free tier)
instance_type = "t3.small"
instance_type = var.cpu_architecture == "arm64" ? "t4g.small" : "t3.small"
key_name = local.ssh_key_name
iam_instance_profile = "APP_SIGNALS_EC2_TEST_ROLE"
vpc_security_group_ids = [aws_default_vpc.default.default_security_group_id]
Expand Down Expand Up @@ -205,7 +219,21 @@ resource "null_resource" "remote_service_setup" {
#!/bin/bash

# Set up environment
sudo yum install nodejs unzip wget tmux aws-cli -y
sudo yum install unzip wget tmux aws-cli -y

# Install nvm
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

# Install the specified Node.js version, or use the system's version if 'none'
if [[ "${var.language_version}" != "none" ]]; then
nvm install ${var.language_version}
nvm use ${var.language_version}
else
sudo yum install nodejs -y
echo "Using the default Node.js version provided by the OS"
fi

echo "Node version in use: $(node -v)"

Expand Down
10 changes: 10 additions & 0 deletions terraform/node/ec2/default/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ variable "user" {
default = "ec2-user"
}

variable "cpu_architecture" {
default = "x86_64" # an alternative value is "arm64"
}

variable "language_version" {
# none means to use the version packaged with the OS
# other alternatives are "14", "16", "18", "20", "22"
default = "none"
}

variable "sample_app_zip" {
default = "s3://<bucket-name>/<zip>"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"EC2.InstanceId": "^{{instanceId}}$",
"PlatformType": "^AWS::EC2$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t3.small$",
"otel.resource.host.type": "^(t3.small|t4g.small)$",
"aws.span.kind": "^LOCAL_ROOT$"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"metadata": {
"default": {
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t3.small$"
"otel.resource.host.type": "^(t3.small|t4g.small)$"
}
},
"subsegments": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"EC2.InstanceId": "^{{instanceId}}$",
"PlatformType": "^AWS::EC2$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t3.small$",
"otel.resource.host.type": "^(t3.small|t4g.small)$",
"aws.span.kind": "^LOCAL_ROOT$"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"EC2.InstanceId": "^{{instanceId}}$",
"PlatformType": "^AWS::EC2$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t3.small$",
"otel.resource.host.type": "^(t3.small|t4g.small)$",
"aws.span.kind": "^LOCAL_ROOT$"
}
},
Expand Down Expand Up @@ -71,7 +71,7 @@
"EC2.InstanceId": "^i-[A-Za-z0-9]{17}$",
"PlatformType": "^AWS::EC2$",
"otel.resource.host.image.id": "^{{instanceAmi}}$",
"otel.resource.host.type": "^t3.small$",
"otel.resource.host.type": "^(t3.small|t4g.small)$",
"aws.span.kind": "^LOCAL_ROOT$"
}
}
Expand Down