Skip to content

Instantly share code, notes, and snippets.

View thehelvetian's full-sized avatar

The Helvetian thehelvetian

View GitHub Profile
StackAlarmTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: Stack Alarm Topic
DatabasePrimaryCPUAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmDescription: Primary database CPU utilization is over 80%.
Namespace: AWS/RDS
@thehelvetian
thehelvetian / storage-high-availability.yaml
Created January 1, 2019 06:03 — forked from li0nel/storage-high-availability.yaml
CloudFormation stack for a DB Cluster read replica
DatabaseReplicaInstance:
Type: AWS::RDS::DBInstance
DependsOn: DatabasePrimaryInstance
Properties:
Engine: aurora
DBClusterIdentifier: !Ref DatabaseCluster
DBInstanceClass: !Ref DatabaseInstanceType
DBSubnetGroupName: !Ref DatabaseSubnetGroup
@thehelvetian
thehelvetian / elasticsearch.yml
Created January 1, 2019 06:03 — forked from li0nel/elasticsearch.yml
CloudFormation stack for an ElasticSearch domain
Elasticsearch:
Type: AWS::Elasticsearch::Domain
Properties:
DomainName: !Sub ${AWS::StackName}-es
ElasticsearchVersion: 5.5
ElasticsearchClusterConfig:
InstanceType: t2.small.elasticsearch
ZoneAwarenessEnabled: false
InstanceCount: 1
EBSOptions:
* * * * * 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.
# The worker containers simply execute the Laravel artisan queue:work
# command instead of php-fpm
TaskDefinitionWorker:
Type: AWS::ECS::TaskDefinition
Properties:
Family: laravel-workers
ContainerDefinitions:
- Name: app
Essential: true
Image: !Join [ ".", [ !Ref "AWS::AccountId", "dkr.ecr", !Ref "AWS::Region", !Join [ ":", [ !Join [ "/", [ "amazonaws.com", !Ref ECR ] ], "laravel" ] ] ] ]
# That's all it takes to create a queue in CloudFormation
# CloudFormation will assign a unique name to it, that we
# will pass to our Laravel containers
Queue:
Type: AWS::SQS::Queue
# Then in the web.yaml stack, we update our ECSRole to grant
# our ECS instances access to this one queue we just created
- PolicyName: sqs-read-write-access
PolicyDocument:
@thehelvetian
thehelvetian / nginx.conf
Created January 1, 2019 06:02 — forked from li0nel/nginx.conf
Enable Nginx rewrite to serve assets from CloudFront
location ~ \.php$ {
root /var/www/html/public;
fastcgi_cache cache_key;
fastcgi_cache_valid 200 204 1m;
fastcgi_ignore_headers Cache-Control;
fastcgi_no_cache $http_authorization $cookie_laravel_session;
fastcgi_cache_lock on;
fastcgi_cache_lock_timeout 10s;
add_header X-Proxy-Cache $upstream_cache_status;
# 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",
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'