Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
256 changes: 256 additions & 0 deletions ebkawasaki.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
---
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Create an ElasticBeanstalk Application, Environment and deploy the samplephp file from S3 bucket'
Parameters:
KeyPair:
Description: Select Key pair
Type: AWS::EC2::KeyPair::KeyName
VpcId:
Description: Select VPC
Type: AWS::EC2::VPC::Id
SubnetId:
Description: Select EB-Instance Subnet
Type: AWS::EC2::Subnet::Id
pubsubnet:
Description: Select Bastion Subnet
Type: AWS::EC2::Subnet::Id
ElbSubnets:
Type: List<AWS::EC2::Subnet::Id>
Description: Select two public subnets in different Availability Zones!
InstanceType:
Description: WebServer EC2 instance type
Type: String
Default: t2.micro
AllowedValues:
- t1.micro
- t2.nano
- t2.micro
- t2.small
- t2.medium
KeyPair:
Description: Select Key pair
Type: AWS::EC2::KeyPair::KeyName
ELBCrossZone:
Type: String
Description: Configure the load balancer to route traffic evenly across all instances
in all Availability Zones rather than only within each zone.
AllowedValues:
- 'true'
- 'false'
Default: 'true'
ApplicationName:
Type: String
Description: 'Name of the ElasticBeanstalk Application'
Default: eb-cft
ApplicationDescription:
Type: String
Description: 'Discreption of the ElasticBeanstalk Application'
Default: eb-cft-with-wordpress
ApplicationS3Bucket:
Description: Application path in s3
Type: String
Default: wpres-wpres
ApplicationS3Artifact:
Description: Application artifact file ebcft.zip
Type: String
Default: wordpresstest.zip
######################################################
## RegionMap:
# us-west-2:
# AMI: ami-0a85857bfc5345c38
#us-east-1:
# AMI: ami-00dc79254d0461090
#us-west-1:
# AMI: ami-024c80694b5b3e51a
######################################################
Resources:
BastionSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security Group for EC2 to allow SSH from Bastion and expose HTTP 80
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: 0.0.0.0/0
VpcId: !Ref VpcId
Tags:
- Key: Name
Value: Bastion-sg
EBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security Group for EC2 to allow SSH from Bastion and expose HTTP 80
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
SourceSecurityGroupId: !Ref ALBSecurityGroup
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
SourceSecurityGroupId: !Ref ALBSecurityGroup
VpcId: !Ref VpcId
Tags:
- Key: Name
Value: Eb-instance-sg
ALBSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: SecurityGroup for ElasticBeanstalk Balancer
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '443'
ToPort: '443'
CidrIp: 0.0.0.0/0
VpcId:
Ref: VpcId
Tags:
- Key: Name
Value: ALB-Sg
​ MyEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
InstanceType: t2.micro
KeyName: !Ref KeyPair
ImageId: ami-0a85857bfc5345c38
SubnetId: !Ref pubsubnet
SecurityGroupIds:
- Ref: BastionSecurityGroup
Tags:
- Key: Name
Value: Kawasaki-Bastion-host
​ #Elatsic beanstalk
WPApplication:
Type: AWS::ElasticBeanstalk::Application
Properties:
ApplicationName: !Ref ApplicationName
Description: !Ref ApplicationDescription
​ WordpressVersion:
Type: AWS::ElasticBeanstalk::ApplicationVersion
Properties:
Description: "1.0.0"
ApplicationName:
Ref: WPApplication
SourceBundle:
S3Bucket: !Ref ApplicationS3Bucket
S3Key: !Ref ApplicationS3Artifact
WordpressConfigTemplate:
Type: AWS::ElasticBeanstalk::ConfigurationTemplate
Properties:
ApplicationName:
Ref: WPApplication
Description: AWS Elastic Beanstalk Environment running Wordpress Application
EnvironmentId: ''
SolutionStackName: 64bit Amazon Linux 2018.03 v2.9.0 running PHP 7.3
OptionSettings:
- Namespace: aws:autoscaling:asg
OptionName: MinSize
Value: "1"
- Namespace: aws:autoscaling:asg
OptionName: MaxSize
Value: "4"
- Namespace: aws:autoscaling:launchconfiguration
OptionName: InstanceType
Value:
Ref: InstanceType
- Namespace: aws:autoscaling:launchconfiguration
OptionName: SSHSourceRestriction
Value:
Fn::Join:
- ''
- - tcp,22,22,
- Ref: BastionSecurityGroup
- Namespace: aws:elasticbeanstalk:container:php:phpini
OptionName: document_root
Value: '/wordpress'
- Namespace: aws:autoscaling:launchconfiguration
OptionName: RootVolumeType
Value: gp2
- Namespace: aws:autoscaling:launchconfiguration
OptionName: RootVolumeSize
Value: "10"
- Namespace: aws:autoscaling:launchconfiguration
OptionName: SecurityGroups
Value:
Ref: EBSecurityGroup
- Namespace: aws:autoscaling:launchconfiguration
OptionName: EC2KeyName
Value:
Ref: KeyPair
- Namespace: aws:autoscaling:trigger
OptionName: BreachDuration
Value: "4"
- Namespace: aws:autoscaling:trigger
OptionName: LowerBreachScaleIncrement
Value: "-1"
- Namespace: aws:autoscaling:trigger
OptionName: LowerThreshold
Value: "40"
- Namespace: aws:autoscaling:trigger
OptionName: MeasureName
Value: CPUUtilization
- Namespace: aws:autoscaling:trigger
OptionName: MeasureName
Value: CPUUtilization
- Namespace: aws:autoscaling:trigger
OptionName: Statistic
Value: Average
- Namespace: aws:autoscaling:trigger
OptionName: Unit
Value: Percent
- Namespace: aws:ec2:vpc
OptionName: VPCId
Value:
Ref: VpcId
- Namespace: aws:ec2:vpc
OptionName: Subnets
Value:
Ref: SubnetId
- Namespace: aws:ec2:vpc
OptionName: ELBSubnets
Value: !Join [",", [!Select [0, !Ref ElbSubnets], !Select [1, !Ref ElbSubnets]]]
- Namespace: aws:elasticbeanstalk:environment
OptionName: LoadBalancerType
Value: application
- Namespace: aws:autoscaling:launchconfiguration
OptionName: IamInstanceProfile
Value: aws-elasticbeanstalk-ec2-role
- Namespace: aws:elb:loadbalancer
OptionName: SecurityGroups
Value:
Ref: ALBSecurityGroup
- Namespace: aws:elbv2:listenerrule:default
OptionName: PathPatterns
Value: "/*"
- Namespace: aws:elbv2:listenerrule:default2
OptionName: PathPatterns
Value: "/*"
Value: default2
- Namespace: aws:elbv2:listenerrule:default
OptionName: Priority
Value: "1"
- Namespace: aws:elbv2:listenerrule:default2
OptionName: Priority
Value: "2"
- Namespace: aws:elbv2:listener:default
OptionName: ListenerEnabled
Value: "true"
WordpressEnvironment:
Type: AWS::ElasticBeanstalk::Environment
Properties:
ApplicationName:
Ref: WPApplication
EnvironmentName: Php-cft-test-EB
Description: AWS Elastic Beanstalk Environment running Wordpress Application.
TemplateName:
Ref: WordpressConfigTemplate
VersionLabel:
Ref: WordpressVersion
#######################################################################################

Loading