Skip to content

Instantly share code, notes, and snippets.

Avatar

Petra Barus petrabarus

View GitHub Profile
@petrabarus
petrabarus / invalidate_cloudfront_and_wait.sh
Last active Apr 18, 2022
Invalidate CloudFront Distribution and Wait
View invalidate_cloudfront_and_wait.sh
#!/usr/bin/env bash
# Requirements
# - AWS
# - jq
# Variables
PROFILE=
DISTRIBUTION_ID=
PATHS="/*"
@petrabarus
petrabarus / 1passwordtoenv.sh
Last active Dec 2, 2021
1Password to Environment Variables
View 1passwordtoenv.sh
#!/usr/bin/env bash
# Load environment variables from 1password
# To execute this script, execute the command below.
# source 1passwordtoenv.sh 'Name of the item'
ITEM_NAME=$1
# Signin
eval $(op signin)
# Load environment variables
@petrabarus
petrabarus / aws-batch-empty-delete.bash
Last active May 4, 2021
Batch Empty and Delete S3 Bucket with Grep Pattern
View aws-batch-empty-delete.bash
#!/usr/bin/env bash
# Sometimes we create a lot of S3 Bucket with similar names.
# The command below will find all buckets in the region with pattern `bucket_pattern`,
# then empty the bucket and then delete the bucket.
BUCKET_PATTERN=bucket_pattern
aws s3api list-buckets |\
jq -r '.Buckets[].Name' |\
grep $BUCKET_PATTERN |\
xargs -n 1 -I {} sh -c 'aws s3 rm s3://{} --recursive && aws s3 rb s3://{}'
View gist:d1dd6f83d1d64204d454fb30fb94b0c9
#!/bin/bash
# Resize disk for AWS Cloud9
# https://docs.aws.amazon.com/cloud9/latest/user-guide/move-environment.html#move-environment-resize
# Specify the desired volume size in GiB as a command line argument. If not specified, default to 20 GiB.
SIZE=${1:-20}
# Get the ID of the environment host Amazon EC2 instance.
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
@petrabarus
petrabarus / Dockerfile
Last active Nov 5, 2021
Part 3 Using DynamoDB for Session Management in PHP/Yii2 Application
View Dockerfile
version: '3'
services:
php:
build: .
volumes:
- ~/.composer-docker/cache:/root/.composer/cache:delegated
- ./:/app:delegated
ports:
- '8080:80'
environment:
View Webstack.template.yml
Resources:
ecsCluster15812518:
Type: AWS::ECS::Cluster
Metadata:
aws:cdk:path: WebStack/ecsCluster/Resource
ecsClusterVpcFF32B42F:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
View app.ts
#!/usr/bin/env node
import 'source-map-support/register';
import cdk = require('@aws-cdk/core');
import ecs = require("@aws-cdk/aws-ecs");
import ecsPatterns = require("@aws-cdk/aws-ecs-patterns");
export class WebStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
this.createECSCluster();
@petrabarus
petrabarus / modern-yii1-app_part-1.patch
Last active Dec 22, 2019
Modern Yii2 Application - Part 1 Patch
View modern-yii1-app_part-1.patch
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..b2ef806
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+cdk.out
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 5bd9be8..8600814 100644
View install-and-run-sonar-scanner.sh
#!/usr/bin/env bash
VERSION=3.3.0.1492-linux
echo "Downloading sonar-scanner....."
rm -rfv /tmp/sonar-scanner-cli-$VERSION.zip
wget -P /tmp/ -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$VERSION.zip
echo "Download completed."
echo "Unziping downloaded file..."
unzip -q /tmp/sonar-scanner-cli-$VERSION.zip -d /tmp/
View install-sonar-scanner.sh
#!/usr/bin/env bash
VERSION=3.3.0.1492-linux
echo "Downloading sonar-scanner....."
rm -rfv /tmp/sonar-scanner-cli-$VERSION.zip
wget -P /tmp/ -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$VERSION.zip
echo "Download completed."
echo "Unziping downloaded file..."
unzip /tmp/sonar-scanner-cli-$VERSION.zip -d /tmp/