Skip to content

Instantly share code, notes, and snippets.

View li0nel's full-sized avatar

Lionel Martin li0nel

View GitHub Profile
@li0nel
li0nel / codebuild.yml
Created February 5, 2018 14:15
CodeBuild
CodeBuildProject:
Type: AWS::CodeBuild::Project
Properties:
Artifacts:
Type: CODEPIPELINE
Source:
Type: CODEPIPELINE
BuildSpec: |
version: 0.2
phases:
@li0nel
li0nel / codecommit.yml
Created February 5, 2018 14:00
CodeCommit
Resources:
CodeRepository:
Type: AWS::CodeCommit::Repository
Properties:
RepositoryName: !Ref AWS::StackName
Outputs:
CloneUrlHttp:
Value: !GetAtt CodeRepository.CloneUrlHttp
@li0nel
li0nel / codepipeline.yml
Created February 5, 2018 13:49
CodePipeline
---
AWSTemplateFormatVersion: 2010-09-09
Parameters:
RepositoryBranch:
Type: String
Default: master
Cluster:
AlarmTopic:
Type: AWS::SNS::Topic
Properties:
Subscription:
- Endpoint: your_email_here@company.com
Protocol: email
CPUAlarmHigh:
Type: AWS::CloudWatch::Alarm
Properties:
# 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:
ScaleUpPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AdjustmentType: ChangeInCapacity
AutoScalingGroupName:
Ref: asGroup
Cooldown: '1'
ScalingAdjustment: '1'
CPUAlarmHigh:
aws cloudformation delete-stack --stack-name=laravelaws
# Create your CloudFormation stack from scratch using the create-stack command
aws cloudformation create-stack
--stack-name=laravel
--template-body=file://master.yaml
--capabilities CAPABILITY_NAMED_IAM
--parameters
ParameterKey=CloudFrontOAI,ParameterValue=origin-access-identity/cloudfront/YOUR_CF_OAI_HERE
ParameterKey=CertificateArnCF,ParameterValue=arn:aws:acm:us-east-1:your_cloudfront_certificate_arn_here
ParameterKey=CertificateArn,ParameterValue=arn:aws:acm:us-east-1:your_certificate_arn_here
ParameterKey=BaseUrl,ParameterValue=laravelaws.com
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