Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "AWSTemplateFormatVersion": "2010-09-09",
- "Mappings": {
- "RegionMap": {
- "us-east-1": {
- "lidarr": "ami-024a64a6685d05041",
- "mopidy": "ami-024a64a6685d05041"
- }
- }
- },
- "Parameters": {
- "LidarrInstanceType": {
- "Type": "String",
- "Default": "t2.micro",
- "AllowedValues": [
- "t2.micro",
- "m1.small",
- "m1.large"
- ],
- "Description": "Choose the instance on which Lidarr will run. Default is t2.micro."
- },
- "MopidyInstanceType": {
- "Type": "String",
- "Default": "t2.micro",
- "AllowedValues": [
- "t2.micro",
- "m1.small",
- "m1.large"
- ],
- "Description": "Choose the instance on which Mopidy will run. Default is t2.micro."
- },
- "KeyPairForInstances": {
- "Type": "AWS::EC2::KeyPair::KeyName",
- "Description": "Keys to upload to the EC2 instances."
- }
- },
- "Resources": {
- "AppNameRouteTable": {
- "Type": "AWS::EC2::RouteTable",
- "Properties": {
- "VpcId": {
- "Ref": "AppNameVPC"
- }
- }
- },
- "AppNameRouteTableAssociation": {
- "Type": "AWS::EC2::SubnetRouteTableAssociation",
- "Properties": {
- "RouteTableId": {
- "Ref": "AppNameRouteTable"
- },
- "SubnetId": {
- "Ref": "AppNameSubnet"
- }
- }
- },
- "AppNameRoute": {
- "Type": "AWS::EC2::Route",
- "Properties": {
- "DestinationCidrBlock": "0.0.0.0/0",
- "GatewayId": {
- "Ref": "AppNameInternetGateway"
- },
- "RouteTableId": {
- "Ref": "AppNameRouteTable"
- }
- }
- },
- "AppNameVPCGatewayAtachment": {
- "Type": "AWS::EC2::VPCGatewayAttachment",
- "Properties": {
- "InternetGatewayId": {
- "Ref": "AppNameInternetGateway"
- },
- "VpcId": {
- "Ref": "AppNameVPC"
- }
- }
- },
- "AppNameInternetGateway": {
- "Type": "AWS::EC2::InternetGateway",
- "Properties": {}
- },
- "ApNameLidarrEIP": {
- "Type": "AWS::EC2::EIP",
- "Properties": {
- "InstanceId": {
- "Ref": "AppNameLidarrVM"
- }
- }
- },
- "ApNameMopidyEIP": {
- "Type": "AWS::EC2::EIP",
- "Properties": {
- "InstanceId": {
- "Ref": "AppNameMopidyVM"
- }
- }
- },
- "AppNameLidarrRole": {
- "Type": "AWS::IAM::Role",
- "Properties": {
- "AssumeRolePolicyDocument": {
- "Version": "2012-10-17",
- "Statement": [
- {
- "Effect": "Allow",
- "Principal": {
- "Service": [
- "ec2.amazonaws.com"
- ]
- },
- "Action": [
- "sts:AssumeRole"
- ]
- }
- ]
- },
- "Path": "/",
- "Policies": [
- {
- "PolicyName": "root",
- "PolicyDocument": {
- "Version": "2012-10-17",
- "Statement": [
- {
- "Effect": "Allow",
- "Action": "*",
- "Resource": "*"
- }
- ]
- }
- }
- ],
- "RoleName": {
- "Fn::Join": [
- "-",
- [
- "AppNameLidarrRole",
- {
- "Ref": "AWS::Region"
- }
- ]
- ]
- }
- }
- },
- "AppNameLidarrProfile": {
- "Type": "AWS::IAM::InstanceProfile",
- "Properties": {
- "Path": "/",
- "Roles": [
- {
- "Ref": "AppNameLidarrRole"
- }
- ]
- }
- },
- "AppNameMopidyRole": {
- "Type": "AWS::IAM::Role",
- "Properties": {
- "AssumeRolePolicyDocument": {
- "Version": "2012-10-17",
- "Statement": [
- {
- "Effect": "Allow",
- "Principal": {
- "Service": [
- "ec2.amazonaws.com"
- ]
- },
- "Action": [
- "sts:AssumeRole"
- ]
- }
- ]
- },
- "Path": "/",
- "Policies": [
- {
- "PolicyName": "root",
- "PolicyDocument": {
- "Version": "2012-10-17",
- "Statement": [
- {
- "Effect": "Allow",
- "Action": "*",
- "Resource": "*"
- }
- ]
- }
- }
- ],
- "RoleName": {
- "Fn::Join": [
- "-",
- [
- "AppNameMopidyRole",
- {
- "Ref": "AWS::Region"
- }
- ]
- ]
- }
- }
- },
- "AppNameMopidyProfile": {
- "Type": "AWS::IAM::InstanceProfile",
- "Properties": {
- "Path": "/",
- "Roles": [
- {
- "Ref": "AppNameMopidyRole"
- }
- ]
- }
- },
- "AppNameLidarrDisk": {
- "Type": "AWS::EC2::Volume",
- "Properties": {
- "AvailabilityZone": {
- "Fn::Join": [
- "",
- [
- {
- "Ref": "AWS::Region"
- },
- "a"
- ]
- ]
- },
- "Size": 4,
- "Tags": [
- {
- "Key": "App",
- "Value": "Lidarr"
- }
- ],
- "VolumeType": "gp2"
- }
- },
- "AppNameMopidyDisk": {
- "Type": "AWS::EC2::Volume",
- "Properties": {
- "AvailabilityZone": {
- "Fn::Join": [
- "",
- [
- {
- "Ref": "AWS::Region"
- },
- "a"
- ]
- ]
- },
- "Size": 4,
- "Tags": [
- {
- "Key": "App",
- "Value": "Mopidy"
- }
- ],
- "VolumeType": "gp2"
- }
- },
- "AppNameSubnet": {
- "Type": "AWS::EC2::Subnet",
- "Properties": {
- "VpcId": {
- "Ref": "AppNameVPC"
- },
- "AvailabilityZone": {
- "Fn::Join": [
- "",
- [
- {
- "Ref": "AWS::Region"
- },
- "a"
- ]
- ]
- },
- "CidrBlock": "10.0.1.0/24"
- }
- },
- "AppNameVPC": {
- "Type": "AWS::EC2::VPC",
- "Properties": {
- "CidrBlock": "10.0.0.0/16",
- "InstanceTenancy": "default"
- }
- },
- "AppNameLidarrSecutityGroup": {
- "Type": "AWS::EC2::SecurityGroup",
- "Properties": {
- "GroupName": "App Name Lidarr Secutity Group",
- "GroupDescription": "Define security rules to ensure the EC2 hosting Lidarr is wich with no extra permissions that in need",
- "SecurityGroupEgress": [
- {
- "CidrIp": "0.0.0.0/0",
- "Description": "Allow all traffic",
- "FromPort": 0,
- "IpProtocol": "tcp",
- "ToPort": 65535
- }
- ],
- "SecurityGroupIngress": [
- {
- "CidrIp": "0.0.0.0/0",
- "Description": "Allow all traffic",
- "FromPort": 0,
- "IpProtocol": "tcp",
- "ToPort": 65535
- }
- ],
- "Tags": [
- {
- "Key": "App",
- "Value": "Lidarr"
- }
- ],
- "VpcId": {
- "Ref": "AppNameVPC"
- }
- }
- },
- "AppNameMopidySecutityGroup": {
- "Type": "AWS::EC2::SecurityGroup",
- "Properties": {
- "GroupName": "App Name Mopidy Secutity Group",
- "GroupDescription": "Define security rules to ensure the EC2 hosting Mopidy is wich with no extra permissions that in need",
- "SecurityGroupEgress": [
- {
- "CidrIp": "0.0.0.0/0",
- "Description": "Allow all traffic",
- "FromPort": 0,
- "IpProtocol": "tcp",
- "ToPort": 65535
- }
- ],
- "SecurityGroupIngress": [
- {
- "CidrIp": "0.0.0.0/0",
- "Description": "Allow all traffic",
- "FromPort": 0,
- "IpProtocol": "tcp",
- "ToPort": 65535
- }
- ],
- "Tags": [
- {
- "Key": "App",
- "Value": "Mopidy"
- }
- ],
- "VpcId": {
- "Ref": "AppNameVPC"
- }
- }
- },
- "AppNameLidarrVM": {
- "Type": "AWS::EC2::Instance",
- "Properties": {
- "AvailabilityZone": {
- "Fn::Join": [
- "",
- [
- {
- "Ref": "AWS::Region"
- },
- "a"
- ]
- ]
- },
- "IamInstanceProfile": {
- "Ref": "AppNameLidarrProfile"
- },
- "ImageId": {
- "Fn::FindInMap": [
- "RegionMap",
- {
- "Ref": "AWS::Region"
- },
- "lidarr"
- ]
- },
- "InstanceType": {
- "Ref": "LidarrInstanceType"
- },
- "KeyName": {
- "Ref": "KeyPairForInstances"
- },
- "SecurityGroupIds": [
- {
- "Ref": "AppNameLidarrSecutityGroup"
- }
- ],
- "SubnetId": {
- "Ref": "AppNameSubnet"
- },
- "Tags": [
- {
- "Key": "App",
- "Value": "Lidarr"
- }
- ],
- "UserData": {
- "Fn::Base64": {
- "Fn::Join": [
- "\n",
- [
- "#!/bin/bash -x\n",
- "\n",
- "exec > /tmp/boot.log 2>&1",
- "\n",
- "# Add the Mono repository to your system\n",
- "apt install gnupg ca-certificates\n",
- "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF\n",
- "echo \"deb https://download.mono-project.com/repo/ubuntu stable-bionic main\" | tee /etc/apt/sources.list.d/mono-official-stable.lis\n",
- "apt update\n",
- "\n",
- "\n",
- "# Install Mono\n",
- "apt install mono-devel\n",
- "\n",
- "\n",
- "# Install Lidarr\n",
- "cd /opt\n",
- "wget https://github.com/lidarr/Lidarr/releases/download/v0.5.0.583/Lidarr.develop.0.5.0.583.linux.tar.gz\n",
- "tar -xzvf Lidarr.develop.0.5.0.583.linux.tar.gz\n",
- "rm Lidarr.develop.0.5.0.583.linux.tar.gz\n",
- "\n",
- "\n",
- "# Auto start Lidarr\n",
- "useradd -s /bin/false -d /var/lib/lidarr/ -r -m -U lidarr\n",
- "chown -R lidarr:lidarr /opt/Lidarr\n",
- "chmod -R a=,a+X,u+rw,g+r /opt/Lidarr\n",
- "\n",
- "touch /etc/systemd/system/lidarr.service\n",
- "echo \"[Unit]\" > /etc/systemd/system/lidarr.service\n",
- "echo \"Description=Lidarr Daemon\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"After=network.target\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"[Service]\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"User=lidarr\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"Group=lidarr\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"Type=simple\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"ExecStart=/usr/bin/mono /opt/Lidarr/Lidarr.exe -nobrowser\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"TimeoutStopSec=20\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"KillMode=process\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"Restart=on-failure\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"[Install]\" >> /etc/systemd/system/lidarr.service\n",
- "echo \"WantedBy=multi-user.target\" >> /etc/systemd/system/lidarr.service\n",
- "\n",
- "systemctl enable lidarr.service\n",
- "systemctl start lidarr.service\n"
- ]
- ]
- }
- },
- "Volumes": [
- {
- "Device": "/dev/sda2",
- "VolumeId": {
- "Ref": "AppNameLidarrDisk"
- }
- }
- ]
- }
- },
- "AppNameMopidyVM": {
- "Type": "AWS::EC2::Instance",
- "Properties": {
- "AvailabilityZone": {
- "Fn::Join": [
- "",
- [
- {
- "Ref": "AWS::Region"
- },
- "a"
- ]
- ]
- },
- "IamInstanceProfile": {
- "Ref": "AppNameMopidyProfile"
- },
- "ImageId": {
- "Fn::FindInMap": [
- "RegionMap",
- {
- "Ref": "AWS::Region"
- },
- "mopidy"
- ]
- },
- "InstanceType": {
- "Ref": "MopidyInstanceType"
- },
- "KeyName": {
- "Ref": "KeyPairForInstances"
- },
- "SecurityGroupIds": [
- {
- "Ref": "AppNameMopidySecutityGroup"
- }
- ],
- "SubnetId": {
- "Ref": "AppNameSubnet"
- },
- "Tags": [
- {
- "Key": "App",
- "Value": "Mopidy"
- }
- ],
- "UserData": {
- "Fn::Base64": {
- "Fn::Join": [
- "\n",
- [
- "#!/bin/bash -x\n",
- "\n",
- "exec > /tmp/boot.log 2>&1",
- "\n"
- ]
- ]
- }
- },
- "Volumes": [
- {
- "Device": "/dev/sda2",
- "VolumeId": {
- "Ref": "AppNameMopidyDisk"
- }
- }
- ]
- }
- }
- },
- "Outputs": {
- "LidarrIPAddress": {
- "Description": "IP address of your new Lidarr app",
- "Value": {
- "Ref": "ApNameLidarrEIP"
- }
- },
- "MopidyIPAddress": {
- "Description": "IP address of your new Mopidy app",
- "Value": {
- "Ref": "ApNameMopidyEIP"
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement