Skip to content

Commit

Permalink
Merge pull request #1000 from bryan-aguilar/updateDev1212
Browse files Browse the repository at this point in the history
Update dev branch with terraform
  • Loading branch information
Aneurysm9 authored Dec 13, 2022
2 parents aec3630 + a93480c commit 24445b3
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 40 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/update-load-generator-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow uses GHA to build a Java project with Gradle 'load-generator', and build and push multi-arch docker image of this project to the Amazon ECR.

name: Update Load-Generator Image

# Should execute only one workflow run at a time
concurrency:
group: build-and-push-load-generator-image
cancel-in-progress: false

on:
workflow_dispatch:
push:
branches: ['terraform']

# List of paths that should be considered when triggering the workflow
paths: ['load-generator/**']

permissions:
id-token: write
contents: read

jobs:
create-and-push-load-generator-image-on-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.TEST_FW_ASSUMABLE_ROLE_ARN }}
aws-region: us-east-1
role-duration-seconds: 7200
- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build image with jib
uses: gradle/gradle-build-action@v2
with:
arguments: :load-generator:jib
env:
COMMIT_HASH: ${{ github.sha }}


29 changes: 0 additions & 29 deletions load-generator/Dockerfile

This file was deleted.

28 changes: 25 additions & 3 deletions load-generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ plugins {

// lombok
id "io.freefair.lombok" version "6.5.1"

// jib
id 'com.google.cloud.tools.jib'
}

repositories {
Expand Down Expand Up @@ -51,13 +54,32 @@ dependencies {
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.19.0'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.19.0'

// local project can't be referenced in Dockerfile
// the workaround is build fat jar and copy it in Dockerfile for building docker image
// implementation files('build/libs/trace-java-client-1.0-all.jar')
implementation project(":trace-java-client")
}

application {
// Define the main class for the application.
mainClassName = 'com.amazon.opentelemetry.load.generator.App'
}

// jibDockerBuild doesn't support multi-platform image manifests
// to build using the local docker daemon execute jibDockerBuild, and use only one specific platforms.
jib {
from {
image = 'gradle:7.3.3-jdk11'
platforms {
platform {
architecture = 'amd64'
os = 'linux'
}
platform {
architecture = 'arm64'
os = 'linux'
}
}
}
to {
image = 'public.ecr.aws/aws-otel-test/aws-otel-load-generator'
tags = ['latest', "${System.getenv("COMMIT_HASH")}"]
}
}
14 changes: 12 additions & 2 deletions terraform/basic_components/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ module "common" {
security_group_name = var.aoc_vpc_security_group
}

locals {
otconfig_path = fileexists("${var.testcase}/otconfig.tpl") ? "${var.testcase}/otconfig.tpl" : module.common.default_otconfig_path

subnet_ids_list = tolist(data.aws_subnet_ids.aoc_public_subnet_ids.ids)

subnet_ids_random_index = random_id.subnetSelector.dec % length(subnet_ids_list)

random_instance_subnet_id = local.subnet_ids_list[local.subnet_ids_random_index]
}

data "aws_security_group" "aoc_security_group" {
name = module.common.aoc_vpc_security_group
}
Expand Down Expand Up @@ -61,8 +71,8 @@ data "aws_subnet_ids" "aoc_public_subnet_ids" {
}
}

locals {
otconfig_path = fileexists("${var.testcase}/otconfig.tpl") ? "${var.testcase}/otconfig.tpl" : module.common.default_otconfig_path
resource "random_id" "subnetSelector" {
byte_length = 2
}

# generate otconfig
Expand Down
4 changes: 4 additions & 0 deletions terraform/basic_components/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ output "sample_app_image" {
output "mocked_server_image" {
value = "${data.aws_ecr_repository.mocked_servers.repository_url}:${var.mocked_server}-latest"
}

output "random_subnet_instance_id" {
value = local.random_instance_subnet_id
}
7 changes: 2 additions & 5 deletions terraform/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ locals {
# get ecr login domain
ecr_login_domain = split("/", data.aws_ecr_repository.sample_app.repository_url)[0]

# get instance subnet, use separate subnet for soaking and performance test as it takes more instances and some times eat up all the available ip address in the subnet
instance_subnet = var.testing_type == "e2e" ? tolist(module.basic_components.aoc_public_subnet_ids)[1] : tolist(module.basic_components.aoc_public_subnet_ids)[0]

# get SSM package version, latest is the default version
ssm_package_version = var.aoc_version == "latest" ? "\"\"" : var.aoc_version
testcase_name = split("/", var.testcase)[2]
Expand All @@ -90,7 +87,7 @@ locals {
resource "aws_instance" "sidecar" {
ami = data.aws_ami.amazonlinux2.id
instance_type = var.sidecar_instance_type
subnet_id = local.instance_subnet
subnet_id = module.basic_components.random_subnet_instance_id
vpc_security_group_ids = [module.basic_components.aoc_security_group_id]
associate_public_ip_address = true
iam_instance_profile = module.common.aoc_iam_role_name
Expand All @@ -108,7 +105,7 @@ resource "aws_instance" "sidecar" {
resource "aws_instance" "aoc" {
ami = local.ami_id
instance_type = local.instance_type
subnet_id = local.instance_subnet
subnet_id = module.basic_components.random_subnet_instance_id
vpc_security_group_ids = [module.basic_components.aoc_security_group_id]
associate_public_ip_address = true
iam_instance_profile = module.common.aoc_iam_role_name
Expand Down
2 changes: 1 addition & 1 deletion terraform/ecs/efs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resource "aws_key_pair" "aws_ssh_key" {
resource "aws_instance" "collector_efs_ec2" {
ami = data.aws_ami.amazonlinux2.id
instance_type = "c5a.large"
subnet_id = tolist(module.basic_components.aoc_public_subnet_ids)[0]
subnet_id = module.basic_components.random_subnet_instance_id
vpc_security_group_ids = [module.basic_components.aoc_security_group_id]
associate_public_ip_address = true
iam_instance_profile = module.common.aoc_iam_role_name
Expand Down

0 comments on commit 24445b3

Please sign in to comment.