Skip to content

Instantly share code, notes, and snippets.

View dtelaroli's full-sized avatar

Denilson Telaroli dtelaroli

View GitHub Profile
@dtelaroli
dtelaroli / amplify-create-subdomain.js
Created July 14, 2020 18:24
Creates an amplify subdomain with aws javascript sdk
const { to } = require("await-to-js");
const { Amplify } = require("aws-sdk");
const amplify = new Amplify();
const config = {
AMPLIFY_FRONTEND_APP_ID: "your_app_id",
AMPLIFY_FRONTEND_DOMAIN: "your_domain.com",
AMPLIFY_FRONTEND_BRANCH: "your_branch_env"
};
@dtelaroli
dtelaroli / README.md
Last active October 13, 2023 08:24
How to activate Macbook TouchID in the Terminal
  1. Open the sudo file:
sudo vim /etc/pam.d/sudo
  1. Add the line above in the first line of the sudo file
auth sufficient pam_tid.so
@dtelaroli
dtelaroli / lambda-get-identity-id.js
Created August 4, 2020 17:18
How to get identity id from cognito with jwt token
// npm install await-to-js
const { to } = require("await-to-js");
const { CognitoIdentity } = require("aws-sdk");
const identity = new CognitoIdentity();
const IDENTITY_POOL_ID = "<your identity pool id>";
exports.handler = async (event) => {
const { issuer } = event.identity;
@dtelaroli
dtelaroli / README.md
Last active November 16, 2022 13:31
AWS CodePipeline SAM Project CD with Bitbucket

Cloudformation Sam Pipeline Example

Template Parameters

env: environment name
region: aws region
codestarConnection: codestar connection arn https://docs.aws.amazon.com/cli/latest/reference/codestar-connections/create-connection.html
branch: bitbucket branch to continuous deployment
repo: bitbucket repo with pattern username/repository_name
@dtelaroli
dtelaroli / add_depends_on_to_files.sh
Last active November 14, 2022 12:24
script which splits terraform states and adds depends_on to some resources
grep -E 'resource.+"codefresh_project"' ./squads/**/*.tf | sed -E 's/([a-z_\/]+):.+" "(.+)" {/\1:\2/g' |
while IFS=":"; read -r key value; do
export key=$key value=$value
cat $key | grep name | sed -E 's/.+name.+\"(.+)\"/\1/g' |
xargs -I{} grep -E 'project_name.+"{}"' ./squads/**/*.tf | sed -E 's/([a-z\/_-]+):.+/\1/g' > tmp.txt
while read file; do
if [ -z "$(grep depends_on $file)" ]; then
replace="\ndepends_on = [codefresh_project.${value}]\n}"
perl -i"" -pe "s/^}/${replace}/g" $file
terraform fmt $file
@dtelaroli
dtelaroli / main.tf
Created October 7, 2022 17:10
workaround to list all directories in a specific folder in terraform
locals {
subfolders = toset(distinct(flatten([for _, v in fileset(".", "./dir/**") : regex("./dir/([^/]*).*", dirname(v))])))
}
@dtelaroli
dtelaroli / default.conf
Created September 27, 2018 15:08
Nginx php-fpm docker real origin ip
# you may use nginx with real ip module
server {
# your host or vpc cidr_block or the docker gateway address ip
set_real_ip_from 10.0.0.0/24;
real_ip_header X-Forwarded-For;
location ~ \.php$ {
# you should pass the header X-Forwarded-For with the real ip from frontend, the AWS ELB/ALB pass by default
fastcgi_param REMOTE_ADDR $http_x_forwarded_for;
@dtelaroli
dtelaroli / git.sh
Last active August 21, 2022 09:13
Git essentials commands
# Configuration
git config user.name "My Name"
git config user.email "myemail@domain.com"
# Initialize a git repository
git init
# Add all files to be commited
git add .
@dtelaroli
dtelaroli / script.sh
Created July 28, 2022 15:04
How to fix SunCertPathBuilderException: unable to find valid certification path to requested target in MacOS
# step 1
# execute the command to get the certificates
openssl s_client -showcerts -connect start.spring.io:443
# copy the lines stating in: Certificate chain (including this line)
# Ending in last -----END CERTIFICATE-----
# step 2
# create the cert file with this content
mkdir $HOME/certs
@dtelaroli
dtelaroli / Beans.java
Created October 4, 2018 13:05
Spring Boot, Selenium and ChromeDriver Headless
@Component
public class Beans {
@Bean @RequestScope(proxyMode = ScopedProxyMode.TARGET_CLASS)
public WebDriver webDriver() {
ChromeOptions options = new ChromeOptions()
.addArguments("--no-sandbox")
.setHeadless(true);
ChromeDriver driver = new ChromeDriver(options);