Skip to content

Instantly share code, notes, and snippets.

View soerenmartius's full-sized avatar
🎯
focused

Sören Martius soerenmartius

🎯
focused
View GitHub Profile
@soerenmartius
soerenmartius / kubernetes.hcl
Last active April 9, 2024 20:44
Kubernetes Provider Generation
### Example on how to generate a more specific provider such as Kubernetes
# The deployment trigger is used to deferr the data source at plan time if it's not available quick is a commonly known workaround in Terraform
# In TF 1.9 this will most likely be fixes by finally allowing plan time with values that are not yet available natively https://github.com/hashicorp/terraform/releases/tag/v1.9.0-alpha20240404
globals "terraform" "providers" "kubernetes" {
source = "hashicorp/kubernetes"
version = "~> 2.16"
postpone_init_to_apply = true
enabled = true
@soerenmartius
soerenmartius / multithreading.go
Created May 5, 2020 09:40
Multithreading Example with WaitGroups in Golang
package main
import (
"fmt"
"sync"
"time"
)
func worker(wg *sync.WaitGroup, id int) {
defer wg.Done()
@soerenmartius
soerenmartius / module.ts
Last active October 12, 2023 09:30
vuex 4 cognito module
import {
ActionContext,
ActionTree,
GetterTree,
MutationTree,
Module,
Store as VuexStore,
CommitOptions,
DispatchOptions,
} from 'vuex'
@soerenmartius
soerenmartius / _src_modules_auth_store_index.ts
Last active June 29, 2023 02:28
Vue 3 with Typescriptt and Vuex 4 Typed Modules Examples ( with real types )
import {
ActionContext,
ActionTree,
GetterTree,
MutationTree,
Module,
Store as VuexStore,
CommitOptions,
DispatchOptions,
} from 'vuex'
@soerenmartius
soerenmartius / locals.hcl.tm
Created July 14, 2022 12:31
Generate Terraform locals with Terramate
# File: /projects/locals.tm.hcl
# Export env and project_id to be referenced as local.project_id and local.env
# in main.tf and other Terraform files in each stack.
generate_hcl "_terramate_generated_locals" {
content {
locals {
env = global.env
project_id = global.project_id
}
@soerenmartius
soerenmartius / generated_files.sg
Created July 14, 2022 12:12
Project Structure with Terramate generated files
projects/
├── provider.tm.hcl
├── backend.tm.hcl
├── my-project-prod/
│   ├── project.tm.hcl
│   ├── stack-1/
│   │ ├── main.tf
│   │ ├── stack.tm.hcl
│   │ ├── _terramate_generated_provider.tf
│   │ └── _terramate_generated_backend.tf
@soerenmartius
soerenmartius / backend.tm.hcl
Created July 14, 2022 12:08
Generate Terraform backend.tf files with Terramate
# File: /projects/backend.tm.hcl
# The file is prefixed with _terramate_generated here to make the generated nature
# of it more visible
generate_hcl "_terramate_generated_backend.tf" {
content {
terraform {
backend "gcs" {
bucket = "tf-state-${global.project_id}"
prefix = terramate.stack.path.absolute
@soerenmartius
soerenmartius / project.tm.hcl
Created July 14, 2022 12:07
Definition of globals with Terramate
# File: /projects/my-project-prod/project.tm.hcl
globals {
env = "prod"
project_id = "my-project-${global.env}"
}
@soerenmartius
soerenmartius / project.tm.hcl
Created July 14, 2022 12:06
Definition of globals with Terramate
# File: /projects/my-project-staging/project.tm.hcl
globals {
env = "staging"
project_id = "my-project-${global.env}"
}
@soerenmartius
soerenmartius / providers.hcl.tm
Last active July 14, 2022 12:00
Terramate provider definition in providers.hcl.tm
# File: /projects/providers.tm.hcl
globals {
# The default project_id to configure the provider with.
# The provider_id can be set at any level in the hierarchy.
# If no project_id the provider fallbacks are used.
terraform_google_provider_project = tm_try(global.project_id, null)
# The default region to configure
terraform_google_provider_region = "europe-north1"