Skip to content

Instantly share code, notes, and snippets.

View sergsoares's full-sized avatar

Sergio Soares sergsoares

View GitHub Profile
@sergsoares
sergsoares / Justfile
Created May 29, 2023 17:59
Justfile to apply argocd inside a cluster
init:
colima start argocd-selfmanaged --kubernetes
kubectl-get-nodes:
kubectl get nodes
kubectl get pods -A
kubectl-apply-argocd:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
@sergsoares
sergsoares / Makefile
Created April 11, 2023 00:12
Makefile for select specific resource inside a main.tf
target:
SELECTED=`cat main.tf | grep resource | tr -d '"' | awk '{ print $$2 "." $$3 }' | fzf` ; \
terraform apply -target=$$SELECTED
@sergsoares
sergsoares / main.go
Created February 1, 2023 05:27
Simple main.go to process a Key/Value bookmarks as .command for be used in MacOS.
package main
import (
"encoding/json"
"os"
"path/filepath"
)
const (
output = "shortcuts"
{
"aws-cli-reference": "https://docs.aws.amazon.com/cli/latest/reference/index.html",
"aws-cli-acm": "https://docs.aws.amazon.com/cli/latest/reference/acm/index.html",
"aws-cli-acm-pca": "https://docs.aws.amazon.com/cli/latest/reference/acm-pca/index.html",
"aws-cli-alexaforbusiness": "https://docs.aws.amazon.com/cli/latest/reference/alexaforbusiness/index.html",
"aws-cli-amplify": "https://docs.aws.amazon.com/cli/latest/reference/amplify/index.html",
"aws-cli-apigateway": "https://docs.aws.amazon.com/cli/latest/reference/apigateway/index.html",
"aws-cli-apigatewaymanagementapi": "https://docs.aws.amazon.com/cli/latest/reference/apigatewaymanagementapi/index.html",
"aws-cli-apigatewayv2": "https://docs.aws.amazon.com/cli/latest/reference/apigatewayv2/index.html",
"aws-cli-application-autoscaling": "https://docs.aws.amazon.com/cli/latest/reference/application-autoscaling/index.html",
@sergsoares
sergsoares / main.go
Created December 9, 2022 23:39
Golang to ping and encode in JSON response
package main
import (
"fmt"
"os/exec"
"strings"
"strconv"
"net"
)
@sergsoares
sergsoares / main.tf
Created July 14, 2022 19:55
Validation of complex variables in terraform
# terraform.vars
rules = [
{
api_groups = [""]
resources = ["pods","services","deployments","jobs"]
verbs = ["*"]
},
{
api_groups = [""]
resources = ["namespaces"]
@sergsoares
sergsoares / manifest.yml
Created July 14, 2022 18:23
Create a Cluster Role but only use RoleBinding to give access for only 2 specific namespaces (otherwise all namespaces like ClusterRoleBinding)
apiVersion: v1
kind: ServiceAccount
metadata:
name: myapp
namespace: mynamespace
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: mynamespace
@sergsoares
sergsoares / main.tf
Created July 13, 2022 15:35
Generate dynamically policies based on input and attach for already created roles and users
locals {
policies_arns = {
for item in aws_iam_policy.policy :
item.name => item.arn
}
users_attachment = distinct(
flatten([
for item in var.policies : [
for user in item.users_to_attach : {
@sergsoares
sergsoares / main.tf
Created July 13, 2022 15:31
Demonstração de ideia para criação de policies dinâmicas com attach em múltiplos users e roles.
# terraform.tfvars
policies = [
{
policy_name = "policy-alpha",
roles_to_attach = []
users_to_attach = ["user1", "user2"]
content = {}
},
{
@sergsoares
sergsoares / main.tf
Created July 11, 2022 19:25
Snippet for use variables as a map
# variables.tf
variable "myapp_conf" {
type = map
}
# terraform.tfvars
myapp_conf = {
REPLICAS = 0
LIMIT_CPU = "50m"
LIMIT_MEMORY = "96Mi"