Skip to content

Instantly share code, notes, and snippets.

View antonbabenko's full-sized avatar
🇺🇦

Anton Babenko antonbabenko

🇺🇦
View GitHub Profile
@antonbabenko
antonbabenko / cloudflare_worker.js
Created January 2, 2023 18:50
CloudFlare worker which does redirects for previous Revue URLs into new
const redirectMap = new Map([
['/issues/weekly-tf-issue-101-best-practices-for-using-terraform-by-google-the-many-ways-to-access-rds-artificial-intelligence-infrastructure-as-code-generator-1473757', 'https://www.weekly.tf/p/weeklytf-issue-101-best-practices-using-terraform-google-many-ways-access-rds-artificial-intelligenc'],
['/issues/weekly-tf-issue-100-using-least-privilege-iam-policies-aws-sam-cli-and-terraform-managing-terraform-state-with-terragrunt-ci-cd-pipeline-in-azure-devops-achieving-balance-with-policy-enforcement-aws-re-invent-1463043', 'https://www.weekly.tf/p/weeklytf-issue-100-using-least-privilege-iam-policies-aws-sam-cli-terraform-managing-terraform-state'],
['/issues/weekly-tf-issue-99-aws-landing-zone-codify-your-infrastructure-with-terraformer-and-terraform-best-practices-gitlab-managed-terraform-state-terrascan-aws-nat-instances-ci-cd-pipelines-for-infrastructure-as-code-with-kief-morris-1448446', 'https://www.weekly.tf/p/weeklytf-issue-99-aws-landing-zone-codify-infrastructure-terrafo
@antonbabenko
antonbabenko / gist:b711b4eed4b24911027e3a7692e4549a
Created January 27, 2022 10:23
Questions for HUG13 with Mitchell and Armon
1. Big success = incredible growth = big investment -> higher risk of losing the pure spirit of open-source + open community. What are the comming actions to reduce this risk and not reproduce the same failing pattern of Docker Inc? / via H.
# - repo: local # @todo: move to pre-commit-terraform, add support for multiple module dirs, and run before terraform_docs
# hooks:
# - id: terraform_wrapper
# name: "Terraform module wrapper - root"
# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --overwrite
# language: system
# pass_filenames: false
# - id: terraform_wrapper
# name: "Terraform module wrapper - object"
# entry: /Users/Bob/Sites/terraform-aws-modules/scripts/generate-terraform-wrappers.sh --module-dir modules/object --overwrite
@antonbabenko
antonbabenko / should_you_sponsor.sh
Last active September 17, 2021 08:29
Let me help you to decide whether you are using some of my work. Please consider supporting me!
#!/bin/bash
# If you are using some terraform-aws-modules, pre-commit-terraform, or other projects I am heavily involved into
# please consider support me on GitHub Sponsors or any other platform!
#
# Here you can see most of my projects - https://github.com/antonbabenko/terraform-aws-devops
find . -type f \( -name "*.tf" -o -name "*.yaml" \) -and \( -not -path "*/.terraform/*" \) -exec \
grep -E 'terraform-aws-modules|antonbabenko/pre-commit-terraform' -q {} + && \
echo "Found some references... You are using some open-source projects by Anton, please support @antonbabenko" && \
@antonbabenko
antonbabenko / valid_but_ugly.tf
Created September 10, 2021 18:02
Very valid but very ugly HCL2 file which break the parsers and IAC Security tools (terrascan, checkov, etc)
resource "aws_db_instance" "valid_but_ugly" {
allocated_storage = 20
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t2.micro"
# flip value to true/false will return multiple violations.
iam_database_authentication_enabled = local.test2.some[0] == "dd" #tobool("true")
#(true == true)
# Copy image from GHCR into private ECR
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 835367859851.dkr.ecr.eu-west-1.amazonaws.com
docker pull ghcr.io/cloudquery/cloudquery:0.13.4
docker tag ghcr.io/cloudquery/cloudquery:0.13.4 835367859851.dkr.ecr.eu-west-1.amazonaws.com/cloudquery:0.13.4
docker push 835367859851.dkr.ecr.eu-west-1.amazonaws.com/cloudquery:0.13.4
# Run Postgres locally
#!/usr/bin/env bash
set -e
readonly CONTENT_MAIN_TF='module "wrapper" {}'
readonly CONTENT_VARIABLES_TF='variable "items" {
description = "Maps of items to create a wrapper from. Values are passed through to the module."
type = any
default = {}
}'
@antonbabenko
antonbabenko / setup.sh
Created September 17, 2020 11:46
Show GitHub sponsors as markdown using apex-up
git clone git@github.com:tj/sponsors-api.git
cd sponsors-api
# Install up ( https://github.com/apex/up )
curl -sf https://up.apex.sh/install | sh
# Build the binary
GOOS=linux GOARCH=amd64 go build -o server cmd/sponsors-api/main.go
# Create config for up
@antonbabenko
antonbabenko / README.md
Created September 1, 2020 13:16
aws_ecs_service - The new ARN and resource ID format must be enabled to propagate tags.

Error:

aws_ecs_service.atlantis: Creating...

Error: InvalidParameterException: The new ARN and resource ID format must be enabled to add tags to the service. Opt in to the new format and try again. "atlantis"

Solution - enable new features in AWS account:

@antonbabenko
antonbabenko / terraform-cost-estimation.rego
Created May 19, 2020 11:58
Terraform Cost Estimation + Open Policy Agent
# Terraform Cost Estimation + Open Policy Agent
#
# This code snippet supports terraform state for now.
#
# Get the whole response:
# opa eval --data terraform-cost-estimation.rego --input terraform.tfstate --format pretty data.terraform_cost_estimation
#
# Get boolean response. Return false if state (per hour) is too expensive:
# opa eval --data terraform-cost-estimation.rego --input terraform.tfstate --format pretty data.terraform_cost_estimation.response.allowed