Advertisement
Guest User

Untitled

a guest
Jun 8th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 19.78 KB | None | 0 0
  1. {
  2.     "AWSTemplateFormatVersion": "2010-09-09",
  3.     "Mappings": {
  4.         "RegionMap": {
  5.             "us-east-1": {
  6.                 "lidarr": "ami-024a64a6685d05041",
  7.                 "mopidy": "ami-024a64a6685d05041"
  8.             }
  9.         }
  10.     },
  11.     "Parameters": {
  12.         "LidarrInstanceType": {
  13.             "Type": "String",
  14.             "Default": "t2.micro",
  15.             "AllowedValues": [
  16.                 "t2.micro",
  17.                 "m1.small",
  18.                 "m1.large"
  19.             ],
  20.             "Description": "Choose the instance on which Lidarr will run. Default is t2.micro."
  21.         },
  22.         "MopidyInstanceType": {
  23.             "Type": "String",
  24.             "Default": "t2.micro",
  25.             "AllowedValues": [
  26.                 "t2.micro",
  27.                 "m1.small",
  28.                 "m1.large"
  29.             ],
  30.             "Description": "Choose the instance on which Mopidy will run. Default is t2.micro."
  31.         },
  32.         "KeyPairForInstances": {
  33.             "Type": "AWS::EC2::KeyPair::KeyName",
  34.             "Description": "Keys to upload to the EC2 instances."
  35.         }
  36.     },
  37.     "Resources": {
  38.         "AppNameRouteTable": {
  39.             "Type": "AWS::EC2::RouteTable",
  40.             "Properties": {
  41.                 "VpcId": {
  42.                     "Ref": "AppNameVPC"
  43.                 }
  44.             }
  45.         },
  46.         "AppNameRouteTableAssociation": {
  47.             "Type": "AWS::EC2::SubnetRouteTableAssociation",
  48.             "Properties": {
  49.                 "RouteTableId": {
  50.                     "Ref": "AppNameRouteTable"
  51.                 },
  52.                 "SubnetId": {
  53.                     "Ref": "AppNameSubnet"
  54.                 }
  55.             }
  56.         },
  57.         "AppNameRoute": {
  58.             "Type": "AWS::EC2::Route",
  59.             "Properties": {
  60.                 "DestinationCidrBlock": "0.0.0.0/0",
  61.                 "GatewayId": {
  62.                     "Ref": "AppNameInternetGateway"
  63.                 },
  64.                 "RouteTableId": {
  65.                     "Ref": "AppNameRouteTable"
  66.                 }
  67.             }
  68.         },
  69.         "AppNameVPCGatewayAtachment": {
  70.             "Type": "AWS::EC2::VPCGatewayAttachment",
  71.             "Properties": {
  72.                 "InternetGatewayId": {
  73.                     "Ref": "AppNameInternetGateway"
  74.                 },
  75.                 "VpcId": {
  76.                     "Ref": "AppNameVPC"
  77.                 }
  78.             }
  79.         },
  80.         "AppNameInternetGateway": {
  81.             "Type": "AWS::EC2::InternetGateway",
  82.             "Properties": {}
  83.         },
  84.         "ApNameLidarrEIP": {
  85.             "Type": "AWS::EC2::EIP",
  86.             "Properties": {
  87.                 "InstanceId": {
  88.                     "Ref": "AppNameLidarrVM"
  89.                 }
  90.             }
  91.         },
  92.         "ApNameMopidyEIP": {
  93.             "Type": "AWS::EC2::EIP",
  94.             "Properties": {
  95.                 "InstanceId": {
  96.                     "Ref": "AppNameMopidyVM"
  97.                 }
  98.             }
  99.         },
  100.         "AppNameLidarrRole": {
  101.             "Type": "AWS::IAM::Role",
  102.             "Properties": {
  103.                 "AssumeRolePolicyDocument": {
  104.                     "Version": "2012-10-17",
  105.                     "Statement": [
  106.                         {
  107.                             "Effect": "Allow",
  108.                             "Principal": {
  109.                                 "Service": [
  110.                                     "ec2.amazonaws.com"
  111.                                 ]
  112.                             },
  113.                             "Action": [
  114.                                 "sts:AssumeRole"
  115.                             ]
  116.                         }
  117.                     ]
  118.                 },
  119.                 "Path": "/",
  120.                 "Policies": [
  121.                     {
  122.                         "PolicyName": "root",
  123.                         "PolicyDocument": {
  124.                             "Version": "2012-10-17",
  125.                             "Statement": [
  126.                                 {
  127.                                     "Effect": "Allow",
  128.                                     "Action": "*",
  129.                                     "Resource": "*"
  130.                                 }
  131.                             ]
  132.                         }
  133.                     }
  134.                 ],
  135.                 "RoleName": {
  136.                     "Fn::Join": [
  137.                         "-",
  138.                         [
  139.                             "AppNameLidarrRole",
  140.                             {
  141.                                 "Ref": "AWS::Region"
  142.                             }
  143.                         ]
  144.                     ]
  145.                 }
  146.             }
  147.         },
  148.         "AppNameLidarrProfile": {
  149.             "Type": "AWS::IAM::InstanceProfile",
  150.             "Properties": {
  151.                 "Path": "/",
  152.                 "Roles": [
  153.                     {
  154.                         "Ref": "AppNameLidarrRole"
  155.                     }
  156.                 ]
  157.             }
  158.         },
  159.         "AppNameMopidyRole": {
  160.             "Type": "AWS::IAM::Role",
  161.             "Properties": {
  162.                 "AssumeRolePolicyDocument": {
  163.                     "Version": "2012-10-17",
  164.                     "Statement": [
  165.                         {
  166.                             "Effect": "Allow",
  167.                             "Principal": {
  168.                                 "Service": [
  169.                                     "ec2.amazonaws.com"
  170.                                 ]
  171.                             },
  172.                             "Action": [
  173.                                 "sts:AssumeRole"
  174.                             ]
  175.                         }
  176.                     ]
  177.                 },
  178.                 "Path": "/",
  179.                 "Policies": [
  180.                     {
  181.                         "PolicyName": "root",
  182.                         "PolicyDocument": {
  183.                             "Version": "2012-10-17",
  184.                             "Statement": [
  185.                                 {
  186.                                     "Effect": "Allow",
  187.                                     "Action": "*",
  188.                                     "Resource": "*"
  189.                                 }
  190.                             ]
  191.                         }
  192.                     }
  193.                 ],
  194.                 "RoleName": {
  195.                     "Fn::Join": [
  196.                         "-",
  197.                         [
  198.                             "AppNameMopidyRole",
  199.                             {
  200.                                 "Ref": "AWS::Region"
  201.                             }
  202.                         ]
  203.                     ]
  204.                 }
  205.             }
  206.         },
  207.         "AppNameMopidyProfile": {
  208.             "Type": "AWS::IAM::InstanceProfile",
  209.             "Properties": {
  210.                 "Path": "/",
  211.                 "Roles": [
  212.                     {
  213.                         "Ref": "AppNameMopidyRole"
  214.                     }
  215.                 ]
  216.             }
  217.         },
  218.         "AppNameLidarrDisk": {
  219.             "Type": "AWS::EC2::Volume",
  220.             "Properties": {
  221.                 "AvailabilityZone": {
  222.                     "Fn::Join": [
  223.                         "",
  224.                         [
  225.                             {
  226.                                 "Ref": "AWS::Region"
  227.                             },
  228.                             "a"
  229.                         ]
  230.                     ]
  231.                 },
  232.                 "Size": 4,
  233.                 "Tags": [
  234.                     {
  235.                         "Key": "App",
  236.                         "Value": "Lidarr"
  237.                     }
  238.                 ],
  239.                 "VolumeType": "gp2"
  240.             }
  241.         },
  242.         "AppNameMopidyDisk": {
  243.             "Type": "AWS::EC2::Volume",
  244.             "Properties": {
  245.                 "AvailabilityZone": {
  246.                     "Fn::Join": [
  247.                         "",
  248.                         [
  249.                             {
  250.                                 "Ref": "AWS::Region"
  251.                             },
  252.                             "a"
  253.                         ]
  254.                     ]
  255.                 },
  256.                 "Size": 4,
  257.                 "Tags": [
  258.                     {
  259.                         "Key": "App",
  260.                         "Value": "Mopidy"
  261.                     }
  262.                 ],
  263.                 "VolumeType": "gp2"
  264.             }
  265.         },
  266.         "AppNameSubnet": {
  267.             "Type": "AWS::EC2::Subnet",
  268.             "Properties": {
  269.                 "VpcId": {
  270.                     "Ref": "AppNameVPC"
  271.                 },
  272.                 "AvailabilityZone": {
  273.                     "Fn::Join": [
  274.                         "",
  275.                         [
  276.                             {
  277.                                 "Ref": "AWS::Region"
  278.                             },
  279.                             "a"
  280.                         ]
  281.                     ]
  282.                 },
  283.                 "CidrBlock": "10.0.1.0/24"
  284.             }
  285.         },
  286.         "AppNameVPC": {
  287.             "Type": "AWS::EC2::VPC",
  288.             "Properties": {
  289.                 "CidrBlock": "10.0.0.0/16",
  290.                 "InstanceTenancy": "default"
  291.             }
  292.         },
  293.         "AppNameLidarrSecutityGroup": {
  294.             "Type": "AWS::EC2::SecurityGroup",
  295.             "Properties": {
  296.                 "GroupName": "App Name Lidarr Secutity Group",
  297.                 "GroupDescription": "Define security rules to ensure the EC2 hosting Lidarr is wich with no extra permissions that in need",
  298.                 "SecurityGroupEgress": [
  299.                     {
  300.                         "CidrIp": "0.0.0.0/0",
  301.                         "Description": "Allow all traffic",
  302.                         "FromPort": 0,
  303.                         "IpProtocol": "tcp",
  304.                         "ToPort": 65535
  305.                     }
  306.                 ],
  307.                 "SecurityGroupIngress": [
  308.                     {
  309.                         "CidrIp": "0.0.0.0/0",
  310.                         "Description": "Allow all traffic",
  311.                         "FromPort": 0,
  312.                         "IpProtocol": "tcp",
  313.                         "ToPort": 65535
  314.                     }
  315.                 ],
  316.                 "Tags": [
  317.                     {
  318.                         "Key": "App",
  319.                         "Value": "Lidarr"
  320.                     }
  321.                 ],
  322.                 "VpcId": {
  323.                     "Ref": "AppNameVPC"
  324.                 }
  325.             }
  326.         },
  327.         "AppNameMopidySecutityGroup": {
  328.             "Type": "AWS::EC2::SecurityGroup",
  329.             "Properties": {
  330.                 "GroupName": "App Name Mopidy Secutity Group",
  331.                 "GroupDescription": "Define security rules to ensure the EC2 hosting Mopidy is wich with no extra permissions that in need",
  332.                 "SecurityGroupEgress": [
  333.                     {
  334.                         "CidrIp": "0.0.0.0/0",
  335.                         "Description": "Allow all traffic",
  336.                         "FromPort": 0,
  337.                         "IpProtocol": "tcp",
  338.                         "ToPort": 65535
  339.                     }
  340.                 ],
  341.                 "SecurityGroupIngress": [
  342.                     {
  343.                         "CidrIp": "0.0.0.0/0",
  344.                         "Description": "Allow all traffic",
  345.                         "FromPort": 0,
  346.                         "IpProtocol": "tcp",
  347.                         "ToPort": 65535
  348.                     }
  349.                 ],
  350.                 "Tags": [
  351.                     {
  352.                         "Key": "App",
  353.                         "Value": "Mopidy"
  354.                     }
  355.                 ],
  356.                 "VpcId": {
  357.                     "Ref": "AppNameVPC"
  358.                 }
  359.             }
  360.         },
  361.         "AppNameLidarrVM": {
  362.             "Type": "AWS::EC2::Instance",
  363.             "Properties": {
  364.                 "AvailabilityZone": {
  365.                     "Fn::Join": [
  366.                         "",
  367.                         [
  368.                             {
  369.                                 "Ref": "AWS::Region"
  370.                             },
  371.                             "a"
  372.                         ]
  373.                     ]
  374.                 },
  375.                 "IamInstanceProfile": {
  376.                     "Ref": "AppNameLidarrProfile"
  377.                 },
  378.                 "ImageId": {
  379.                     "Fn::FindInMap": [
  380.                         "RegionMap",
  381.                         {
  382.                             "Ref": "AWS::Region"
  383.                         },
  384.                         "lidarr"
  385.                     ]
  386.                 },
  387.                 "InstanceType": {
  388.                     "Ref": "LidarrInstanceType"
  389.                 },
  390.                 "KeyName": {
  391.                     "Ref": "KeyPairForInstances"
  392.                 },
  393.                 "SecurityGroupIds": [
  394.                     {
  395.                         "Ref": "AppNameLidarrSecutityGroup"
  396.                     }
  397.                 ],
  398.                 "SubnetId": {
  399.                     "Ref": "AppNameSubnet"
  400.                 },
  401.                 "Tags": [
  402.                     {
  403.                         "Key": "App",
  404.                         "Value": "Lidarr"
  405.                     }
  406.                 ],
  407.                 "UserData": {
  408.                     "Fn::Base64": {
  409.                         "Fn::Join": [
  410.                             "\n",
  411.                             [
  412.                                 "#!/bin/bash -x\n",
  413.                                 "\n",
  414.                                 "exec > /tmp/boot.log 2>&1",
  415.                                 "\n",
  416.                                 "# Add the Mono repository to your system\n",
  417.                                 "apt install gnupg ca-certificates\n",
  418.                                 "apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF\n",
  419.                                 "echo \"deb https://download.mono-project.com/repo/ubuntu stable-bionic main\" | tee /etc/apt/sources.list.d/mono-official-stable.lis\n",
  420.                                 "apt update\n",
  421.                                 "\n",
  422.                                 "\n",
  423.                                 "# Install Mono\n",
  424.                                 "apt install mono-devel\n",
  425.                                 "\n",
  426.                                 "\n",
  427.                                 "# Install Lidarr\n",
  428.                                 "cd /opt\n",
  429.                                 "wget https://github.com/lidarr/Lidarr/releases/download/v0.5.0.583/Lidarr.develop.0.5.0.583.linux.tar.gz\n",
  430.                                 "tar -xzvf Lidarr.develop.0.5.0.583.linux.tar.gz\n",
  431.                                 "rm Lidarr.develop.0.5.0.583.linux.tar.gz\n",
  432.                                 "\n",
  433.                                 "\n",
  434.                                 "# Auto start Lidarr\n",
  435.                                 "useradd -s /bin/false -d /var/lib/lidarr/ -r -m -U lidarr\n",
  436.                                 "chown -R lidarr:lidarr   /opt/Lidarr\n",
  437.                                 "chmod -R a=,a+X,u+rw,g+r /opt/Lidarr\n",
  438.                                 "\n",
  439.                                 "touch /etc/systemd/system/lidarr.service\n",
  440.                                 "echo \"[Unit]\" > /etc/systemd/system/lidarr.service\n",
  441.                                 "echo \"Description=Lidarr Daemon\" >> /etc/systemd/system/lidarr.service\n",
  442.                                 "echo \"After=network.target\" >> /etc/systemd/system/lidarr.service\n",
  443.                                 "echo \"\" >> /etc/systemd/system/lidarr.service\n",
  444.                                 "echo \"[Service]\" >> /etc/systemd/system/lidarr.service\n",
  445.                                 "echo \"User=lidarr\" >> /etc/systemd/system/lidarr.service\n",
  446.                                 "echo \"Group=lidarr\" >> /etc/systemd/system/lidarr.service\n",
  447.                                 "echo \"Type=simple\" >> /etc/systemd/system/lidarr.service\n",
  448.                                 "echo \"ExecStart=/usr/bin/mono /opt/Lidarr/Lidarr.exe -nobrowser\" >> /etc/systemd/system/lidarr.service\n",
  449.                                 "echo \"TimeoutStopSec=20\" >> /etc/systemd/system/lidarr.service\n",
  450.                                 "echo \"KillMode=process\" >> /etc/systemd/system/lidarr.service\n",
  451.                                 "echo \"Restart=on-failure\" >> /etc/systemd/system/lidarr.service\n",
  452.                                 "echo \"\" >> /etc/systemd/system/lidarr.service\n",
  453.                                 "echo \"[Install]\" >> /etc/systemd/system/lidarr.service\n",
  454.                                 "echo \"WantedBy=multi-user.target\" >> /etc/systemd/system/lidarr.service\n",
  455.                                 "\n",
  456.                                 "systemctl enable lidarr.service\n",
  457.                                 "systemctl start lidarr.service\n"
  458.                             ]
  459.                         ]
  460.                     }
  461.                 },
  462.                 "Volumes": [
  463.                     {
  464.                         "Device": "/dev/sda2",
  465.                         "VolumeId": {
  466.                             "Ref": "AppNameLidarrDisk"
  467.                         }
  468.                     }
  469.                 ]
  470.             }
  471.         },
  472.         "AppNameMopidyVM": {
  473.             "Type": "AWS::EC2::Instance",
  474.             "Properties": {
  475.                 "AvailabilityZone": {
  476.                     "Fn::Join": [
  477.                         "",
  478.                         [
  479.                             {
  480.                                 "Ref": "AWS::Region"
  481.                             },
  482.                             "a"
  483.                         ]
  484.                     ]
  485.                 },
  486.                 "IamInstanceProfile": {
  487.                     "Ref": "AppNameMopidyProfile"
  488.                 },
  489.                 "ImageId": {
  490.                     "Fn::FindInMap": [
  491.                         "RegionMap",
  492.                         {
  493.                             "Ref": "AWS::Region"
  494.                         },
  495.                         "mopidy"
  496.                     ]
  497.                 },
  498.                 "InstanceType": {
  499.                     "Ref": "MopidyInstanceType"
  500.                 },
  501.                 "KeyName": {
  502.                     "Ref": "KeyPairForInstances"
  503.                 },
  504.                 "SecurityGroupIds": [
  505.                     {
  506.                         "Ref": "AppNameMopidySecutityGroup"
  507.                     }
  508.                 ],
  509.                 "SubnetId": {
  510.                     "Ref": "AppNameSubnet"
  511.                 },
  512.                 "Tags": [
  513.                     {
  514.                         "Key": "App",
  515.                         "Value": "Mopidy"
  516.                     }
  517.                 ],
  518.                 "UserData": {
  519.                     "Fn::Base64": {
  520.                         "Fn::Join": [
  521.                             "\n",
  522.                             [
  523.                                 "#!/bin/bash -x\n",
  524.                                 "\n",
  525.                                 "exec > /tmp/boot.log 2>&1",
  526.                                 "\n"
  527.                             ]
  528.                         ]
  529.                     }
  530.                 },
  531.                 "Volumes": [
  532.                     {
  533.                         "Device": "/dev/sda2",
  534.                         "VolumeId": {
  535.                             "Ref": "AppNameMopidyDisk"
  536.                         }
  537.                     }
  538.                 ]
  539.             }
  540.         }
  541.     },
  542.     "Outputs": {
  543.         "LidarrIPAddress": {
  544.             "Description": "IP address of your new Lidarr app",
  545.             "Value": {
  546.                 "Ref": "ApNameLidarrEIP"
  547.             }
  548.         },
  549.         "MopidyIPAddress": {
  550.             "Description": "IP address of your new Mopidy app",
  551.             "Value": {
  552.                 "Ref": "ApNameMopidyEIP"
  553.             }
  554.         }
  555.     }
  556. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement