Skip to content

Commit

Permalink
feature(examples): adding AWS terraform example (#2028)
Browse files Browse the repository at this point in the history
* feat(server): implement viper (#1977)

* config(server): allow provisioning from file or environent variable (#1999)

* chore: disable application exporter in demo (#2012)

disable app exporter in demo

* feature(examples): adding aws terraform example

* updating the tracetest image

* feat(server): implement viper (#1977)

* config(server): allow provisioning from file or environent variable (#1999)

* feat: config deprecation (#2015)

* update options to use named fields

* add postgresConnString as deprecated

* remove nil validations

* fix deprecated config fields detection

* add logger to config New function

* replace zap with go's log package

* invert logic of printing the deprecation note

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>

* unexport logger interface

* use camelCase names in tests

* update test with Sebastian notes and update logic to make it pass

---------

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>

* fix: postgres config retrocompatibility  (#2043)

feat: ensure retrocompatibility if users is using postgresConnString

* feature: adding support for AWS X-RAY (#1987)

* feature: adding support for AWS X-RAY

* updating README

* cleanup

* feat(server): implement viper (#1977)

* added quick-start golang app in example (#1940)

* added quick-start golnag app in example

* Added quick-start-python in examples

* chore(docs): add recipe for datadog (#1995)

* chore(examples): adding documentation and example of datadog integration

* adding datadog recipe

* fixing details in docs

* Apply suggestions from code review

Co-authored-by: Julianne Fermi <julianne@kubeshop.io>

---------

Co-authored-by: Julianne Fermi <julianne@kubeshop.io>

* Update docs structure and config guides (#1984)

* docs(1919): flatten tools and integration

* docs(1919): flatten examples and tutorials

* docs(recipes): edit naming

* docs(config): fix 1982

* examples(tempo): edit config

* docs(structure): add redirect

* docs(config): update dd

* feature(examples): adding net core x tracetest example (#1978)

* feature(examples): adding net core x tracetest example

* adding readme

* addressing feedback comments

* adding more information

* adding support for the native xray client

* refactor connectivity test to reuse components (#1994)

* refactor connectivity test to reuse components

* only run next step if previous step succeeded

* simplify tester TestConnection

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>

* add protocol in IsReachable function

* ignore unused ctx

* remove boolean return from IsReachable

* use multierrors to wrap all endpoint errors

* fix build

* use const for IsReachable timeout

* rename IsReachable to CheckReachability

---------

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>

* cleanup

* using the new test connection logic

* config(server): allow provisioning from file or environent variable (#1999)

* cleanup

* adding support for session token

* feat(server): implement viper (#1977)

* config(server): allow provisioning from file or environent variable (#1999)

* moving trace id generation to data store

* fixing unit tests

* chore: disable application exporter in demo (#2012)

disable app exporter in demo

* removing examples

* cleanup

---------

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>
Co-authored-by: Mahesh Kasbe <60398112+maheshkasabe@users.noreply.github.com>
Co-authored-by: Daniel Baptista Dias <danielbdias@users.noreply.github.com>
Co-authored-by: Julianne Fermi <julianne@kubeshop.io>
Co-authored-by: Adnan Rahić <adnan@kubeshop.io>
Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>

* feature(examples) adding tracetest x aws-xray examples (#2030)

* feature: adding support for AWS X-RAY

* updating README

* cleanup

* feat(server): implement viper (#1977)

* added quick-start golang app in example (#1940)

* added quick-start golnag app in example

* Added quick-start-python in examples

* chore(docs): add recipe for datadog (#1995)

* chore(examples): adding documentation and example of datadog integration

* adding datadog recipe

* fixing details in docs

* Apply suggestions from code review

Co-authored-by: Julianne Fermi <julianne@kubeshop.io>

---------

Co-authored-by: Julianne Fermi <julianne@kubeshop.io>

* Update docs structure and config guides (#1984)

* docs(1919): flatten tools and integration

* docs(1919): flatten examples and tutorials

* docs(recipes): edit naming

* docs(config): fix 1982

* examples(tempo): edit config

* docs(structure): add redirect

* docs(config): update dd

* feature(examples): adding net core x tracetest example (#1978)

* feature(examples): adding net core x tracetest example

* adding readme

* addressing feedback comments

* adding more information

* adding support for the native xray client

* refactor connectivity test to reuse components (#1994)

* refactor connectivity test to reuse components

* only run next step if previous step succeeded

* simplify tester TestConnection

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>

* add protocol in IsReachable function

* ignore unused ctx

* remove boolean return from IsReachable

* use multierrors to wrap all endpoint errors

* fix build

* use const for IsReachable timeout

* rename IsReachable to CheckReachability

---------

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>

* cleanup

* using the new test connection logic

* config(server): allow provisioning from file or environent variable (#1999)

* cleanup

* adding support for session token

* feat(server): implement viper (#1977)

* config(server): allow provisioning from file or environent variable (#1999)

* moving trace id generation to data store

* fixing unit tests

* chore: disable application exporter in demo (#2012)

disable app exporter in demo

* removing examples

* feature(examples) adding tracetest x aws-xray examples

* cleanup

* cleanup

* removing mysql dependency

---------

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>
Co-authored-by: Mahesh Kasbe <60398112+maheshkasabe@users.noreply.github.com>
Co-authored-by: Daniel Baptista Dias <danielbdias@users.noreply.github.com>
Co-authored-by: Julianne Fermi <julianne@kubeshop.io>
Co-authored-by: Adnan Rahić <adnan@kubeshop.io>
Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>

* cleanup

---------

Co-authored-by: Sebastian Choren <schoren@users.noreply.github.com>
Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>
Co-authored-by: Mahesh Kasbe <60398112+maheshkasabe@users.noreply.github.com>
Co-authored-by: Daniel Baptista Dias <danielbdias@users.noreply.github.com>
Co-authored-by: Julianne Fermi <julianne@kubeshop.io>
Co-authored-by: Adnan Rahić <adnan@kubeshop.io>
  • Loading branch information
7 people committed Mar 1, 2023
1 parent c3dff3f commit c1395d5
Show file tree
Hide file tree
Showing 18 changed files with 4,653 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/tracetest-aws-terraform-serverless/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.terraform
terraform.tfstate*
src.zip
node_modules
84 changes: 84 additions & 0 deletions examples/tracetest-aws-terraform-serverless/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions examples/tracetest-aws-terraform-serverless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Quick Start - Tracetest with Terraform, AWS Fargate, Lambda, Node.js and Jaeger

This is a simple quick start on how to configure a Node.js lambda function API to use OpenTelemetry instrumentation with traces and Tracetest for enhancing your E2E and integration tests with trace-based testing. The infrastructure will use Jaeger as the trace data store and Terraform to provision the required AWS infrastructure (Fargate/Lambda).

## Steps

1. [Install the tracetest CLI](https://github.com/kubeshop/tracetest/blob/main/docs/installing.md#cli-installation)
2. Run `terraform init`, `terraform apply` and accept the changes
3. From the terraform outputs, grab the `tracetes_url` and run `tracetest configure --endpoint <tracetest_url>` on a terminal to configure the CLI to send all commands to that address
4. From the terraform outputs, grab the `api_endpoint` and update the `<your_api_endpoint>` section from `tests/test.yaml`
5. Test if it works by running: `tracetest test run -d tests/test.yaml`. This would execute a test against the Node.js API Gateway endpoint that will send spans to Jaeger to be fetched from the Tracetest server.

Feel free to check out the [docs](https://docs.tracetest.io/), and join our [Discord Community](https://discord.gg/8MtcMrQNbX) for more info!
94 changes: 94 additions & 0 deletions examples/tracetest-aws-terraform-serverless/alb.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
module "tracetest_alb_security_group" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 4.0"

name = local.name
description = "Load balancer security group"
vpc_id = module.network.vpc_id

ingress_with_cidr_blocks = [
{
from_port = 11633
to_port = 11633
protocol = "tcp"
description = "HTTP access for Tracetest"
cidr_blocks = "0.0.0.0/0"
}, {
from_port = 16686
to_port = 16686
protocol = "tcp"
description = "HTTP access for Jaeger UI"
cidr_blocks = "0.0.0.0/0"
}, {
from_port = 16685
to_port = 16685
protocol = "tcp"
description = "HTTP access for Jaeger API"
cidr_blocks = "0.0.0.0/0"
}]

egress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "-1"
description = "HTTP access to anywhere"
cidr_blocks = "0.0.0.0/0"
}]
}

resource "aws_lb" "tracetest-alb" {
name = "tracetest-alb"
internal = false
load_balancer_type = "application"
security_groups = [module.tracetest_alb_security_group.security_group_id]
subnets = module.network.public_subnets_ids

enable_deletion_protection = false
tags = local.tags
}

// INTERNAL ALB
module "internal_tracetest_alb_security_group" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 4.0"

name = local.name
description = "Internal Load balancer security group"
vpc_id = module.network.vpc_id

ingress_with_cidr_blocks = [
{
from_port = 16685
to_port = 16685
protocol = "tcp"
description = "HTTP access for Jaeger API"
cidr_blocks = local.vpc_cidr
}, {
from_port = 4318
to_port = 4318
protocol = "tcp"
description = "HTTP access for Jaeger Collector"
cidr_blocks = local.vpc_cidr
}]

egress_with_cidr_blocks = [
{
from_port = 0
to_port = 65535
protocol = "-1"
description = "HTTP access to Anywhere"
cidr_blocks = "0.0.0.0/0"
}]
}

resource "aws_lb" "internal_tracetest_alb" {
name = "tracetest-internal-alb"
internal = true
load_balancer_type = "application"
security_groups = [module.internal_tracetest_alb_security_group.security_group_id]
subnets = module.network.private_subnets_ids

enable_deletion_protection = false
tags = local.tags
}
59 changes: 59 additions & 0 deletions examples/tracetest-aws-terraform-serverless/apigateway.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
resource "aws_apigatewayv2_api" "lambda" {
name = "serverless_lambda_gw"
protocol_type = "HTTP"
}

resource "aws_apigatewayv2_stage" "lambda" {
api_id = aws_apigatewayv2_api.lambda.id

name = local.environment
auto_deploy = true

access_log_settings {
destination_arn = aws_cloudwatch_log_group.api_gw.arn

format = jsonencode({
requestId = "$context.requestId"
sourceIp = "$context.identity.sourceIp"
requestTime = "$context.requestTime"
protocol = "$context.protocol"
httpMethod = "$context.httpMethod"
resourcePath = "$context.resourcePath"
routeKey = "$context.routeKey"
status = "$context.status"
responseLength = "$context.responseLength"
integrationErrorMessage = "$context.integrationErrorMessage"
}
)
}
}

resource "aws_apigatewayv2_integration" "hello_world" {
api_id = aws_apigatewayv2_api.lambda.id

integration_uri = aws_lambda_function.hello_world.invoke_arn
integration_type = "AWS_PROXY"
integration_method = "POST"
}

resource "aws_apigatewayv2_route" "hello_world" {
api_id = aws_apigatewayv2_api.lambda.id

route_key = "GET /hello"
target = "integrations/${aws_apigatewayv2_integration.hello_world.id}"
}

resource "aws_cloudwatch_log_group" "api_gw" {
name = "/aws/api_gw/${aws_apigatewayv2_api.lambda.name}"

retention_in_days = 30
}

resource "aws_lambda_permission" "api_gw" {
statement_id = "AllowExecutionFromAPIGateway"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.hello_world.function_name
principal = "apigateway.amazonaws.com"

source_arn = "${aws_apigatewayv2_api.lambda.execution_arn}/*/*"
}

0 comments on commit c1395d5

Please sign in to comment.