Skip to content

Instantly share code, notes, and snippets.

View dgomesbr's full-sized avatar
🏠
Working from home

Diego Magalhães dgomesbr

🏠
Working from home
View GitHub Profile
@dgomesbr
dgomesbr / deploy2AWS.sh
Last active February 24, 2019 15:15
WP2Static S3 + Cloudfront invalidation
#!/bin/bash
#######################################################################################
#
# On WP2Static, targetdir = /opt/bitnami/wordpress/wp-content/static-version/deploy
# the script is executed outside the deploy dir in case you need to do any transfomations
# before the actual sync.
#
# Earlier version contained for example, hash of the deploy dir and its files for
# comparison, but since we're using s3 sync, no need to keep that.
@dgomesbr
dgomesbr / sample-policy.json
Created July 6, 2020 05:23
Sample DynamoDB policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Query"
],
@dgomesbr
dgomesbr / sampe.js
Created November 9, 2020 14:50
Sample write event to dynamoDB
// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT-0
// default imports
const AWSXRay = require('aws-xray-sdk-core')
const AWS = AWSXRay.captureAWS(require('aws-sdk'))
const { metricScope, Unit } = require("aws-embedded-metrics")
const DDB = new AWS.DynamoDB({ apiVersion: "2012-10-08" })
// environment variables
#!/bin/bash
# Specify the desired volume size in GiB as a command line argument. If not specified, default to 50 GiB.
SIZE=${1:-50}
# Get the ID of the environment host Amazon EC2 instance.
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
# Get the ID of the Amazon EBS volume associated with the instance.
VOLUMEID=$(aws ec2 describe-instances \