From 051cc261a1eeae178c3a0c474cbbd5a29f5a5faa Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Tue, 1 Apr 2025 11:52:26 -0400 Subject: [PATCH 01/19] add module release process --- .github/workflows/terraform-release.yaml | 73 +++++++++++++++++++++++ .github/workflows/terraform-validate.yaml | 43 +++++++++++++ main.tf | 10 ++-- 3 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/terraform-release.yaml create mode 100644 .github/workflows/terraform-validate.yaml diff --git a/.github/workflows/terraform-release.yaml b/.github/workflows/terraform-release.yaml new file mode 100644 index 0000000..2d3aa73 --- /dev/null +++ b/.github/workflows/terraform-release.yaml @@ -0,0 +1,73 @@ +name: Terraform CI/CD +on: + workflow_dispatch: + pull_request: + types: [closed] + branches: + - main +jobs: + terraform-ci-cd: + runs-on: 229685449397 + permissions: + contents: write + + steps: + - name: Checkout code + uses: CSVD/gh-actions-checkout@v4 + + - name: Setup Terraform + uses: CSVD/gh-actions-setup-terraform@v3 + with: + terraform_version: "1.9.1" + + - name: Setup GITHUB Credentials + id: github_credentials + uses: CSVD/gh-auth@main + with: + github_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }} + github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }} + github_app_id: ${{ vars.GH_APP_ID }} + + + - name: Debug Authentication + run: | + # Print the GitHub server URL + echo "GitHub Server URL: ${{ github.server_url }}" + + # Extract the host from the URL + HOST="${{ github.server_url }}" + HOST="${HOST#*//}" + HOST="${HOST%%/*}" + echo "GitHub Host: $HOST" + + # Check if token exists + if [[ -n "${{ steps.github_credentials.outputs.github_token }}" ]]; then + echo "Token generated successfully" + # Test the token with a simple GitHub API call (without exposing the token) + STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${{ steps.github_credentials.outputs.github_token }}" "${{ github.server_url }}/api/v3/user") + echo "API Test Status Code: $STATUS" + else + echo "No token was generated!" + fi + + - name: Setup GitHub CLI + run: | + # Force manual authentication since setup-git might not work with GitHub Enterprise + echo "${{ steps.github_credentials.outputs.github_token }}" > /tmp/token.txt + gh auth login --with-token --hostname "github.e.it.census.gov" < /tmp/token.txt + rm /tmp/token.txt + + # Test GitHub CLI auth status + gh auth status || echo "GitHub CLI authentication failed" + + - name: AWS Auth + id: aws_auth + uses: CSVD/aws-auth@main + with: + ecs: true + + - name: Run Terraform Module Release Action + uses: CSVD/terraform-module-release@main + with: + github-token: ${{ steps.github_credentials.outputs.github_token }} + working-directory: '.' diff --git a/.github/workflows/terraform-validate.yaml b/.github/workflows/terraform-validate.yaml new file mode 100644 index 0000000..d8322a1 --- /dev/null +++ b/.github/workflows/terraform-validate.yaml @@ -0,0 +1,43 @@ +name: Terraform Validate +on: + pull_request: + workflow_dispatch: + +jobs: + + terraform-validate: + runs-on: "229685449397" + permissions: + contents: write + steps: + - name: Checkout code + uses: CSVD/gh-actions-checkout@v4 + + - name: Setup Terraform + uses: CSVD/gh-actions-setup-terraform@v2 + with: + terraform_version: '1.7.3' + + - name: Validate Terraform Configuration + id: validate + uses: CSVD/terraform-validate@main + + - name: Check Validation/Test Results + if: always() + run: | + # Set default values if outputs are empty + IS_VALID="${{ steps.validate.outputs.is_valid }}" + TESTS_PASSED="${{ steps.validate.outputs.tests_passed }}" + + # If outputs are empty, set them to false + [ -z "$IS_VALID" ] && IS_VALID="false" + [ -z "$TESTS_PASSED" ] && TESTS_PASSED="false" + + if [[ "$IS_VALID" != "true" || "$TESTS_PASSED" != "true" ]]; then + echo "Validation or test errors found:" + echo "${{ steps.validate.outputs.stderr }}" + exit 1 + else + echo "All validations and tests passed successfully!" + fi + diff --git a/main.tf b/main.tf index 7514e7d..d4c7d7d 100644 --- a/main.tf +++ b/main.tf @@ -1,7 +1,5 @@ locals { - telemetry_ns = var.namespace - - otel_internal_hostname = format("otel-daemonset-collector.%v.svc.cluster.local", local.telemetry_ns) + otel_internal_hostname = format("otel-daemonset-collector.%v.svc.cluster.local", var.namespace) otel_internal_port_number = 4318 otel_internal_url = format("http://%v:%v/", local.otel_internal_hostname, local.otel_internal_port_number) } @@ -14,7 +12,7 @@ resource "helm_release" "opentelemetry-operator" { chart = "opentelemetry-operator" name = "opentelemetry-operator" - namespace = local.telemetry_ns + namespace = var.namespace repository = var.otel_helm_repo version = var.otel_helm_version @@ -78,7 +76,7 @@ resource "helm_release" "otel-resources" { chart = "./otel" name = "otel-resources" - namespace = local.telemetry_ns + namespace = var.namespace version = local.module_version set { @@ -126,4 +124,4 @@ resource "helm_release" "otel-resources" { name = "autoinstrumentation.java.tag" value = module.images.images[local.auto_instrumentation_java_key].tag } -} \ No newline at end of file +} From 18917b4c881f7a5466e7bdcf5ab845848ce6194b Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Tue, 1 Apr 2025 21:06:07 -0400 Subject: [PATCH 02/19] update module source --- copy_images.tf | 2 +- requirements.tf | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/copy_images.tf b/copy_images.tf index 95b8623..9019947 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -69,7 +69,7 @@ locals { } module "images" { - source = "git@github.e.it.census.gov:terraform-modules/aws-ecr-copy-images.git/?ref=tf-upgrade" + source = "git::https://github.e.it.census.gov/terraform-modules/aws-ecr-copy-images.git/?ref=tf-upgrade" profile = var.profile application_name = var.cluster_name diff --git a/requirements.tf b/requirements.tf index 4eab89e..2e678e4 100644 --- a/requirements.tf +++ b/requirements.tf @@ -10,9 +10,5 @@ terraform { source = "hashicorp/helm" version = ">= 2.11.0" } - kubectl = { - source = "gavinbunney/kubectl" - version = ">= 1.14.0" - } } } From 057555c8ed38171eb135cd7dac433b4e46e61f14 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Tue, 1 Apr 2025 21:06:28 -0400 Subject: [PATCH 03/19] update module source --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6bfca7a..add5da5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: # Git style - id: check-added-large-files @@ -38,7 +38,7 @@ repos: # Terraform Hooks - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.92.1 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases + rev: v1.98.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases hooks: - id: terraform_fmt args: @@ -94,6 +94,6 @@ repos: # - --hook-config=--parallelism-ci-cpu-cores=2 - repo: https://github.com/ljnsn/cz-conventional-gitmoji - rev: v0.3.2 + rev: v0.7.0 hooks: - id: conventional-gitmoji From c672da3b073561e6abe07052b66644fb564a8178 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Tue, 1 Apr 2025 21:07:58 -0400 Subject: [PATCH 04/19] lint --- .github/workflows/terraform-release.yaml | 20 ++++++++--------- .github/workflows/terraform-validate.yaml | 15 ++++++------- .tflint.hcl | 26 +++++++++++------------ README.md | 11 +++++----- examples/simple/variables.tf | 2 +- otel/templates/java_instrumentation.yaml | 2 +- otel/templates/otelcol_daemonset.yaml | 10 ++++----- otel/templates/otelcol_deployment.yaml | 4 ++-- otel/values.yaml | 2 +- 9 files changed, 45 insertions(+), 47 deletions(-) diff --git a/.github/workflows/terraform-release.yaml b/.github/workflows/terraform-release.yaml index 2d3aa73..90910bc 100644 --- a/.github/workflows/terraform-release.yaml +++ b/.github/workflows/terraform-release.yaml @@ -10,16 +10,16 @@ jobs: runs-on: 229685449397 permissions: contents: write - + steps: - name: Checkout code uses: CSVD/gh-actions-checkout@v4 - + - name: Setup Terraform uses: CSVD/gh-actions-setup-terraform@v3 with: terraform_version: "1.9.1" - + - name: Setup GITHUB Credentials id: github_credentials uses: CSVD/gh-auth@main @@ -28,18 +28,18 @@ jobs: github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }} github_app_id: ${{ vars.GH_APP_ID }} - + - name: Debug Authentication run: | # Print the GitHub server URL echo "GitHub Server URL: ${{ github.server_url }}" - + # Extract the host from the URL HOST="${{ github.server_url }}" HOST="${HOST#*//}" HOST="${HOST%%/*}" echo "GitHub Host: $HOST" - + # Check if token exists if [[ -n "${{ steps.github_credentials.outputs.github_token }}" ]]; then echo "Token generated successfully" @@ -49,23 +49,23 @@ jobs: else echo "No token was generated!" fi - + - name: Setup GitHub CLI run: | # Force manual authentication since setup-git might not work with GitHub Enterprise echo "${{ steps.github_credentials.outputs.github_token }}" > /tmp/token.txt gh auth login --with-token --hostname "github.e.it.census.gov" < /tmp/token.txt rm /tmp/token.txt - + # Test GitHub CLI auth status gh auth status || echo "GitHub CLI authentication failed" - + - name: AWS Auth id: aws_auth uses: CSVD/aws-auth@main with: ecs: true - + - name: Run Terraform Module Release Action uses: CSVD/terraform-module-release@main with: diff --git a/.github/workflows/terraform-validate.yaml b/.github/workflows/terraform-validate.yaml index d8322a1..72829d8 100644 --- a/.github/workflows/terraform-validate.yaml +++ b/.github/workflows/terraform-validate.yaml @@ -2,9 +2,9 @@ name: Terraform Validate on: pull_request: workflow_dispatch: - + jobs: - + terraform-validate: runs-on: "229685449397" permissions: @@ -12,27 +12,27 @@ jobs: steps: - name: Checkout code uses: CSVD/gh-actions-checkout@v4 - + - name: Setup Terraform uses: CSVD/gh-actions-setup-terraform@v2 with: terraform_version: '1.7.3' - + - name: Validate Terraform Configuration id: validate uses: CSVD/terraform-validate@main - + - name: Check Validation/Test Results if: always() run: | # Set default values if outputs are empty IS_VALID="${{ steps.validate.outputs.is_valid }}" TESTS_PASSED="${{ steps.validate.outputs.tests_passed }}" - + # If outputs are empty, set them to false [ -z "$IS_VALID" ] && IS_VALID="false" [ -z "$TESTS_PASSED" ] && TESTS_PASSED="false" - + if [[ "$IS_VALID" != "true" || "$TESTS_PASSED" != "true" ]]; then echo "Validation or test errors found:" echo "${{ steps.validate.outputs.stderr }}" @@ -40,4 +40,3 @@ jobs: else echo "All validations and tests passed successfully!" fi - diff --git a/.tflint.hcl b/.tflint.hcl index f63db7d..6a77997 100644 --- a/.tflint.hcl +++ b/.tflint.hcl @@ -5,18 +5,18 @@ config { } -rule "aws_instance_invalid_type" { - enabled = true -} +# rule "aws_instance_invalid_type" { +# enabled = true +# } -plugin "aws" { - enabled = true - version = "0.32.0" - source = "github.com/terraform-linters/tflint-ruleset-aws" -} +# plugin "aws" { +# enabled = true +# version = "0.32.0" +# source = "github.com/terraform-linters/tflint-ruleset-aws" +# } -plugin "terraform" { - enabled = true - version = "0.9.0" - source = "github.com/terraform-linters/tflint-ruleset-terraform" -} +# plugin "terraform" { +# enabled = true +# version = "0.9.0" +# source = "github.com/terraform-linters/tflint-ruleset-terraform" +# } diff --git a/README.md b/README.md index a2aaf2f..0491327 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # tfmod-open-telemetry -Installs the OpenTelemetry (OTel) Collector operator, collectors and autoinstrumentation. [OpenTelemetry](https://opentelemetry.io/docs/) is a vendor neutral, open source observability framework and toolkit providing collection, processing and export of telemetry data, such as traces, metrics, and logs from applications and infrastructure. In the platform context, the OpenTelemetry Collector acts as an intermediary between instrumented applications and observability backends, aggregating telemetry data before forwarding it to various monitoring and logging systems. The Collector acts as a pipeline, utilizing processors, receivers and exporters, allowing fine-grained control over how and where data is sent. +Installs the OpenTelemetry (OTel) Collector operator, collectors and autoinstrumentation. [OpenTelemetry](https://opentelemetry.io/docs/) is a vendor neutral, open source observability framework and toolkit providing collection, processing and export of telemetry data, such as traces, metrics, and logs from applications and infrastructure. In the platform context, the OpenTelemetry Collector acts as an intermediary between instrumented applications and observability backends, aggregating telemetry data before forwarding it to various monitoring and logging systems. The Collector acts as a pipeline, utilizing processors, receivers and exporters, allowing fine-grained control over how and where data is sent. ![OpenTelemetry implementation:](images/opentelemetry_diagrams.drawio.png) -This modules installs the OpenTelemetry Collector operator and two Collectors. One Collector runs as a deployment and its purpose is to collect cluster-wide telemetry content, ie. collect content related to the cluster itself, such as cluster health, utilization, etc. The second Collector runs as a daemonset and is associated with collecting application specific telemetry content for the pods of each node. Lastly, OpenTelemetry Instrumentation is deployed for application specific workloads corresponding to GPLs of the project, ie. Java, .NET, Deno, etc. This Instrumentation allows for auto-instrumentation of application workloads through injection of application libraries integrating with the Collectors, allowing for zero-code configuration of applications with OpenTelemetry and the Platform. The auto-instrumentation is bound by Kubernetes namespaces and configured via annotation, for example the following is annotation for configuration of python libraries: `instrumentation.opentelemetry.io/inject-python: true`. +This modules installs the OpenTelemetry Collector operator and two Collectors. One Collector runs as a deployment and its purpose is to collect cluster-wide telemetry content, ie. collect content related to the cluster itself, such as cluster health, utilization, etc. The second Collector runs as a daemonset and is associated with collecting application specific telemetry content for the pods of each node. Lastly, OpenTelemetry Instrumentation is deployed for application specific workloads corresponding to GPLs of the project, ie. Java, .NET, Deno, etc. This Instrumentation allows for auto-instrumentation of application workloads through injection of application libraries integrating with the Collectors, allowing for zero-code configuration of applications with OpenTelemetry and the Platform. The auto-instrumentation is bound by Kubernetes namespaces and configured via annotation, for example the following is annotation for configuration of python libraries: `instrumentation.opentelemetry.io/inject-python: true`. ## Requirements @@ -14,19 +14,18 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | [terraform](#requirement\_terraform) | >= 0.13 | | [aws](#requirement\_aws) | >= 5.14.0 | | [helm](#requirement\_helm) | >= 2.11.0 | -| [kubectl](#requirement\_kubectl) | >= 1.14.0 | ## Providers | Name | Version | |------|---------| -| [helm](#provider\_helm) | >= 2.11.0 | +| [helm](#provider\_helm) | 2.17.0 | ## Modules | Name | Source | Version | |------|--------|---------| -| [images](#module\_images) | git@github.e.it.census.gov:terraform-modules/aws-ecr-copy-images.git/ | tf-upgrade | +| [images](#module\_images) | git::https://github.e.it.census.gov/terraform-modules/aws-ecr-copy-images.git/ | tf-upgrade | ## Resources @@ -55,4 +54,4 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O |------|-------------| | [module\_name](#output\_module\_name) | The name of this module. | | [module\_version](#output\_module\_version) | The version of this module. | - \ No newline at end of file + diff --git a/examples/simple/variables.tf b/examples/simple/variables.tf index 660df39..64e253e 100644 --- a/examples/simple/variables.tf +++ b/examples/simple/variables.tf @@ -36,4 +36,4 @@ variable "tempo_endpoint" { description = "The endpoint for the tempo service" type = string default = "" -} \ No newline at end of file +} diff --git a/otel/templates/java_instrumentation.yaml b/otel/templates/java_instrumentation.yaml index ec67844..3b98a6b 100644 --- a/otel/templates/java_instrumentation.yaml +++ b/otel/templates/java_instrumentation.yaml @@ -12,4 +12,4 @@ spec: type: parentbased_traceidratio argument: "1" java: - image: "{{ .Values.autoinstrumentation.java.image }}:{{ .Values.autoinstrumentation.java.tag | default .Chart.AppVersion }}" \ No newline at end of file + image: "{{ .Values.autoinstrumentation.java.image }}:{{ .Values.autoinstrumentation.java.tag | default .Chart.AppVersion }}" diff --git a/otel/templates/otelcol_daemonset.yaml b/otel/templates/otelcol_daemonset.yaml index 3eeae79..8a2e13a 100644 --- a/otel/templates/otelcol_daemonset.yaml +++ b/otel/templates/otelcol_daemonset.yaml @@ -11,9 +11,9 @@ spec: receivers: otlp: # Used to collect application traces, metrics and logs. protocols: - grpc: + grpc: endpoint: 0.0.0.0:4317 - http: + http: endpoint: 0.0.0.0:4318 kubeletstats: # Used to pull node, pod, and container metrics from the API server on a kubelet. collection_interval: 10s @@ -141,7 +141,7 @@ spec: name: k8s.pod.uid - sources: # If neither of those work, use the requests connection to get the pod IP. - from: connection - memory_limiter: # Best practice to force telemetry backoff if the collector pushes against memory thresholds, ie. avoid oom + memory_limiter: # Best practice to force telemetry backoff if the collector pushes against memory thresholds, ie. avoid oom check_interval: 1s limit_percentage: 80 spike_limit_percentage: 25 @@ -164,7 +164,7 @@ spec: # prometheusremotewrite: # endpoint: http://mimir-monolithic-headless.mimir.svc.cluster.local:8080/api/v1/push # tls: - # insecure_skip_verify: true + # insecure_skip_verify: true # remote_write_queue: # enabled: true # queue_size: 100000 @@ -264,4 +264,4 @@ roleRef: subjects: - kind: ServiceAccount name: otel-daemon - namespace: {{ .Release.Namespace }} \ No newline at end of file + namespace: {{ .Release.Namespace }} diff --git a/otel/templates/otelcol_deployment.yaml b/otel/templates/otelcol_deployment.yaml index 1511efd..d457187 100644 --- a/otel/templates/otelcol_deployment.yaml +++ b/otel/templates/otelcol_deployment.yaml @@ -103,7 +103,7 @@ rules: - get - list - watch -- apiGroups: +- apiGroups: - "events.k8s.io" resources: - events @@ -124,4 +124,4 @@ roleRef: subjects: - kind: ServiceAccount name: otel-deployment - namespace: {{ .Release.Namespace }} \ No newline at end of file + namespace: {{ .Release.Namespace }} diff --git a/otel/values.yaml b/otel/values.yaml index 5254581..e89063b 100644 --- a/otel/values.yaml +++ b/otel/values.yaml @@ -22,4 +22,4 @@ otel: autoinstrumentation: java: image: "" - tag: "" \ No newline at end of file + tag: "" From 68bdf9fc18454a10c1d966a75d09c263a5b8dd02 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Mon, 14 Apr 2025 18:20:00 -0400 Subject: [PATCH 05/19] pull from ent-ecr --- .github/workflows/terraform-validate.yaml | 54 +++++++++++------------ README.md | 4 ++ copy_images.tf | 46 +++++++++++++------ variables.tf | 36 ++++++++------- 4 files changed, 83 insertions(+), 57 deletions(-) diff --git a/.github/workflows/terraform-validate.yaml b/.github/workflows/terraform-validate.yaml index 72829d8..04b96db 100644 --- a/.github/workflows/terraform-validate.yaml +++ b/.github/workflows/terraform-validate.yaml @@ -1,42 +1,40 @@ -name: Terraform Validate +name: Terraform CI/CD on: - pull_request: workflow_dispatch: - + pull_request: + types: [closed] + branches: + - main jobs: - - terraform-validate: - runs-on: "229685449397" + terraform-ci-cd: + runs-on: 229685449397 permissions: contents: write + steps: - name: Checkout code uses: CSVD/gh-actions-checkout@v4 - - name: Setup Terraform - uses: CSVD/gh-actions-setup-terraform@v2 + - name: Setup GITHUB Credentials + id: github_credentials + uses: CSVD/gh-auth@main with: - terraform_version: '1.7.3' - - - name: Validate Terraform Configuration - id: validate - uses: CSVD/terraform-validate@main + github_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }} + github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }} + github_app_id: ${{ vars.GH_APP_ID }} - - name: Check Validation/Test Results - if: always() + - name: Setup GitHub CLI run: | - # Set default values if outputs are empty - IS_VALID="${{ steps.validate.outputs.is_valid }}" - TESTS_PASSED="${{ steps.validate.outputs.tests_passed }}" + # Force manual authentication since setup-git might not work with GitHub Enterprise + echo "${{ steps.github_credentials.outputs.github_token }}" > /tmp/token.txt + gh auth login --with-token --hostname "github.e.it.census.gov" < /tmp/token.txt + rm /tmp/token.txt - # If outputs are empty, set them to false - [ -z "$IS_VALID" ] && IS_VALID="false" - [ -z "$TESTS_PASSED" ] && TESTS_PASSED="false" + # Test GitHub CLI auth status + gh auth status || echo "GitHub CLI authentication failed" - if [[ "$IS_VALID" != "true" || "$TESTS_PASSED" != "true" ]]; then - echo "Validation or test errors found:" - echo "${{ steps.validate.outputs.stderr }}" - exit 1 - else - echo "All validations and tests passed successfully!" - fi + - name: Run Release Action + uses: CSVD/releaser@main + with: + github-token: ${{ steps.github_credentials.outputs.github_token }} + working-directory: '.' diff --git a/README.md b/README.md index 0491327..5e396dd 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | Name | Version | |------|---------| +| [aws](#provider\_aws) | 5.93.0 | | [helm](#provider\_helm) | 2.17.0 | ## Modules @@ -33,11 +34,14 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O |------|------| | [helm_release.opentelemetry-operator](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [helm_release.otel-resources](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | +| [aws_ecr_authorization_token.ecr_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | +| [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [account\_id](#input\_account\_id) | aws account number | `string` | `""` | no | | [cluster\_name](#input\_cluster\_name) | EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev) | `string` | n/a | yes | | [loki\_endpoint](#input\_loki\_endpoint) | The internal endpoint for the loki service | `string` | n/a | yes | | [namespace](#input\_namespace) | Namespace in which to install open telemetry | `string` | `"telemetry"` | no | diff --git a/copy_images.tf b/copy_images.tf index 9019947..b2f9b8d 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -1,7 +1,7 @@ locals { - otel_name = "opentelemetry-operator" - otel_version = "0.110.0" - otel_key = format("%v#%v", local.otel_name, local.otel_version) + auto_instrumentation_java_name = "autoinstrumentation-java" + auto_instrumentation_java_version = "2.9.0" + auto_instrumentation_java_key = format("%v#%v", local.auto_instrumentation_java_name, local.auto_instrumentation_java_version) collector_name = "opentelemetry-collector-k8s" collector_version = "0.111.0-amd64" @@ -11,13 +11,16 @@ locals { collector_contrib_version = "0.113.0-amd64" collector_contrib_key = format("%v#%v", local.collector_contrib_name, local.collector_contrib_version) + ent_ecr_source = format("%v.%v.%v.%v", var.account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images") + + otel_name = "opentelemetry-operator" + otel_version = "0.110.0" + otel_key = format("%v#%v", local.otel_name, local.otel_version) + rbac_proxy_name = "kube-rbac-proxy" rbac_proxy_version = "v0.18.1" rbac_proxy_key = format("%v#%v", local.rbac_proxy_name, local.rbac_proxy_version) - auto_instrumentation_java_name = "autoinstrumentation-java" - auto_instrumentation_java_version = "2.9.0" - auto_instrumentation_java_key = format("%v#%v", local.auto_instrumentation_java_name, local.auto_instrumentation_java_version) image_config = [ { @@ -25,7 +28,7 @@ locals { dest_path = null name = local.otel_name source_image = "otel/${local.otel_name}" - source_registry = "docker.io" + source_registry = format("%v/%v", local.ent_ecr_source, "docker") source_tag = local.otel_version tag = local.otel_version }, @@ -34,7 +37,7 @@ locals { dest_path = null name = local.collector_name source_image = "otel/${local.collector_name}" - source_registry = "docker.io" + source_registry = format("%v/%v", local.ent_ecr_source, "docker") source_tag = local.collector_version tag = local.collector_version }, @@ -43,7 +46,7 @@ locals { dest_path = null name = local.collector_contrib_name source_image = "otel/${local.collector_contrib_name}" - source_registry = "docker.io" + source_registry = format("%v/%v", local.ent_ecr_source, "docker") source_tag = local.collector_contrib_version tag = local.collector_contrib_version }, @@ -52,7 +55,7 @@ locals { dest_path = null name = local.rbac_proxy_name source_image = "brancz/${local.rbac_proxy_name}" - source_registry = "quay.io" + source_registry = format("%v/%v", local.ent_ecr_source, "quay") source_tag = local.rbac_proxy_version tag = local.rbac_proxy_version }, @@ -61,7 +64,7 @@ locals { dest_path = null name = local.auto_instrumentation_java_name source_image = "open-telemetry/opentelemetry-operator/${local.auto_instrumentation_java_name}" - source_registry = "ghcr.io" + source_registry = format("%v/%v", local.ent_ecr_source, "ghcr") source_tag = local.auto_instrumentation_java_version tag = local.auto_instrumentation_java_version } @@ -76,7 +79,22 @@ module "images" { image_config = local.image_config tags = {} - enable_lifecycle_policy = true - lifecycle_policy_all = true - force_delete = true + enable_lifecycle_policy = true + lifecycle_policy_all = true + force_delete = true + lifecycle_policy_keep_count = 5 + + source_username = data.aws_ecr_authorization_token.ecr_token.user_name + source_password = data.aws_ecr_authorization_token.ecr_token.password + + destination_username = data.aws_ecr_authorization_token.token.user_name + destination_password = data.aws_ecr_authorization_token.token.password +} + +data "aws_ecr_authorization_token" "ecr_token" { + registry_id = var.account_id +} + +data "aws_ecr_authorization_token" "token" { + registry_id = var.account_id } diff --git a/variables.tf b/variables.tf index 9225b59..9f5f22b 100644 --- a/variables.tf +++ b/variables.tf @@ -1,24 +1,23 @@ -variable "cluster_name" { - description = "EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev)" +variable "account_id" { + description = "aws account number" type = string + default = "" } -variable "namespace" { - description = "Namespace in which to install open telemetry" +variable "cluster_name" { + description = "EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev)" type = string - default = "telemetry" } -# tflint-ignore: terraform_unused_declarations -variable "region" { - description = "AWS region" +variable "loki_endpoint" { + description = "The internal endpoint for the loki service" type = string } -variable "profile" { - description = "AWS config profile" +variable "namespace" { + description = "Namespace in which to install open telemetry" type = string - default = "" + default = "telemetry" } variable "otel_helm_repo" { @@ -33,13 +32,15 @@ variable "otel_helm_version" { default = "0.71.2" } -variable "loki_endpoint" { - description = "The internal endpoint for the loki service" +variable "profile" { + description = "AWS config profile" type = string + default = "" } -variable "tempo_endpoint" { - description = "Internal otlp endpoint of tempo" +# tflint-ignore: terraform_unused_declarations +variable "region" { + description = "AWS region" type = string } @@ -49,3 +50,8 @@ variable "tags" { type = map(string) default = {} } + +variable "tempo_endpoint" { + description = "Internal otlp endpoint of tempo" + type = string +} From ef5ecbfcfe884909c355a547d9813e78efc7fad2 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Mon, 14 Apr 2025 19:25:35 -0400 Subject: [PATCH 06/19] pull from ent-ecr --- copy_images.tf | 4 ++-- variables.tf | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/copy_images.tf b/copy_images.tf index b2f9b8d..5f4141d 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -54,8 +54,8 @@ locals { enabled = true dest_path = null name = local.rbac_proxy_name - source_image = "brancz/${local.rbac_proxy_name}" - source_registry = format("%v/%v", local.ent_ecr_source, "quay") + source_image = "opensource/coreos/${local.rbac_proxy_name}" + source_registry = format("%v/%v", local.ent_ecr_source, "ironbank") source_tag = local.rbac_proxy_version tag = local.rbac_proxy_version }, diff --git a/variables.tf b/variables.tf index 9f5f22b..94b63e4 100644 --- a/variables.tf +++ b/variables.tf @@ -38,7 +38,6 @@ variable "profile" { default = "" } -# tflint-ignore: terraform_unused_declarations variable "region" { description = "AWS region" type = string From 6cfe8fc1f9989be13dc31344d7e9c8621754f903 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Mon, 14 Apr 2025 19:34:05 -0400 Subject: [PATCH 07/19] fix source path --- copy_images.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/copy_images.tf b/copy_images.tf index 5f4141d..aff897d 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -27,7 +27,7 @@ locals { enabled = true dest_path = null name = local.otel_name - source_image = "otel/${local.otel_name}" + source_image = local.otel_name source_registry = format("%v/%v", local.ent_ecr_source, "docker") source_tag = local.otel_version tag = local.otel_version @@ -36,7 +36,7 @@ locals { enabled = true dest_path = null name = local.collector_name - source_image = "otel/${local.collector_name}" + source_image = local.collector_name source_registry = format("%v/%v", local.ent_ecr_source, "docker") source_tag = local.collector_version tag = local.collector_version @@ -45,7 +45,7 @@ locals { enabled = true dest_path = null name = local.collector_contrib_name - source_image = "otel/${local.collector_contrib_name}" + source_image = local.collector_contrib_name source_registry = format("%v/%v", local.ent_ecr_source, "docker") source_tag = local.collector_contrib_version tag = local.collector_contrib_version From 616da5c2fe2b11c84d060c886917da930a79139d Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Thu, 17 Apr 2025 14:18:37 -0400 Subject: [PATCH 08/19] pull across accounts from central ecr --- README.md | 3 ++- copy_images.tf | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e396dd..c886b85 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.93.0 | +| [aws](#provider\_aws) | 5.94.1 | +| [aws.eecr](#provider\_aws.eecr) | 5.94.1 | | [helm](#provider\_helm) | 2.17.0 | ## Modules diff --git a/copy_images.tf b/copy_images.tf index aff897d..ef23d0f 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -92,7 +92,8 @@ module "images" { } data "aws_ecr_authorization_token" "ecr_token" { - registry_id = var.account_id + provider = aws.eecr + registry_id = var.eecr_account_id } data "aws_ecr_authorization_token" "token" { From fe0aeb0f16ec6337fed71f4b46d3928c2116361d Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Thu, 17 Apr 2025 17:46:42 -0400 Subject: [PATCH 09/19] add eecr_account_id --- README.md | 1 + variables.tf | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index c886b85..e0caedb 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O |------|-------------|------|---------|:--------:| | [account\_id](#input\_account\_id) | aws account number | `string` | `""` | no | | [cluster\_name](#input\_cluster\_name) | EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev) | `string` | n/a | yes | +| [eecr\_account\_id](#input\_eecr\_account\_id) | enterpirse ecr source aws account number | `string` | `""` | no | | [loki\_endpoint](#input\_loki\_endpoint) | The internal endpoint for the loki service | `string` | n/a | yes | | [namespace](#input\_namespace) | Namespace in which to install open telemetry | `string` | `"telemetry"` | no | | [otel\_helm\_repo](#input\_otel\_helm\_repo) | Helm repo for official opentelemetry | `string` | `"https://open-telemetry.github.io/opentelemetry-helm-charts"` | no | diff --git a/variables.tf b/variables.tf index 94b63e4..d945735 100644 --- a/variables.tf +++ b/variables.tf @@ -9,6 +9,12 @@ variable "cluster_name" { type = string } +variable "eecr_account_id" { + description = "enterpirse ecr source aws account number" + type = string + default = "" +} + variable "loki_endpoint" { description = "The internal endpoint for the loki service" type = string From 13167fb56043c07631bc3315a8fba87accbdbbe7 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Thu, 17 Apr 2025 19:35:55 -0400 Subject: [PATCH 10/19] fix ent_ecr_source --- copy_images.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copy_images.tf b/copy_images.tf index ef23d0f..1d6836c 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -11,7 +11,7 @@ locals { collector_contrib_version = "0.113.0-amd64" collector_contrib_key = format("%v#%v", local.collector_contrib_name, local.collector_contrib_version) - ent_ecr_source = format("%v.%v.%v.%v", var.account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images") + ent_ecr_source = format("%v.%v.%v.%v", var.eecr_account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images") otel_name = "opentelemetry-operator" otel_version = "0.110.0" From 4d03bf99733f1e438ece00ecbbe759bdc2e984dc Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Thu, 17 Apr 2025 23:32:08 -0400 Subject: [PATCH 11/19] dynamic version --- README.md | 4 ++++ requirements.tf | 4 ++++ version.tf | 27 +++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e0caedb..7aeaa20 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | [terraform](#requirement\_terraform) | >= 0.13 | | [aws](#requirement\_aws) | >= 5.14.0 | | [helm](#requirement\_helm) | >= 2.11.0 | +| [null](#requirement\_null) | >= 3.2.1 | ## Providers @@ -22,6 +23,7 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | [aws](#provider\_aws) | 5.94.1 | | [aws.eecr](#provider\_aws.eecr) | 5.94.1 | | [helm](#provider\_helm) | 2.17.0 | +| [null](#provider\_null) | 3.2.3 | ## Modules @@ -35,6 +37,8 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O |------|------| | [helm_release.opentelemetry-operator](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [helm_release.otel-resources](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | +| [null_resource.git_version](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [null_resource.module_name](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [aws_ecr_authorization_token.ecr_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | | [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | diff --git a/requirements.tf b/requirements.tf index 2e678e4..5cd741d 100644 --- a/requirements.tf +++ b/requirements.tf @@ -10,5 +10,9 @@ terraform { source = "hashicorp/helm" version = ">= 2.11.0" } + null = { + source = "hashicorp/null" + version = ">= 3.2.1" + } } } diff --git a/version.tf b/version.tf index 7f30ac4..665110b 100644 --- a/version.tf +++ b/version.tf @@ -1,4 +1,27 @@ +resource "null_resource" "git_version" { + triggers = { + # Force this to run on every apply to get the latest tag value + always_run = timestamp() + } + + provisioner "local-exec" { + command = "git describe --tags --abbrev=0 2>/dev/null || echo 'unknown' > ${path.module}/.git_tag" + on_failure = continue + } +} + +resource "null_resource" "module_name" { + triggers = { + module_path = path.module + } + + provisioner "local-exec" { + command = "basename $(pwd) > ${path.module}/.module_name" + on_failure = continue + } +} + locals { - module_name = "tfmod-open-telemetry" - module_version = "0.0.1" + module_name = fileexists("${path.module}/.module_name") ? trimspace(file("${path.module}/.module_name")) : "tfmod-open-telemetry" + module_version = fileexists("${path.module}/.git_tag") ? trimspace(file("${path.module}/.git_tag")) : "latest" } From e7b00790fcff507fa1a92e4bec8235296584b71f Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Fri, 18 Apr 2025 12:29:02 -0400 Subject: [PATCH 12/19] update image sources --- README.md | 5 +++++ copy_images.tf | 16 ++++++++-------- variables.tf | 30 ++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7aeaa20..05a270e 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,18 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [account\_id](#input\_account\_id) | aws account number | `string` | `""` | no | +| [auto\_instrumentation\_java\_version](#input\_auto\_instrumentation\_java\_version) | Which version of auto\_instrumentation for java | `string` | `"2.9.0"` | no | | [cluster\_name](#input\_cluster\_name) | EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev) | `string` | n/a | yes | +| [collector\_contrib\_version](#input\_collector\_contrib\_version) | Which version of collector\_contrib | `string` | `"0.113.0"` | no | +| [collector\_version](#input\_collector\_version) | Which version of collector | `string` | `"0.100.0"` | no | | [eecr\_account\_id](#input\_eecr\_account\_id) | enterpirse ecr source aws account number | `string` | `""` | no | | [loki\_endpoint](#input\_loki\_endpoint) | The internal endpoint for the loki service | `string` | n/a | yes | | [namespace](#input\_namespace) | Namespace in which to install open telemetry | `string` | `"telemetry"` | no | | [otel\_helm\_repo](#input\_otel\_helm\_repo) | Helm repo for official opentelemetry | `string` | `"https://open-telemetry.github.io/opentelemetry-helm-charts"` | no | | [otel\_helm\_version](#input\_otel\_helm\_version) | Which helm chart version of opentelemetry | `string` | `"0.71.2"` | no | +| [otel\_version](#input\_otel\_version) | Which version of opentelemetry | `string` | `"0.100.0"` | no | | [profile](#input\_profile) | AWS config profile | `string` | `""` | no | +| [rbac\_proxy\_version](#input\_rbac\_proxy\_version) | Which version of rbac\_proxy | `string` | `"0.100.0"` | no | | [region](#input\_region) | AWS region | `string` | n/a | yes | | [tags](#input\_tags) | AWS Tags to apply to appropriate resources | `map(string)` | `{}` | no | | [tempo\_endpoint](#input\_tempo\_endpoint) | Internal otlp endpoint of tempo | `string` | n/a | yes | diff --git a/copy_images.tf b/copy_images.tf index 1d6836c..f656bc0 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -1,24 +1,24 @@ locals { auto_instrumentation_java_name = "autoinstrumentation-java" - auto_instrumentation_java_version = "2.9.0" + auto_instrumentation_java_version = var.auto_instrumentation_java_version auto_instrumentation_java_key = format("%v#%v", local.auto_instrumentation_java_name, local.auto_instrumentation_java_version) collector_name = "opentelemetry-collector-k8s" - collector_version = "0.111.0-amd64" + collector_version = var.collector_version collector_key = format("%v#%v", local.collector_name, local.collector_version) collector_contrib_name = "opentelemetry-collector-contrib" - collector_contrib_version = "0.113.0-amd64" + collector_contrib_version = var.collector_contrib_version collector_contrib_key = format("%v#%v", local.collector_contrib_name, local.collector_contrib_version) ent_ecr_source = format("%v.%v.%v.%v", var.eecr_account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images") otel_name = "opentelemetry-operator" - otel_version = "0.110.0" + otel_version = var.otel_version otel_key = format("%v#%v", local.otel_name, local.otel_version) rbac_proxy_name = "kube-rbac-proxy" - rbac_proxy_version = "v0.18.1" + rbac_proxy_version = var.rbac_proxy_version rbac_proxy_key = format("%v#%v", local.rbac_proxy_name, local.rbac_proxy_version) @@ -28,7 +28,7 @@ locals { dest_path = null name = local.otel_name source_image = local.otel_name - source_registry = format("%v/%v", local.ent_ecr_source, "docker") + source_registry = format("%v/%v", local.ent_ecr_source, "docker-io") source_tag = local.otel_version tag = local.otel_version }, @@ -37,7 +37,7 @@ locals { dest_path = null name = local.collector_name source_image = local.collector_name - source_registry = format("%v/%v", local.ent_ecr_source, "docker") + source_registry = format("%v/%v", local.ent_ecr_source, "docke-ior") source_tag = local.collector_version tag = local.collector_version }, @@ -46,7 +46,7 @@ locals { dest_path = null name = local.collector_contrib_name source_image = local.collector_contrib_name - source_registry = format("%v/%v", local.ent_ecr_source, "docker") + source_registry = format("%v/%v", local.ent_ecr_source, "docker-io") source_tag = local.collector_contrib_version tag = local.collector_contrib_version }, diff --git a/variables.tf b/variables.tf index d945735..32d37a5 100644 --- a/variables.tf +++ b/variables.tf @@ -4,11 +4,29 @@ variable "account_id" { default = "" } +variable "auto_instrumentation_java_version" { + description = "Which version of auto_instrumentation for java" + type = string + default = "2.9.0" +} + variable "cluster_name" { description = "EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev)" type = string } +variable "collector_contrib_version" { + description = "Which version of collector_contrib" + type = string + default = "0.113.0" +} + +variable "collector_version" { + description = "Which version of collector" + type = string + default = "0.100.0" +} + variable "eecr_account_id" { description = "enterpirse ecr source aws account number" type = string @@ -38,12 +56,24 @@ variable "otel_helm_version" { default = "0.71.2" } +variable "otel_version" { + description = "Which version of opentelemetry" + type = string + default = "0.100.0" +} + variable "profile" { description = "AWS config profile" type = string default = "" } +variable "rbac_proxy_version" { + description = "Which version of rbac_proxy" + type = string + default = "0.100.0" +} + variable "region" { description = "AWS region" type = string From 025d021e0e9c4d0d7d2a78c94cf690f5067fd9f3 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Fri, 18 Apr 2025 12:34:25 -0400 Subject: [PATCH 13/19] typo --- copy_images.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copy_images.tf b/copy_images.tf index f656bc0..31380b0 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -37,7 +37,7 @@ locals { dest_path = null name = local.collector_name source_image = local.collector_name - source_registry = format("%v/%v", local.ent_ecr_source, "docke-ior") + source_registry = format("%v/%v", local.ent_ecr_source, "docker-io") source_tag = local.collector_version tag = local.collector_version }, From 0adabcf77bfe911f506ec8d5910e351b3c275636 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Fri, 18 Apr 2025 15:01:32 -0400 Subject: [PATCH 14/19] remove eecr data item as it is in the provider --- README.md | 2 -- copy_images.tf | 5 ----- 2 files changed, 7 deletions(-) diff --git a/README.md b/README.md index 05a270e..6fac68c 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | Name | Version | |------|---------| | [aws](#provider\_aws) | 5.94.1 | -| [aws.eecr](#provider\_aws.eecr) | 5.94.1 | | [helm](#provider\_helm) | 2.17.0 | | [null](#provider\_null) | 3.2.3 | @@ -39,7 +38,6 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | [helm_release.otel-resources](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [null_resource.git_version](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [null_resource.module_name](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | -| [aws_ecr_authorization_token.ecr_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | | [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | ## Inputs diff --git a/copy_images.tf b/copy_images.tf index 31380b0..73daf46 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -91,11 +91,6 @@ module "images" { destination_password = data.aws_ecr_authorization_token.token.password } -data "aws_ecr_authorization_token" "ecr_token" { - provider = aws.eecr - registry_id = var.eecr_account_id -} - data "aws_ecr_authorization_token" "token" { registry_id = var.account_id } From ed40debccc602bf11e24162e6e3b754aca3fda25 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Fri, 18 Apr 2025 21:15:07 -0400 Subject: [PATCH 15/19] update copy images for eecr pulling --- README.md | 2 ++ copy_images.tf | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 6fac68c..05a270e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | Name | Version | |------|---------| | [aws](#provider\_aws) | 5.94.1 | +| [aws.eecr](#provider\_aws.eecr) | 5.94.1 | | [helm](#provider\_helm) | 2.17.0 | | [null](#provider\_null) | 3.2.3 | @@ -38,6 +39,7 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | [helm_release.otel-resources](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [null_resource.git_version](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [null_resource.module_name](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [aws_ecr_authorization_token.ecr_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | | [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | ## Inputs diff --git a/copy_images.tf b/copy_images.tf index 73daf46..6322660 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -94,3 +94,14 @@ module "images" { data "aws_ecr_authorization_token" "token" { registry_id = var.account_id } + +data "aws_ecr_authorization_token" "ecr_token" { + provider = aws.eecr + registry_id = var.eecr_info.account_id +} + +provider "aws" { + alias = "eecr" + profile = var.eecr_info.profile + region = var.eecr_info.region +} From 0286916a9667dbe5c1afcf223fad946af519537b Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Fri, 18 Apr 2025 21:34:17 -0400 Subject: [PATCH 16/19] update var and ent_ecr_source --- README.md | 2 +- copy_images.tf | 2 +- variables.tf | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 05a270e..848377e 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | [cluster\_name](#input\_cluster\_name) | EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev) | `string` | n/a | yes | | [collector\_contrib\_version](#input\_collector\_contrib\_version) | Which version of collector\_contrib | `string` | `"0.113.0"` | no | | [collector\_version](#input\_collector\_version) | Which version of collector | `string` | `"0.100.0"` | no | -| [eecr\_account\_id](#input\_eecr\_account\_id) | enterpirse ecr source aws account number | `string` | `""` | no | +| [eecr\_info](#input\_eecr\_info) | Enterprise ECR source information |
object({
account_id = string
alias = string
profile = string
region = string
})
|
{
"account_id": "269222635945",
"alias": "lab-gov-shared-nonprod",
"profile": "269222635945-lab-gov-shared-nonprod",
"region": "us-gov-east-1"
}
| no | | [loki\_endpoint](#input\_loki\_endpoint) | The internal endpoint for the loki service | `string` | n/a | yes | | [namespace](#input\_namespace) | Namespace in which to install open telemetry | `string` | `"telemetry"` | no | | [otel\_helm\_repo](#input\_otel\_helm\_repo) | Helm repo for official opentelemetry | `string` | `"https://open-telemetry.github.io/opentelemetry-helm-charts"` | no | diff --git a/copy_images.tf b/copy_images.tf index 6322660..81118dd 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -11,7 +11,7 @@ locals { collector_contrib_version = var.collector_contrib_version collector_contrib_key = format("%v#%v", local.collector_contrib_name, local.collector_contrib_version) - ent_ecr_source = format("%v.%v.%v.%v", var.eecr_account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images") + ent_ecr_source = format("%v.%v.%v.%v", var.eecr_info.account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images") otel_name = "opentelemetry-operator" otel_version = var.otel_version diff --git a/variables.tf b/variables.tf index 32d37a5..e4f1351 100644 --- a/variables.tf +++ b/variables.tf @@ -27,10 +27,20 @@ variable "collector_version" { default = "0.100.0" } -variable "eecr_account_id" { - description = "enterpirse ecr source aws account number" - type = string - default = "" +variable "eecr_info" { + description = "Enterprise ECR source information" + type = object({ + account_id = string + alias = string + profile = string + region = string + }) + default = { + account_id = "269222635945" + alias = "lab-gov-shared-nonprod" + profile = "269222635945-lab-gov-shared-nonprod" + region = "us-gov-east-1" + } } variable "loki_endpoint" { From d31a47543a0a72118004dec15a2ec81444ec06c3 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Mon, 21 Apr 2025 11:42:32 -0400 Subject: [PATCH 17/19] ensure workflows are current --- .github/workflows/terraform-release.yaml | 2 +- terraform-release.yaml | 40 ++++++++++++++++++++++ terraform-validate.yaml | 42 ++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 terraform-release.yaml create mode 100644 terraform-validate.yaml diff --git a/.github/workflows/terraform-release.yaml b/.github/workflows/terraform-release.yaml index 90910bc..b91ef15 100644 --- a/.github/workflows/terraform-release.yaml +++ b/.github/workflows/terraform-release.yaml @@ -7,7 +7,7 @@ on: - main jobs: terraform-ci-cd: - runs-on: 229685449397 + runs-on: "229685449397" permissions: contents: write diff --git a/terraform-release.yaml b/terraform-release.yaml new file mode 100644 index 0000000..3f67574 --- /dev/null +++ b/terraform-release.yaml @@ -0,0 +1,40 @@ +name: Terraform Module Release +on: + workflow_dispatch: + pull_request: + types: [closed] + branches: + - main +jobs: + terraform-release: + runs-on: "229685449397" + permissions: + contents: write + + steps: + - name: Checkout code + uses: CSVD/gh-actions-checkout@v4 + + - name: Setup GITHUB Credentials + id: github_credentials + uses: CSVD/gh-auth@main + with: + github_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }} + github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }} + github_app_id: ${{ vars.GH_APP_ID }} + + - name: Setup GitHub CLI + run: | + # Force manual authentication since setup-git might not work with GitHub Enterprise + echo "${{ steps.github_credentials.outputs.github_token }}" > /tmp/token.txt + gh auth login --with-token --hostname "github.e.it.census.gov" < /tmp/token.txt + rm /tmp/token.txt + + # Test GitHub CLI auth status + gh auth status || echo "GitHub CLI authentication failed" + + - name: Run Release Action + uses: CSVD/releaser@main + with: + github-token: ${{ steps.github_credentials.outputs.github_token }} + working-directory: '.' diff --git a/terraform-validate.yaml b/terraform-validate.yaml new file mode 100644 index 0000000..ac349eb --- /dev/null +++ b/terraform-validate.yaml @@ -0,0 +1,42 @@ +name: Terraform Validate +on: + pull_request: + workflow_dispatch: + +jobs: + + terraform-validate: + runs-on: "229685449397" + permissions: + contents: write + steps: + - name: Checkout code + uses: CSVD/gh-actions-checkout@v4 + + - name: Setup Terraform + uses: CSVD/gh-actions-setup-terraform@v2 + with: + terraform_version: '1.10.5' + + - name: Validate Terraform Configuration + id: validate + uses: CSVD/terraform-validate@main + + - name: Check Validation/Test Results + if: always() + run: | + # Set default values if outputs are empty + IS_VALID="${{ steps.validate.outputs.is_valid }}" + TESTS_PASSED="${{ steps.validate.outputs.tests_passed }}" + + # If outputs are empty, set them to false + [ -z "$IS_VALID" ] && IS_VALID="false" + [ -z "$TESTS_PASSED" ] && TESTS_PASSED="false" + + if [[ "$IS_VALID" != "true" || "$TESTS_PASSED" != "true" ]]; then + echo "Validation or test errors found:" + echo "${{ steps.validate.outputs.stderr }}" + exit 1 + else + echo "All validations and tests passed successfully!" + fi From 94dbd56dc9bfa10b86e4e1554b122ae7f652c372 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Mon, 21 Apr 2025 15:43:10 -0400 Subject: [PATCH 18/19] ensure workflows are current --- .github/workflows/terraform-release.yaml | 41 +++-------------------- terraform-release.yaml | 40 ---------------------- terraform-validate.yaml | 42 ------------------------ 3 files changed, 4 insertions(+), 119 deletions(-) delete mode 100644 terraform-release.yaml delete mode 100644 terraform-validate.yaml diff --git a/.github/workflows/terraform-release.yaml b/.github/workflows/terraform-release.yaml index b91ef15..3f67574 100644 --- a/.github/workflows/terraform-release.yaml +++ b/.github/workflows/terraform-release.yaml @@ -1,4 +1,4 @@ -name: Terraform CI/CD +name: Terraform Module Release on: workflow_dispatch: pull_request: @@ -6,7 +6,7 @@ on: branches: - main jobs: - terraform-ci-cd: + terraform-release: runs-on: "229685449397" permissions: contents: write @@ -15,11 +15,6 @@ jobs: - name: Checkout code uses: CSVD/gh-actions-checkout@v4 - - name: Setup Terraform - uses: CSVD/gh-actions-setup-terraform@v3 - with: - terraform_version: "1.9.1" - - name: Setup GITHUB Credentials id: github_credentials uses: CSVD/gh-auth@main @@ -28,28 +23,6 @@ jobs: github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }} github_app_id: ${{ vars.GH_APP_ID }} - - - name: Debug Authentication - run: | - # Print the GitHub server URL - echo "GitHub Server URL: ${{ github.server_url }}" - - # Extract the host from the URL - HOST="${{ github.server_url }}" - HOST="${HOST#*//}" - HOST="${HOST%%/*}" - echo "GitHub Host: $HOST" - - # Check if token exists - if [[ -n "${{ steps.github_credentials.outputs.github_token }}" ]]; then - echo "Token generated successfully" - # Test the token with a simple GitHub API call (without exposing the token) - STATUS=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${{ steps.github_credentials.outputs.github_token }}" "${{ github.server_url }}/api/v3/user") - echo "API Test Status Code: $STATUS" - else - echo "No token was generated!" - fi - - name: Setup GitHub CLI run: | # Force manual authentication since setup-git might not work with GitHub Enterprise @@ -60,14 +33,8 @@ jobs: # Test GitHub CLI auth status gh auth status || echo "GitHub CLI authentication failed" - - name: AWS Auth - id: aws_auth - uses: CSVD/aws-auth@main - with: - ecs: true - - - name: Run Terraform Module Release Action - uses: CSVD/terraform-module-release@main + - name: Run Release Action + uses: CSVD/releaser@main with: github-token: ${{ steps.github_credentials.outputs.github_token }} working-directory: '.' diff --git a/terraform-release.yaml b/terraform-release.yaml deleted file mode 100644 index 3f67574..0000000 --- a/terraform-release.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Terraform Module Release -on: - workflow_dispatch: - pull_request: - types: [closed] - branches: - - main -jobs: - terraform-release: - runs-on: "229685449397" - permissions: - contents: write - - steps: - - name: Checkout code - uses: CSVD/gh-actions-checkout@v4 - - - name: Setup GITHUB Credentials - id: github_credentials - uses: CSVD/gh-auth@main - with: - github_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }} - github_app_installation_id: ${{ vars.GH_APP_INSTALLATION_ID }} - github_app_id: ${{ vars.GH_APP_ID }} - - - name: Setup GitHub CLI - run: | - # Force manual authentication since setup-git might not work with GitHub Enterprise - echo "${{ steps.github_credentials.outputs.github_token }}" > /tmp/token.txt - gh auth login --with-token --hostname "github.e.it.census.gov" < /tmp/token.txt - rm /tmp/token.txt - - # Test GitHub CLI auth status - gh auth status || echo "GitHub CLI authentication failed" - - - name: Run Release Action - uses: CSVD/releaser@main - with: - github-token: ${{ steps.github_credentials.outputs.github_token }} - working-directory: '.' diff --git a/terraform-validate.yaml b/terraform-validate.yaml deleted file mode 100644 index ac349eb..0000000 --- a/terraform-validate.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Terraform Validate -on: - pull_request: - workflow_dispatch: - -jobs: - - terraform-validate: - runs-on: "229685449397" - permissions: - contents: write - steps: - - name: Checkout code - uses: CSVD/gh-actions-checkout@v4 - - - name: Setup Terraform - uses: CSVD/gh-actions-setup-terraform@v2 - with: - terraform_version: '1.10.5' - - - name: Validate Terraform Configuration - id: validate - uses: CSVD/terraform-validate@main - - - name: Check Validation/Test Results - if: always() - run: | - # Set default values if outputs are empty - IS_VALID="${{ steps.validate.outputs.is_valid }}" - TESTS_PASSED="${{ steps.validate.outputs.tests_passed }}" - - # If outputs are empty, set them to false - [ -z "$IS_VALID" ] && IS_VALID="false" - [ -z "$TESTS_PASSED" ] && TESTS_PASSED="false" - - if [[ "$IS_VALID" != "true" || "$TESTS_PASSED" != "true" ]]; then - echo "Validation or test errors found:" - echo "${{ steps.validate.outputs.stderr }}" - exit 1 - else - echo "All validations and tests passed successfully!" - fi From 6e0f63497b20aadbc1db776f4e960915aa2ad4bc Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Tue, 22 Apr 2025 00:04:50 -0400 Subject: [PATCH 19/19] ensure committed --- README.md | 1 - version.tf | 13 +------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/README.md b/README.md index 848377e..8c4c4ae 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ This modules installs the OpenTelemetry Collector operator and two Collectors. O | [helm_release.opentelemetry-operator](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [helm_release.otel-resources](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | | [null_resource.git_version](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | -| [null_resource.module_name](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [aws_ecr_authorization_token.ecr_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | | [aws_ecr_authorization_token.token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ecr_authorization_token) | data source | diff --git a/version.tf b/version.tf index 665110b..f36ca8a 100644 --- a/version.tf +++ b/version.tf @@ -10,18 +10,7 @@ resource "null_resource" "git_version" { } } -resource "null_resource" "module_name" { - triggers = { - module_path = path.module - } - - provisioner "local-exec" { - command = "basename $(pwd) > ${path.module}/.module_name" - on_failure = continue - } -} - locals { - module_name = fileexists("${path.module}/.module_name") ? trimspace(file("${path.module}/.module_name")) : "tfmod-open-telemetry" + module_name = "tfmod-open-telemetry" module_version = fileexists("${path.module}/.git_tag") ? trimspace(file("${path.module}/.git_tag")) : "latest" }