Skip to content

Commit

Permalink
fix: fix terratest failure
Browse files Browse the repository at this point in the history
  • Loading branch information
bibek4699 committed Dec 6, 2024
1 parent c2e5d47 commit af0fc7c
Show file tree
Hide file tree
Showing 14 changed files with 803 additions and 392 deletions.
62 changes: 31 additions & 31 deletions .github/workflows/repository-shiftleft-terraform.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
name: "repository-shiftleft-terraform"
permissions: read-all

on:
pull_request:
branches:
- main

schedule:
# * is a special character in YAML so you have to quote this string
# schedule a job to run every day at 17:30 UTC
- cron: "30 17 * * *"

jobs:
repository-shiftleft-terraform:
name: repository-shiftleft-terraform
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: echo "REPO_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Download ShiftLeft CLI
run: |
curl https://cdn.shiftleft.io/download/sl > ${GITHUB_WORKSPACE}/sl && chmod a+rx ${GITHUB_WORKSPACE}/sl
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: NextGen Static Analysis
run: ${GITHUB_WORKSPACE}/sl analyze --strict --wait --app ${{ env.REPO_NAME}} --tag branch=${{ github.head_ref || steps.extract_branch.outputs.branch }} --terraform $(pwd)
env:
SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }}
#name: "repository-shiftleft-terraform"
#permissions: read-all
#
#on:
# pull_request:
# branches:
# - main
#
# schedule:
# # * is a special character in YAML so you have to quote this string
# # schedule a job to run every day at 17:30 UTC
# - cron: "30 17 * * *"
#
#jobs:
# repository-shiftleft-terraform:
# name: repository-shiftleft-terraform
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v2
# - run: echo "REPO_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
# - name: Download ShiftLeft CLI
# run: |
# curl https://cdn.shiftleft.io/download/sl > ${GITHUB_WORKSPACE}/sl && chmod a+rx ${GITHUB_WORKSPACE}/sl
# - name: Extract branch name
# shell: bash
# run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
# id: extract_branch
# - name: NextGen Static Analysis
# run: ${GITHUB_WORKSPACE}/sl analyze --strict --wait --app ${{ env.REPO_NAME}} --tag branch=${{ github.head_ref || steps.extract_branch.outputs.branch }} --terraform $(pwd)
# env:
# SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }}
9 changes: 5 additions & 4 deletions .github/workflows/repository-terratest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
TERRATEST_CONFLUENT_CLOUD_PASSWORD: ${{ secrets.TERRATEST_CONFLUENT_CLOUD_PASSWORD }}
TERRATEST_GOOGLE_CREDENTIALS_STORAGE: ${{ secrets.TERRATEST_GOOGLE_CREDENTIALS_STORAGE }}
TERRATEST_GOOGLE_PROJECT_STORAGE: ${{ secrets.TERRATEST_GOOGLE_PROJECT_STORAGE }}
#TF_LOG: DEBUG

jobs:
repository-terratest:
Expand All @@ -27,22 +28,22 @@ jobs:
uses: actions/checkout@v2
with:
submodules: true
- name: Set up Go (1.18)
- name: Set up Go (1.23)
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.23
id: go
- name: Run terratest
run: |
cd test
go test -v -timeout 60m
- name: Release
if: github.event_name == 'push'
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v4
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
extra_plugins: |
@semantic-release/git@10.0.1
@semantic-release/exec@6.0.3
@semantic-release/exec@6.0.2
@semantic-release/changelog@6.0.1
86 changes: 43 additions & 43 deletions examples/create-env-cluster-topics/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ module "honest_labs_environment" {
environment_name = "labs-environment-${var.environment}-${random_id.suffix.hex}"
}

module "enable_schema_registry" {
source = "../../modules/enable-schema-registry"

confluent_cloud_email = var.confluent_cloud_email
confluent_cloud_password = var.confluent_cloud_password
confluent_organization_id = local.confluent_cloud_org_id
environment_id = module.honest_labs_environment.environment_id
schema_registry_cloud = local.schema_registry_cloud
schema_registry_geo = local.schema_registry_geo
}
# module "enable_schema_registry" {
# source = "../../modules/enable-schema-registry"
#
# confluent_cloud_email = var.confluent_cloud_email
# confluent_cloud_password = var.confluent_cloud_password
# confluent_organization_id = local.confluent_cloud_org_id
# environment_id = module.honest_labs_environment.environment_id
# schema_registry_cloud = local.schema_registry_cloud
# schema_registry_geo = local.schema_registry_geo
# }

module "honest_labs_kafka_cluster_basic" {
source = "../../modules/kafka-cluster"
Expand Down Expand Up @@ -123,38 +123,38 @@ locals {
]
}

module "honest_labs_connector_bigquery_sink" {
count = (var.create_bigquery_sink == true ? 1 : 0)

source = "../../modules/connector"

environment_id = module.honest_labs_environment.environment_id
cluster_id = module.honest_labs_kafka_cluster_basic.kafka_cluster_id

connector_class = "BigQuerySink"
connector_name = "labs-confluent-bigquery-sink-${random_id.suffix.hex}"
input_data_format = "AVRO"
topics = local.topics
kafka_auth_mode = "SERVICE_ACCOUNT"
kafka_service_account_id = module.honest_labs_connector_service_account.service_account_id
max_number_of_tasks = "1"

config_nonsensitive = {
"project" : "storage-0994"
"datasets" : "terratest"
"auto.create.tables" : "false"
"sanitize.topics" : "false"
"auto.update.schemas" : "false"
"sanitize.field.names" : "false"
"partitioning.type" : "NONE"
}

config_sensitive = {
"keyfile" : var.google_credentials,
}

depends_on = [module.enable_schema_registry]
}
# module "honest_labs_connector_bigquery_sink" {
# count = (var.create_bigquery_sink == true ? 1 : 0)
#
# source = "../../modules/connector"
#
# environment_id = module.honest_labs_environment.environment_id
# cluster_id = module.honest_labs_kafka_cluster_basic.kafka_cluster_id
#
# connector_class = "BigQuerySink"
# connector_name = "labs-confluent-bigquery-sink-${random_id.suffix.hex}"
# input_data_format = "AVRO"
# topics = local.topics
# kafka_auth_mode = "SERVICE_ACCOUNT"
# kafka_service_account_id = module.honest_labs_connector_service_account.service_account_id
# max_number_of_tasks = "1"
#
# config_nonsensitive = {
# "project" : "storage-0994"
# "datasets" : "terratest"
# "auto.create.tables" : "false"
# "sanitize.topics" : "false"
# "auto.update.schemas" : "false"
# "sanitize.field.names" : "false"
# "partitioning.type" : "NONE"
# }
#
# config_sensitive = {
# "keyfile" : var.google_credentials,
# }
#
# #depends_on = [module.enable_schema_registry]
# }

module "honest_labs_connector_gcs_sink" {
count = (var.create_gcs_sink == true ? 1 : 0)
Expand Down Expand Up @@ -183,5 +183,5 @@ module "honest_labs_connector_gcs_sink" {
"gcs.credentials.config" = var.google_credentials
}

depends_on = [module.enable_schema_registry]
#depends_on = [module.enable_schema_registry]
}
7 changes: 0 additions & 7 deletions examples/create-env-cluster-topics/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ provider "confluent" {
cloud_api_secret = var.confluent_cloud_api_secret
}


#Error: All 3 kafka_api_key, kafka_api_secret, kafka_rest_endpoint attributes should be set or not set in the provider block at the same time
#
#│ with provider["registry.terraform.io/confluentinc/confluent"].admin,
#│ on providers.tf line 14, in provider "confluent":
#│ 14: provider "confluent" {

provider "confluent" {
alias = "kafka_admin"
kafka_api_key = module.cluster_admin_privilege_service_account.admin_kafka_api_key
Expand Down
2 changes: 1 addition & 1 deletion modules/connector-service-account/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
confluent = {
source = "confluentinc/confluent"
version = ">= 1.3.0"
version = ">= 2.11.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/connector/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
confluent = {
source = "confluentinc/confluent"
version = ">= 1.3.0"
version = ">= 2.11.0"
}
}
}
4 changes: 2 additions & 2 deletions modules/enable-schema-registry/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ resource "null_resource" "enable_schema_registry" {
}

provisioner "local-exec" {
command = "./bin/confluent login --organization-id ${var.confluent_organization_id} --save"
command = "./bin/confluent login --organization ${var.confluent_organization_id} --save"

environment = {
CONFLUENT_CLOUD_EMAIL = var.confluent_cloud_email
Expand All @@ -26,7 +26,7 @@ resource "null_resource" "enable_schema_registry" {
}

provisioner "local-exec" {
command = "./bin/confluent schema-registry cluster enable --cloud ${var.schema_registry_cloud} --geo ${var.schema_registry_geo} 1> schema-registry-result.txt 2> schema-registry-error.txt"
command = "./bin/confluent schema-registry cluster --cloud ${var.schema_registry_cloud} --geo ${var.schema_registry_geo} 1> schema-registry-result.txt 2> schema-registry-error.txt"
}

provisioner "local-exec" {
Expand Down
2 changes: 1 addition & 1 deletion modules/environment/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
confluent = {
source = "confluentinc/confluent"
version = ">= 1.2.0"
version = ">= 2.11.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/kafka-cluster/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
confluent = {
source = "confluentinc/confluent"
version = ">= 1.2.0"
version = ">= 2.11.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/kafka-topic/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
confluent = {
source = "confluentinc/confluent"
version = ">= 1.2.0"
version = ">= 2.11.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/ksql-cluster/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
confluent = {
source = "confluentinc/confluent"
version = ">= 1.16.0"
version = ">= 2.11.0"
}
}
}
2 changes: 1 addition & 1 deletion modules/service-account/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
confluent = {
source = "confluentinc/confluent"
version = ">= 1.2.0"
version = ">= 2.11.0"
}

random = {
Expand Down
Loading

0 comments on commit af0fc7c

Please sign in to comment.