Skip to content

Instantly share code, notes, and snippets.

View li0nel's full-sized avatar

Lionel Martin li0nel

View GitHub Profile
FROM php:fpm
# Update packages and install composer and PHP dependencies.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
postgresql-client \
libpq-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
* * * * * root . /etc/cron.d/project_env.sh ; /usr/local/bin/php /var/www/html/artisan schedule:run &> /var/log/cron.log
# An empty line is required at the end of this file for a valid cron file.
aws cloudfront create-cloud-front-origin-access-identity
--cloud-front-origin-access-identity-config CallerReference=random_string_here,Comment=
CloudFrontDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Origins:
- DomainName: !Ref S3BucketDNSName
Id: myS3Origin
S3OriginConfig:
OriginAccessIdentity: !Ref CloudFrontOAI
Enabled: 'true'
# Add an ALIAS record to ELB URL
aws route53 change-resource-record-sets 
--hosted-zone-id /hostedzone/YOUR_HOSTED_ZONE_ID
--change-batch '{
"Changes":[
{
"Action":"CREATE",
"ResourceRecordSet":{
"Name":"files.laravelaws.com.",
"Type":"A",
# create a hosted zone for AWS to select NS servers for your domain
aws route53 create-hosted-zone
--name laravelaws.com
--caller-reference random_string_here
# wait for the hosted zone to be created
# retrieve NS records
aws route53 get-hosted-zone
--id /hostedzone/YOUR_HOSTED_ZONE_ID
@li0nel
li0nel / ssh-tunnel.sh
Created December 10, 2017 13:45
SSH tunnel to our Aurora or RDS database
# create a SSH tunnel to RDS through your bastion:
ssh -L 54320:your_rds_database_endpoint_here.your_region_here.rds.amazonaws.com:5432
ec2-user@<bastion_public_ip>
-i ./laravelaws.pem
# Your remote database is now accessible from port 54320 on your local machine
# I strongly recommend to create first thing a read-only user in your database
psql -h localhost -p 54320 -U postgres -W db_name_here
> CREATE ROLE lionel LOGIN PASSWORD 'a_unique_password_here';
> GRANT CONNECT ON DATABASE crvs TO lionel;
@li0nel
li0nel / Dockerfile-nginx
Created December 10, 2017 13:25
Dockerfile for Nginx
FROM nginx
ADD deploy/nginx/nginx.conf /etc/nginx/
ADD deploy/nginx/default.conf /etc/nginx/conf.d/
ADD public /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
@li0nel
li0nel / Dockerfile
Last active January 1, 2019 05:56
Laravel reference Dockerfile
FROM php:7.1-fpm
# Update packages and install composer and PHP dependencies.
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
postgresql-client \
libpq-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
@li0nel
li0nel / alb.yaml
Created December 10, 2017 13:22
CloudFormation template for ALB
# One ALB with two listeners for HTTP and HTTPS
# The HTTP listener will pointed to a specific Nginx container redirecting traffic to HTTPS
# because neither ALB or ELB allow you to handle this through their configuration
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Ref EnvironmentName
Subnets: !Ref PublicSubnets
SecurityGroups:
- !Ref LBSecurityGroup