Skip to content

Instantly share code, notes, and snippets.

View karl-cardenas-coding's full-sized avatar

Karl Cardenas karl-cardenas-coding

View GitHub Profile
#############################
# DynamoDB
#############################
resource "aws_dynamodb_table" "main-table" {
name = var.table-name
billing_mode = "PROVISIONED"
read_capacity = 2
write_capacity = 2
hash_key = "orderId"
range_key = "customerId"
@karl-cardenas-coding
karl-cardenas-coding / provider.tf
Created August 17, 2020 23:32
provider example
provider "aws" {
access_key = "mock_access_key"
region = "us-east-1"
s3_force_path_style = true
secret_key = "mock_secret_key"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
endpoints {
@karl-cardenas-coding
karl-cardenas-coding / new-car.md
Created July 19, 2020 03:40
Markdown example for adding content to a Hugo project
title date draft
New Car
2020-07-18 15:20:47 -0700
false

A car for everyone

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum

{
"basics": {
"name": "Karl Cardenas",
"label": "IT Architecture Manager/Leader",
"picture": "https://crazykarlcodes.dev/about/img/profile.jpg",
"email": "[email protected]",
"website": "https://crazykarlcodes.dev",
"summary": "I am a passionate technology leader with a strong emphasis on DevSecOps. I enjoy teaching others and enabling them to create business solutions. I believe in empowering others and leading by example. My strong technical background and unique leadership experience allows me to develop strong technical leaders and tackle challenging organizational problems others avoid. Attitude equal altitude.",
"location": {
"postalCode": "AZ 85257",
@karl-cardenas-coding
karl-cardenas-coding / for-loop-s3.tf
Last active March 8, 2020 00:05
For loop in Terraform
locals {
s3_ips = try(distinct([ #distinct() is not needed but added to showcase the wrap of functions before the loop
for items in jsondecode(data.http.primary-server.body).prefixes:
items.ip_prefix if items.service == "S3"
]), "NO LIST PROVIDED IN LOCALS S3_IPS VARIABLE")
}
@karl-cardenas-coding
karl-cardenas-coding / try.tf
Last active May 29, 2020 15:28
Example of using try in Terraform
# Try example
data "http" "primary-server" {
url = "https://ip-ranges.amazonaws.com/ip-ranges.json"
# Optional request headers
request_headers = {
Accept = "application/json"
}
}
### Test scenario for "can"
variable "word-length" {
validation {
# The condition here identifies if the integer if greater than 1
condition = var.word-length > 1
error_message = "The variable is not greater than 5. Word length has to be at a minimum > 1."
}
}
variable "os" {
default = "linux"
validation {
# The condition here identifies if the variable contains the string "linxu" OR "windows".
condition = can(regex("linux|windows", var.os))
error_message = "ERROR: Operating System must be Windows OR Linux."
}
}
@karl-cardenas-coding
karl-cardenas-coding / Dockerfile
Created March 19, 2019 02:19
automation-dockerfile
FROM hashicorp/terraform:latest
RUN apk update && apk upgrade && apk add --no-cache \
python3 \
&& python3 -m ensurepip \
&& pip3 install --upgrade pip setuptools \
&& pip3 install awscli --upgrade --user \
&& apk add bash \
&& mv /root/.local/bin/* /usr/local/bin \
&& rm -rf /var/cache/apk/*
@karl-cardenas-coding
karl-cardenas-coding / lambda.py
Created March 19, 2019 02:17
lambda-start-ci
import json
import boto3
import os
from botocore.vendored import requests
from base64 import b64decode
projectId = os.environ['projectId']
token = os.environ['token']
tokenDecrypted = boto3.client('kms').decrypt(CiphertextBlob=b64decode(token))['Plaintext'].decode("utf-8")