Created
February 5, 2020 16:53
-
-
Save haranjackson/379fc34f4c5e65b9f56168050d940743 to your computer and use it in GitHub Desktop.
Deploys BookStack wiki on AWS EC2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STACK= # give the stack a name | |
REGION= # choose your region | |
DOMAIN= # a Route53 domain - wiki will be hosted at wiki.[DOMAIN] | |
aws cloudformation deploy \ | |
--template-file wiki.yaml \ | |
--stack-name $STACK \ | |
--region $REGION \ | |
--parameter-overrides Domain=$DOMAIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: 2010-09-09 | |
Parameters: | |
Domain: | |
Type: String | |
Resources: | |
SecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
GroupDescription: Allows connections from anyhere | |
GroupName: WikiConnectionsIn | |
SecurityGroupIngress: | |
- CidrIp: 0.0.0.0/0 | |
FromPort: 80 | |
IpProtocol: TCP | |
ToPort: 80 | |
- CidrIp: 0.0.0.0/0 | |
FromPort: 443 | |
IpProtocol: TCP | |
ToPort: 443 | |
Instance: | |
DeletionPolicy: Retain | |
Type: AWS::EC2::Instance | |
Properties: | |
BlockDeviceMappings: | |
- DeviceName: /dev/sda1 | |
Ebs: | |
DeleteOnTermination: false | |
VolumeSize: 20 | |
DisableApiTermination: true | |
ImageId: ami-02df9ea15c1778c9c | |
InstanceInitiatedShutdownBehavior: stop | |
InstanceType: t3.micro | |
SecurityGroups: | |
- !Ref SecurityGroup | |
Tags: | |
- Key: Name | |
Value: wiki | |
UserData: | |
Fn::Base64: !Sub | | |
#!/bin/bash -xe | |
sudo apt update | |
sudo apt install unzip | |
wget https://raw.githubusercontent.com/BookStackApp/devops/master/scripts/installation-ubuntu-18.04.sh | |
chmod a+x installation-ubuntu-18.04.sh | |
sudo ./installation-ubuntu-18.04.sh wiki.${Domain} | |
EIP: | |
Type: AWS::EC2::EIP | |
Properties: | |
InstanceId: !Ref Instance | |
RecordSet: | |
Type: AWS::Route53::RecordSet | |
Properties: | |
HostedZoneName: !Sub ${Domain}. | |
Name: !Sub wiki.${Domain}. | |
Type: A | |
TTL: 300 | |
ResourceRecords: | |
- !Ref EIP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment