Running InfluxDB on AWS with Cloud Formation

Anais Dotis
Aug 19 · 5 min read

Setup for an EC2 instance

cp ~/Downloads/Influx20.pem ~/cloudformation/deploy-aws
touch stack.yml
Copy
chmod 400 Influx20.pemCopy

Creating the stack definition to install InfluxDB

Resources:
AppNode:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-024a64a6685d05041
KeyName: Influx20
SecurityGroups:
- !Ref AppNodeSG
Copy
AppNodeSG:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: for the app nodes that allow ssh
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: 0.0.0.0/0
Copy
UserData: !Base64 |
#!/bin/bash
apt-get update -qq
apt-get install -y apt-transport-https ca-certificates
apt-key adv apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
apt-get update -qq apt-get purge lxc-docker || true
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
apt-get -y install linux-image-extra-$(uname -r) linux-image-extra-virtual
apt-get -y install docker-ce
usermod -aG docker unbuntu
docker image pull quay.io/influxdb/influxdb:2.0.0-alpha
docker container run -p 80:9999 quay.io/influxdb/influxdb:2.0.0-alpha
Copy

Using Cloud Formation to create the stack

aws cloudformation create-stack --stack-name demo --region us-east-1 --template-body file://$PWD/stack.ymlCopy
wget <a href="https://dl.influxdata.com/telegraf/releases/telegraf_1.10.4-1_amd64.deb">https://dl.influxdata.com/telegraf/releases/telegraf_1.10.4-1_amd64.deb</a>
sudo dpkg -i telegraf_1.10.4-1_amd64.deb
Copy

Conclusion

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade