Skip to content

Commit

Permalink
feat: Add ability to track usage telemetry of EKS Blueprint solutions (
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantbiggs authored Oct 24, 2024
1 parent aa60bf2 commit d2e33bb
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 51 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:
permissions: read-all

env:
TERRAFORM_DOCS_VERSION: v0.16.0
TFLINT_VERSION: v0.50.3
TERRAFORM_DOCS_VERSION: v0.19.0
TFLINT_VERSION: v0.53.0

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
Expand All @@ -31,7 +31,7 @@ jobs:

- name: Get root directories
id: dirs
uses: clowdhaus/terraform-composite-actions/directories@v1.9.0
uses: clowdhaus/terraform-composite-actions/directories@v1.11.1

preCommitMinVersions:
name: Min TF pre-commit
Expand All @@ -58,22 +58,22 @@ jobs:
- '${{ matrix.directory }}/*.tf'
- name: Terraform min/max versions
uses: clowdhaus/[email protected].0
uses: clowdhaus/[email protected].1
if: steps.changes.outputs.src== 'true'
id: minMax
with:
directory: ${{ matrix.directory }}

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1
# Run only validate pre-commit check on min version supported
if: ${{ matrix.directory != '.' && steps.changes.outputs.src== 'true' }}
with:
terraform-version: ${{ steps.minMax.outputs.minVersion }}
args: 'terraform_validate --color=always --show-diff-on-failure --files ${{ matrix.directory }}/*'

- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1
# Run only validate pre-commit check on min version supported
if: ${{ matrix.directory == '.' && steps.changes.outputs.src== 'true' }}
with:
Expand All @@ -100,11 +100,11 @@ jobs:
- name: Terraform min/max versions
id: minMax
uses: clowdhaus/[email protected].0
uses: clowdhaus/[email protected].1
if: steps.changes.outputs.src== 'true'

- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.9.0
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.11.1
if: steps.changes.outputs.src== 'true'
with:
terraform-version: ${{ steps.minMax.outputs.maxVersion }}
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
args: ['--markdown-linebreak-ext=md']
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ module "eks" {
|------|------|
| [aws_autoscaling_group_tag.aws_node_termination_handler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_group_tag) | resource |
| [aws_autoscaling_lifecycle_hook.aws_node_termination_handler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/autoscaling_lifecycle_hook) | resource |
| [aws_cloudformation_stack.usage_telemetry](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack) | resource |
| [aws_cloudwatch_event_rule.aws_node_termination_handler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource |
| [aws_cloudwatch_event_rule.karpenter](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_rule) | resource |
| [aws_cloudwatch_event_target.aws_node_termination_handler](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_event_target) | resource |
Expand Down Expand Up @@ -182,7 +183,7 @@ module "eks" {
| <a name="input_bottlerocket_shadow"></a> [bottlerocket\_shadow](#input\_bottlerocket\_shadow) | Bottlerocket Update Operator CRDs configuration values | `any` | `{}` | no |
| <a name="input_bottlerocket_update_operator"></a> [bottlerocket\_update\_operator](#input\_bottlerocket\_update\_operator) | Bottlerocket Update Operator add-on configuration values | `any` | `{}` | no |
| <a name="input_cert_manager"></a> [cert\_manager](#input\_cert\_manager) | cert-manager add-on configuration values | `any` | `{}` | no |
| <a name="input_cert_manager_route53_hosted_zone_arns"></a> [cert\_manager\_route53\_hosted\_zone\_arns](#input\_cert\_manager\_route53\_hosted\_zone\_arns) | List of Route53 Hosted Zone ARNs that are used by cert-manager to create DNS records | `list(string)` | <pre>[<br> "arn:aws:route53:::hostedzone/*"<br>]</pre> | no |
| <a name="input_cert_manager_route53_hosted_zone_arns"></a> [cert\_manager\_route53\_hosted\_zone\_arns](#input\_cert\_manager\_route53\_hosted\_zone\_arns) | List of Route53 Hosted Zone ARNs that are used by cert-manager to create DNS records | `list(string)` | <pre>[<br/> "arn:aws:route53:::hostedzone/*"<br/>]</pre> | no |
| <a name="input_cluster_autoscaler"></a> [cluster\_autoscaler](#input\_cluster\_autoscaler) | Cluster Autoscaler add-on configuration values | `any` | `{}` | no |
| <a name="input_cluster_endpoint"></a> [cluster\_endpoint](#input\_cluster\_endpoint) | Endpoint for your Kubernetes API server | `string` | n/a | yes |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the EKS cluster | `string` | n/a | yes |
Expand Down Expand Up @@ -225,9 +226,9 @@ module "eks" {
| <a name="input_external_dns"></a> [external\_dns](#input\_external\_dns) | external-dns add-on configuration values | `any` | `{}` | no |
| <a name="input_external_dns_route53_zone_arns"></a> [external\_dns\_route53\_zone\_arns](#input\_external\_dns\_route53\_zone\_arns) | List of Route53 zones ARNs which external-dns will have access to create/manage records (if using Route53) | `list(string)` | `[]` | no |
| <a name="input_external_secrets"></a> [external\_secrets](#input\_external\_secrets) | External Secrets add-on configuration values | `any` | `{}` | no |
| <a name="input_external_secrets_kms_key_arns"></a> [external\_secrets\_kms\_key\_arns](#input\_external\_secrets\_kms\_key\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> "arn:aws:kms:*:*:key/*"<br>]</pre> | no |
| <a name="input_external_secrets_secrets_manager_arns"></a> [external\_secrets\_secrets\_manager\_arns](#input\_external\_secrets\_secrets\_manager\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> "arn:aws:secretsmanager:*:*:secret:*"<br>]</pre> | no |
| <a name="input_external_secrets_ssm_parameter_arns"></a> [external\_secrets\_ssm\_parameter\_arns](#input\_external\_secrets\_ssm\_parameter\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br> "arn:aws:ssm:*:*:parameter/*"<br>]</pre> | no |
| <a name="input_external_secrets_kms_key_arns"></a> [external\_secrets\_kms\_key\_arns](#input\_external\_secrets\_kms\_key\_arns) | List of KMS Key ARNs that are used by Secrets Manager that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> "arn:aws:kms:*:*:key/*"<br/>]</pre> | no |
| <a name="input_external_secrets_secrets_manager_arns"></a> [external\_secrets\_secrets\_manager\_arns](#input\_external\_secrets\_secrets\_manager\_arns) | List of Secrets Manager ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> "arn:aws:secretsmanager:*:*:secret:*"<br/>]</pre> | no |
| <a name="input_external_secrets_ssm_parameter_arns"></a> [external\_secrets\_ssm\_parameter\_arns](#input\_external\_secrets\_ssm\_parameter\_arns) | List of Systems Manager Parameter ARNs that contain secrets to mount using External Secrets | `list(string)` | <pre>[<br/> "arn:aws:ssm:*:*:parameter/*"<br/>]</pre> | no |
| <a name="input_fargate_fluentbit"></a> [fargate\_fluentbit](#input\_fargate\_fluentbit) | Fargate fluentbit add-on config | `any` | `{}` | no |
| <a name="input_fargate_fluentbit_cw_log_group"></a> [fargate\_fluentbit\_cw\_log\_group](#input\_fargate\_fluentbit\_cw\_log\_group) | AWS Fargate Fluentbit CloudWatch Log Group configurations | `any` | `{}` | no |
| <a name="input_gatekeeper"></a> [gatekeeper](#input\_gatekeeper) | Gatekeeper add-on configuration | `any` | `{}` | no |
Expand All @@ -240,6 +241,7 @@ module "eks" {
| <a name="input_karpenter_sqs"></a> [karpenter\_sqs](#input\_karpenter\_sqs) | Karpenter SQS queue for native node termination handling configuration values | `any` | `{}` | no |
| <a name="input_kube_prometheus_stack"></a> [kube\_prometheus\_stack](#input\_kube\_prometheus\_stack) | Kube Prometheus Stack add-on configurations | `any` | `{}` | no |
| <a name="input_metrics_server"></a> [metrics\_server](#input\_metrics\_server) | Metrics Server add-on configurations | `any` | `{}` | no |
| <a name="input_observability_tag"></a> [observability\_tag](#input\_observability\_tag) | Tag to identify EKS Blueprints usage within observability tools | `string` | `"qs-1ubotj5kl"` | no |
| <a name="input_oidc_provider_arn"></a> [oidc\_provider\_arn](#input\_oidc\_provider\_arn) | The ARN of the cluster OIDC Provider | `string` | n/a | yes |
| <a name="input_secrets_store_csi_driver"></a> [secrets\_store\_csi\_driver](#input\_secrets\_store\_csi\_driver) | CSI Secrets Store Provider add-on configurations | `any` | `{}` | no |
| <a name="input_secrets_store_csi_driver_provider_aws"></a> [secrets\_store\_csi\_driver\_provider\_aws](#input\_secrets\_store\_csi\_driver\_provider\_aws) | CSI Secrets Store Provider add-on configurations | `any` | `{}` | no |
Expand Down
23 changes: 23 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3814,3 +3814,26 @@ module "bottlerocket_update_operator" {
# https://github.com/bottlerocket-os/bottlerocket-update-operator/tree/develop/deploy/charts/bottlerocket-update-operator
depends_on = [module.bottlerocket_shadow]
}

################################################################################
# Usage Telemetry
################################################################################

resource "aws_cloudformation_stack" "usage_telemetry" {
count = var.observability_tag != null ? 1 : 0

name = var.cluster_name

on_failure = "DO_NOTHING"
template_body = jsonencode({
AWSTemplateFormatVersion = "2010-09-09",
Description = "Usage telemetry for EKS Blueprints. (${var.observability_tag})",
Resources = {
EmptyResource = {
Type = "AWS::CloudFormation::WaitConditionHandle"
}
}
})

tags = var.tags
}
13 changes: 6 additions & 7 deletions tests/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,24 @@ terraform destroy

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.38 |
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.8 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.2 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.70 |
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.9 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.20 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.38 |
| <a name="provider_aws.virginia"></a> [aws.virginia](#provider\_aws.virginia) | >= 5.38 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.70 |
| <a name="provider_aws.virginia"></a> [aws.virginia](#provider\_aws.virginia) | >= 5.70 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_adot_irsa"></a> [adot\_irsa](#module\_adot\_irsa) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | ~> 5.20 |
| <a name="module_ebs_csi_driver_irsa"></a> [ebs\_csi\_driver\_irsa](#module\_ebs\_csi\_driver\_irsa) | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | ~> 5.20 |
| <a name="module_eks"></a> [eks](#module\_eks) | terraform-aws-modules/eks/aws | ~> 20.4 |
| <a name="module_eks"></a> [eks](#module\_eks) | terraform-aws-modules/eks/aws | ~> 20.26 |
| <a name="module_eks_blueprints_addons"></a> [eks\_blueprints\_addons](#module\_eks\_blueprints\_addons) | ../../ | n/a |
| <a name="module_velero_backup_s3_bucket"></a> [velero\_backup\_s3\_bucket](#module\_velero\_backup\_s3\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 3.0 |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
Expand Down
37 changes: 9 additions & 28 deletions tests/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ provider "helm" {
}
}

data "aws_availability_zones" "available" {}
data "aws_availability_zones" "available" {
# Do not include local zones
filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}

data "aws_ecrpublic_authorization_token" "token" {
provider = aws.virginia
Expand Down Expand Up @@ -82,10 +88,6 @@ module "eks_blueprints_addons" {
most_recent = true
}
kube-proxy = {}
adot = {
most_recent = true
service_account_role_arn = module.adot_irsa.iam_role_arn
}
}

enable_aws_efs_csi_driver = true
Expand Down Expand Up @@ -237,10 +239,10 @@ module "eks_blueprints_addons" {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.4"
version = "~> 20.26"

cluster_name = local.name
cluster_version = "1.29"
cluster_version = "1.31"
cluster_endpoint_public_access = true

vpc_id = module.vpc.vpc_id
Expand Down Expand Up @@ -359,24 +361,3 @@ module "ebs_csi_driver_irsa" {

tags = local.tags
}

module "adot_irsa" {
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
version = "~> 5.20"

role_name_prefix = "${local.name}-adot-"

role_policy_arns = {
prometheus = "arn:aws:iam::aws:policy/AmazonPrometheusRemoteWriteAccess"
xray = "arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess"
cloudwatch = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
}
oidc_providers = {
main = {
provider_arn = module.eks.oidc_provider_arn
namespace_service_accounts = ["opentelemetry-operator-system:opentelemetry-operator"]
}
}

tags = local.tags
}
6 changes: 3 additions & 3 deletions tests/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
terraform {
required_version = ">= 1.3"
required_version = ">= 1.3.2"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.38"
version = ">= 5.70"
}
helm = {
source = "hashicorp/helm"
version = ">= 2.8"
version = ">= 2.9"
}
kubernetes = {
source = "hashicorp/kubernetes"
Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,13 @@ variable "create_kubernetes_resources" {
type = bool
default = true
}

################################################################################
# Usage Telemetry
################################################################################

variable "observability_tag" {
description = "Tag to identify EKS Blueprints usage within observability tools"
type = string
default = "qs-1ubotj5kl"
}

0 comments on commit d2e33bb

Please sign in to comment.