Skip to content

Instantly share code, notes, and snippets.

@fungilation
Forked from haranjackson/deploy_wiki.sh
Last active January 11, 2023 00:12
Show Gist options
  • Save fungilation/fc95de6137cf310ef96287ab8a81d8a6 to your computer and use it in GitHub Desktop.
Save fungilation/fc95de6137cf310ef96287ab8a81d8a6 to your computer and use it in GitHub Desktop.
Deploys BookStack wiki on AWS EC2
STACK=bookstack-ec2 # give the stack a name
REGION=us-west-2 # choose your region
DOMAIN= # wiki will be hosted at wiki.[DOMAIN]
aws cloudformation deploy \
--template-file wiki.yaml \
--stack-name $STACK \
--region $REGION \
--parameter-overrides Domain=$DOMAIN
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
- CidrIp: 0.0.0.0/0
FromPort: 22
IpProtocol: TCP
ToPort: 22
Instance:
DeletionPolicy: Retain
Type: AWS::EC2::Instance
Properties:
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
DeleteOnTermination: false
VolumeSize: 30
DisableApiTermination: true
ImageId: ami-0497e51c56f8ea7da # us-west-2 ubuntu-22.04 - https://cloud-images.ubuntu.com/locator/ec2/
InstanceInitiatedShutdownBehavior: stop
InstanceType: t3.micro
KeyName: # name of "Key pairs" on EC2 for ssh
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/main/scripts/installation-ubuntu-22.04.sh
chmod a+x installation-ubuntu-22.04.sh
sudo ./installation-ubuntu-22.04.sh wiki.${Domain}
EIP:
Type: AWS::EC2::EIP
Properties:
InstanceId: !Ref Instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment