diff --git a/.github/workflows/terraform-release.yaml b/.github/workflows/terraform-release.yaml
new file mode 100644
index 0000000..90910bc
--- /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..72829d8
--- /dev/null
+++ b/.github/workflows/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.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/.github/workflows/terragrunt-cicd.yml b/.github/workflows/terragrunt-cicd.yml
deleted file mode 100644
index a78523e..0000000
--- a/.github/workflows/terragrunt-cicd.yml
+++ /dev/null
@@ -1,101 +0,0 @@
-name: 'Terraform Module CI'
-
-on:
- push:
- branches:
- - main
- paths:
- - '**/*.hcl'
- - '**/*.tf'
- pull_request:
- branches:
- - main
- paths:
- - '**/*.hcl'
- - '**/*.tf'
-
-permissions:
- contents: read
- pull-requests: write
-
-jobs:
- validate:
- name: 'Validate Module'
- runs-on: self-hosted
-
- steps:
- - name: Checkout
- uses: actions/checkout@v3
-
- - name: Setup Terraform
- uses: hashicorp/setup-terraform@v2
- with:
- terraform_version: 1.5.0
-
- - name: Terraform Init
- run: |
- terraform init -backend=false
-
- - name: Terraform Format
- run: |
- terraform fmt -check
-
- - name: Terraform Validate
- run: |
- terraform validate
-
- - name: Run tflint
- uses: terraform-linters/setup-tflint@v3
- if: github.event_name == 'pull_request'
-
- - name: Lint Terraform
- if: github.event_name == 'pull_request'
- run: |
- tflint --format compact
-
- release:
- name: 'Create Release'
- needs: validate
- if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- runs-on: self-hosted
- permissions:
- contents: write
-
- steps:
- - name: Checkout
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
- token: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Setup Python
- uses: actions/setup-python@v4
- with:
- python-version: '3.9'
-
- - name: Install Commitizen
- run: |
- pip install commitizen
-
- - name: Configure Git
- run: |
- git config --local user.email "action@github.com"
- git config --local user.name "GitHub Action"
-
- - name: Bump Version and Generate Changelog
- id: cz
- run: |
- cz bump --yes
- echo "new_version=$(cz version --project)" >> $GITHUB_OUTPUT
- echo "changelog=$(cz changelog --dry-run)" >> $GITHUB_OUTPUT
-
- - name: Create Release
- uses: actions/create-release@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- tag_name: v${{ steps.cz.outputs.new_version }}
- release_name: Release v${{ steps.cz.outputs.new_version }}
- draft: false
- prerelease: false
- body: ${{ steps.cz.outputs.changelog }}
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ef52d70..8244dbb 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -37,7 +37,7 @@ repos:
# Terraform Hooks
- repo: https://github.com/antonbabenko/pre-commit-terraform
- rev: v1.97.3 # 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.6.1
+ rev: v0.7.0
hooks:
- id: conventional-gitmoji
diff --git a/README.md b/README.md
index e587c7f..824072e 100644
--- a/README.md
+++ b/README.md
@@ -32,27 +32,29 @@ Developer NOTE: We should automate this configuration.
|------|---------|
| [aws](#provider\_aws) | >= 5.14.0 |
| [helm](#provider\_helm) | >= 2.11.0 |
+| [terraform](#provider\_terraform) | n/a |
## Modules
| Name | Source | Version |
|------|--------|---------|
-| [images](#module\_images) | git@github.e.it.census.gov:terraform-modules/aws-ecr-copy-images.git/ | tf-upgrade |
-| [tempo-irsa-role](#module\_tempo-irsa-role) | git@github.e.it.census.gov:SCT-Engineering/tfmod-custom-iam-role-for-service-account-eks.git/ | base |
-| [tempo-s3](#module\_tempo-s3) | git@github.e.it.census.gov:terraform-modules/aws-s3.git//standard | tf-upgrade |
+| [images](#module\_images) | git::https://github.e.it.census.gov/terraform-modules/aws-ecr-copy-images.git/ | tf-upgrade |
+| [tempo-irsa-role](#module\_tempo-irsa-role) | git::https://github.e.it.census.gov/SCT-Engineering/tfmod-custom-iam-role-for-service-account-eks.git/ | base |
+| [tempo\_s3](#module\_tempo\_s3) | git::https://github.e.it.census.gov/terraform-modules/aws-s3.git//standard | tf-upgrade |
## Resources
| Name | Type |
|------|------|
| [helm_release.tempo](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
+| [terraform_data.bucket_name_validator](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
+| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_s3_bucket.s3_server_access_logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/s3_bucket) | data source |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
-| [account\_id](#input\_account\_id) | The account\_id holding these resources (for the s3 bucket.) | `string` | n/a | yes |
| [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 |
| [namespace](#input\_namespace) | The namespace into which tempo will be deployed | `string` | `"tempo"` | no |
| [oidc\_provider\_arn](#input\_oidc\_provider\_arn) | The ARN in the EKS cluster for the OpenID Connect identity provider. | `string` | n/a | yes |
diff --git a/aws_data.tf b/aws_data.tf
new file mode 100644
index 0000000..8fc4b38
--- /dev/null
+++ b/aws_data.tf
@@ -0,0 +1 @@
+data "aws_caller_identity" "current" {}
diff --git a/copy_images.tf b/copy_images.tf
index 7d14060..fbb90ef 100644
--- a/copy_images.tf
+++ b/copy_images.tf
@@ -15,7 +15,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/main.tf b/main.tf
index 745a29c..4515b8f 100644
--- a/main.tf
+++ b/main.tf
@@ -1,7 +1,6 @@
locals {
- oidc_arn = var.oidc_provider_arn
- tags = var.tags
- account_id = var.account_id
+ oidc_arn = var.oidc_provider_arn
+ tags = var.tags
tempo_internal_hostname = format("tempo.%v.svc.cluster.local", var.namespace)
tempo_internal_port_number = 3100
@@ -15,18 +14,18 @@ locals {
# IRSA Role for Tempo
################################################################################
module "tempo-irsa-role" {
- source = "git@github.e.it.census.gov:SCT-Engineering/tfmod-custom-iam-role-for-service-account-eks.git/?ref=base"
+ source = "git::https://github.e.it.census.gov/SCT-Engineering/tfmod-custom-iam-role-for-service-account-eks.git/?ref=base"
- role_name = "${var.cluster_name}-tempo"
+ role_name = format("%v%v-%v", local.prefixes["eks-role"], var.cluster_name, "tempo")
attach_s3_bucket_owner_policy = true
attach_encrypted_object_manager_policy = true
s3_bucket_arns = [
- module.tempo-s3.s3_bucket_arn,
- "${module.tempo-s3.s3_bucket_arn}/*",
+ module.tempo_s3.s3_bucket_arn,
+ "${module.tempo_s3.s3_bucket_arn}/*",
]
kms_key_arns = [
- module.tempo-s3.kms_key_arn
+ module.tempo_s3.kms_key_arn
]
oidc_providers = {
@@ -69,7 +68,7 @@ resource "helm_release" "tempo" {
}
set {
name = "tempo.storage.trace.s3.bucket"
- value = module.tempo-s3.s3_bucket_id
+ value = module.tempo_s3.s3_bucket_id
}
set {
name = "tempo.storage.trace.s3.endpoint"
diff --git a/prefixes.tf b/prefixes.tf
new file mode 100644
index 0000000..e9a6127
--- /dev/null
+++ b/prefixes.tf
@@ -0,0 +1,35 @@
+locals {
+ prefixes = {
+ "efs" = "v-efs-"
+ "s3" = "v-s3-"
+ "ebs" = "v-ebs-"
+ "kms" = "k-kms-"
+ "role" = "r-"
+ "policy" = "p-"
+ "group" = "g-"
+ "security-group" = "" # "sg-"
+ # VPC
+ "vpc" = ""
+ "dhcp-options" = ""
+ "vpc-peer" = "vpcp-"
+ "route-table" = "route-"
+ "subnet" = ""
+ "vpc-endpoint" = "vpce-"
+ "elastic-ip" = "eip-"
+ "nat-gateway" = "nat-"
+ "internet-gateway" = "igw-"
+ "network-acl" = "nacl-"
+ "customer-gateway" = "cgw-"
+ "vpn-gateway" = "vpcg-"
+ "vpn-connection" = "vpn_"
+ "log-group" = "lg-"
+ "log-stream" = "lgs-"
+ # EKS
+ "eks" = "eks-"
+ "eks-s3" = "v-s3-eks-"
+ "eks-user" = "s-eks-"
+ "eks-role" = "r-eks-"
+ "eks-policy" = "p-eks-"
+ "eks-security-group" = "eks-sg-" # "sg-eks-"
+ }
+}
diff --git a/s3.tf b/s3.tf
index 498fa70..4a70192 100644
--- a/s3.tf
+++ b/s3.tf
@@ -1,14 +1,32 @@
-## create bucket
+locals {
+ account_id = data.aws_caller_identity.current.account_id
+ bucket_name = format("%v%v-tempo-%v-%v", local.prefixes["eks-s3"], var.cluster_name, local.account_id, local.region_short)
+ region_short = join("", [for c in split("-", var.region) : substr(c, 0, 1)])
+}
data "aws_s3_bucket" "s3_server_access_logs" {
bucket = format("inf-logs-%v-%v", local.account_id, var.region)
}
-module "tempo-s3" {
- source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//standard?ref=tf-upgrade"
+# Validate S3 bucket name length
+resource "terraform_data" "bucket_name_validator" {
+ input = local.bucket_name
+
+ lifecycle {
+ precondition {
+ condition = length(local.bucket_name) >= 3 && length(local.bucket_name) <= 63
+ error_message = "S3 bucket name must be between 3 and 63 characters. Current name '${local.bucket_name}' is ${length(local.bucket_name)} characters."
+ }
+ }
+}
+
+module "tempo_s3" {
+ depends_on = [terraform_data.bucket_name_validator]
+ source = "git::https://github.e.it.census.gov/terraform-modules/aws-s3.git//standard?ref=tf-upgrade"
- bucket_name = format("%v-tempo", var.cluster_name)
+ bucket_name = local.bucket_name
access_log_bucket = data.aws_s3_bucket.s3_server_access_logs.id
+ force_destroy = true
- tags = local.tags
+ tags = var.tags
}
diff --git a/tempo_values.yaml b/tempo_values.yaml
index 24a6bbd..5b2e47b 100644
--- a/tempo_values.yaml
+++ b/tempo_values.yaml
@@ -1,4 +1,11 @@
tempo:
+ resources:
+ requests:
+ cpu: 100m
+ memory: 512Mi
+ limits:
+ cpu: 2000m
+ memory: 6Gi
storage:
trace:
backend: s3
@@ -18,62 +25,12 @@ serviceAccount:
persistence:
enabled: true
+ enableStatefulSetAutoDeletePVC: false
accessModes:
- ReadWriteOnce
size: 10Gi
-ingester:
- autoscaling:
- enabled: true
- resources:
- requests:
- cpu: "1m"
- memory: "1Mi"
- limits:
- cpu: "200m"
- memory: "256Mi"
-distributor:
- autoscaling:
- enabled: true
- resources:
- requests:
- cpu: "1m"
- memory: "1Mi"
- limits:
- cpu: "200m"
- memory: "256Mi"
-compactor:
- autoscaling:
- enabled: true
- resources:
- requests:
- cpu: "1m"
- memory: "1Mi"
- limits:
- cpu: "200m"
- memory: "256Mi"
-querier:
- autoscaling:
- enabled: true
- resources:
- requests:
- cpu: "1m"
- memory: "1Mi"
- limits:
- cpu: "200m"
- memory: "256Mi"
-gateway:
- autoscaling:
- enabled: true
- resources:
- requests:
- cpu: "1m"
- memory: "1Mi"
- limits:
- cpu: "200m"
- memory: "256Mi"
traces:
jaeger:
zipkin:
- # -- Enable Tempo to ingest Zipkin traces
enabled: true
diff --git a/variables.tf b/variables.tf
index e824a9d..ce7152f 100644
--- a/variables.tf
+++ b/variables.tf
@@ -9,11 +9,6 @@ variable "region" {
type = string
}
-variable "account_id" {
- description = "The account_id holding these resources (for the s3 bucket.)"
- type = string
-}
-
variable "cluster_name" {
description = "EKS cluster name name component used through out the EKS cluster describing its purpose (ex: dice-dev)"
type = string