diff --git a/.github/workflows/terraform-release.yaml b/.github/workflows/terraform-release.yaml index 90910bc..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,8 +6,8 @@ on: branches: - main jobs: - terraform-ci-cd: - runs-on: 229685449397 + 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/.github/workflows/terraform-validate.yaml b/.github/workflows/terraform-validate.yaml index 72829d8..ac349eb 100644 --- a/.github/workflows/terraform-validate.yaml +++ b/.github/workflows/terraform-validate.yaml @@ -16,7 +16,7 @@ jobs: - name: Setup Terraform uses: CSVD/gh-actions-setup-terraform@v2 with: - terraform_version: '1.7.3' + terraform_version: '1.10.5' - name: Validate Terraform Configuration id: validate diff --git a/README.md b/README.md index 0491327..8c4c4ae 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,16 @@ 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 | 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 | ## Modules @@ -33,17 +37,27 @@ 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 | +| [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 | +| [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\_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 | | [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 9019947..81118dd 100644 --- a/copy_images.tf +++ b/copy_images.tf @@ -1,31 +1,34 @@ 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 = 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_info.account_id, "dkr.ecr", var.region, "amazonaws.com/ent-images") + + otel_name = "opentelemetry-operator" + 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) - 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 = [ { enabled = true dest_path = null name = local.otel_name - source_image = "otel/${local.otel_name}" - source_registry = "docker.io" + source_image = local.otel_name + source_registry = format("%v/%v", local.ent_ecr_source, "docker-io") source_tag = local.otel_version tag = local.otel_version }, @@ -33,8 +36,8 @@ locals { enabled = true dest_path = null name = local.collector_name - source_image = "otel/${local.collector_name}" - source_registry = "docker.io" + source_image = local.collector_name + source_registry = format("%v/%v", local.ent_ecr_source, "docker-io") source_tag = local.collector_version tag = local.collector_version }, @@ -42,8 +45,8 @@ locals { enabled = true dest_path = null name = local.collector_contrib_name - source_image = "otel/${local.collector_contrib_name}" - source_registry = "docker.io" + source_image = local.collector_contrib_name + source_registry = format("%v/%v", local.ent_ecr_source, "docker-io") source_tag = local.collector_contrib_version tag = local.collector_contrib_version }, @@ -51,8 +54,8 @@ locals { enabled = true dest_path = null name = local.rbac_proxy_name - source_image = "brancz/${local.rbac_proxy_name}" - source_registry = "quay.io" + 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 }, @@ -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,29 @@ 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" "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 } 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/variables.tf b/variables.tf index 9225b59..e4f1351 100644 --- a/variables.tf +++ b/variables.tf @@ -1,24 +1,57 @@ +variable "account_id" { + description = "aws account number" + type = string + 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 "namespace" { - description = "Namespace in which to install open telemetry" +variable "collector_contrib_version" { + description = "Which version of collector_contrib" type = string - default = "telemetry" + default = "0.113.0" } -# tflint-ignore: terraform_unused_declarations -variable "region" { - description = "AWS region" +variable "collector_version" { + description = "Which version of collector" type = string + default = "0.100.0" } -variable "profile" { - description = "AWS config profile" +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" { + description = "The internal endpoint for the loki service" type = string - default = "" +} + +variable "namespace" { + description = "Namespace in which to install open telemetry" + type = string + default = "telemetry" } variable "otel_helm_repo" { @@ -33,13 +66,26 @@ variable "otel_helm_version" { default = "0.71.2" } -variable "loki_endpoint" { - description = "The internal endpoint for the loki service" +variable "otel_version" { + description = "Which version of opentelemetry" type = string + default = "0.100.0" } -variable "tempo_endpoint" { - description = "Internal otlp endpoint of tempo" +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 } @@ -49,3 +95,8 @@ variable "tags" { type = map(string) default = {} } + +variable "tempo_endpoint" { + description = "Internal otlp endpoint of tempo" + type = string +} diff --git a/version.tf b/version.tf index 7f30ac4..f36ca8a 100644 --- a/version.tf +++ b/version.tf @@ -1,4 +1,16 @@ +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 + } +} + locals { module_name = "tfmod-open-telemetry" - module_version = "0.0.1" + module_version = fileexists("${path.module}/.git_tag") ? trimspace(file("${path.module}/.git_tag")) : "latest" }