@104corp/cfn-web-module
v2.2.2
Published
Include AltoScaling Group, Application LoadBalance, S3 Bucket, Role, etc...
Downloads
65
Maintainers
Readme
cfn Web Template
AWS WEB Service deployment from CloudFormation Template
Architecture
Install
Use git clone to copy template
git clone https://github.com/104corp/104isgd-devops-cfn-web.git
Or use npm install
Install Node.js and npm first!
npm i @104corp/cfn-web-module
Usage
For Prod(without scheduled action)
---
AWSTemplateFormatVersion: "2010-09-09"
Resources:
Infra:
Type: "AWS::CloudFormation::Stack"
Properties:
Parameters:
AutoScalingDesiredMax: 4
AutoScalingDesiredMin: 2
AutoScalingOutPolicyHighCPU: 80
AutoScalingOutPolicyLowCPU: 30
ALBLogEnable: true
ALBScheme: internal
ALBListenerHttpsACMArn: arn:aws:acm:ap-northeast-1:685256291126:certificate/235ab25a-3bbc-43f1-8588-ad8a106fe4ae
UserdataA: ""
UserdataB: ""
UserdataC: ""
InstanceImageId: ""
ALBLogLifecycleExpirationInDays: 30
ProductName: aws-06-web
VPCId: vpc-0651a7ee9874c4bbf
VPCSubnetIdForELB: subnet-044e3e0ca5d02d47c, subnet-0755b85dfb1b14fd2
VPCSubnetIdForEC2: subnet-044e3e0ca5d02d47c, subnet-0755b85dfb1b14fd2
TemplateURL: "./node_modules/@104corp/cfn-web-module/templates/web.yaml"
For Dev/Stg(with scheduled action)
---
AWSTemplateFormatVersion: "2010-09-09"
Resources:
Infra:
Type: "AWS::CloudFormation::Stack"
Properties:
Parameters:
AutoScalingDesiredMax: 4
AutoScalingDesiredMin: 2
AutoScalingOutPolicyHighCPU: 80
AutoScalingOutPolicyLowCPU: 30
ALBLogEnable: true
ALBScheme: internal
ALBListenerHttpsACMArn: arn:aws:acm:ap-northeast-1:685256291126:certificate/235ab25a-3bbc-43f1-8588-ad8a106fe4ae
UserdataA: ""
UserdataB: ""
UserdataC: ""
InstanceImageId: ""
ALBLogLifecycleExpirationInDays: 30
ProductName: aws-06-web
VPCId: vpc-0651a7ee9874c4bbf
VPCSubnetIdForELB: subnet-044e3e0ca5d02d47c, subnet-0755b85dfb1b14fd2
VPCSubnetIdForEC2: subnet-044e3e0ca5d02d47c, subnet-0755b85dfb1b14fd2
PowerOnTime: '0 0 * * *'
PowerOffTime: '0 11 * * *'
TemplateURL: "./node_modules/@104corp/cfn-web-module/templates/web.yaml"
Package
$ aws cloudformation package --template-file example.yml --s3-bucket <your cfn template bucket> --output-template-file packaged.yml
Deploy
$ aws cloudformation deploy --template-file packaged.yml --stack-name <your stack name>
templates/web
Description
AWS Service :
- application loadbalancer
- listen port 80 & 443
- access log enable
- autoscaling group
- change capacity by cloudwatch cpu usage
- iam role
- ssm policy
- s3 bucket
- Application Loadbalancer log
- security group
- AutoScaling Group
- Application LoadBalancer
- cloudwatch
- cpu alarm high and low
Parameters
AutoScalingOutPolicyHighCPU
Type: String
Description: How many percent cpu usage need to scaling up instance, default is 80 percent.
AutoScalingOutPolicyLowCPU
Type: String
Description: How many percent cpu usage need to scaling down instance, default is 30 percent.
AutoScalingDesiredMin
Type: String
Description: Autoscaling minimum instance capacity, default is 2.
AutoScalingDesiredMax
Type: String
Description: Autoscaling maximum instance capacity, default is 4.
ALBLogEnable
Type: String
Description: Enable or Disable LoadBalancer log, default is true.
ALBScheme
Type: String
Description: Choice ELB network, default is internal.
ALBListenerHttpsACMArn
Type: String
Description: Enter Your ACM ARN look like arn:aws:acm:region:123456789012:certificate/00000000-0000-0000-0000-000000000000
UserdataA
Type: String
Description: Enter Your shell script if needed, default is ""
UserdataB
Type: String
Description: Enter Your shell script if needed, default is ""
UserdataC
Type: String
Description: Enter Your shell script if needed, default is ""
InstanceImageId
Type: String
Description: Enter AMI ID.
ALBLogLifecycleExpirationInDays:
Type: String
Description: S3 Bucket Lifecycle, default is 30 days.
ProductName
Type: String
Description: Enter Your ProductName. E.G. NewWeb, Hunter etc...
VPCId
Type: AWS::EC2::VPC::Id
Description: Choice Exist VPC ID
VPCSubnetIdForELB
Type: AWS::EC2::Subnet::Id Description: Enter exist two subnet id depens on VPC For ElasticLoadbalancer.
VPCSubnetIdForEC2
Type: AWS::EC2::Subnet::Id
Description: Enter exist two subnet id depens on VPC For EC2.
InstanceType
Type: String
Description: Choice ec2 instance type, default is t3.nano
Use For Lab/Stg env if needed it(Option).
We provider ten Scheduled Action Function for usage.
Schedule Name and Parameter Name List
{sequence}
- First
- Second
- Third
- Fourth
- Fifth
- Sixth
- Seventh
- Eighth
- Ninth
- Tenth
- asgScheduledAction{sequence}:
- ScheduledActions{sequence}
- ScheduledActions{sequence}MaxSize
- ScheduledActions{sequence}MinSize
ScheduledActionsFirst
Type: String
Description: Conrd format like "0 8 * * * ", default is 0 0 * * * . Time Zone is UTC(Teipei Time -8)
ScheduledActionsFirstMaxSize
Type: String
Description: scheduled action for instance max size.
ScheduledActionsFirstMinSize
Type: String
Description: scheduled action for instance min size.
Maintenance
Maintainers:
104corp