{"id":19872069,"url":"https://github.com/saltstack-formulas/ec2-autoscale-reactor","last_synced_at":"2025-05-02T09:30:57.491Z","repository":{"id":16818864,"uuid":"19578027","full_name":"saltstack-formulas/ec2-autoscale-reactor","owner":"saltstack-formulas","description":"Autonomous Minion Management via EC2 Autoscaler","archived":false,"fork":false,"pushed_at":"2016-11-30T21:07:46.000Z","size":154,"stargazers_count":76,"open_issues_count":12,"forks_count":28,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-04-07T00:41:47.399Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html","language":"SaltStack","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saltstack-formulas.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-08T15:14:20.000Z","updated_at":"2024-11-28T16:29:17.000Z","dependencies_parsed_at":"2022-08-25T14:40:44.717Z","dependency_job_id":null,"html_url":"https://github.com/saltstack-formulas/ec2-autoscale-reactor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fec2-autoscale-reactor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fec2-autoscale-reactor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fec2-autoscale-reactor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fec2-autoscale-reactor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saltstack-formulas","download_url":"https://codeload.github.com/saltstack-formulas/ec2-autoscale-reactor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252015765,"owners_count":21680821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T16:14:25.598Z","updated_at":"2025-05-02T09:30:57.131Z","avatar_url":"https://github.com/saltstack-formulas.png","language":"SaltStack","funding_links":[],"categories":[],"sub_categories":[],"readme":"ec2-autoscale-reactor\n=====================\n\nThis is a reactor formula, which allows the autoscaling feature in EC2 to\nnotify Salt when an instance is created, so that it may be automatically\nbootstrapped and accepted by the Salt Master, or when an instance is deleted,\nso that its key can be automatically removed from the Salt Master.\n\n\nDependencies\n------------\nThe following packages must be installed:\n\n.. code-block:: yaml\n\n    - Salt (develop branch)\n\n\nMaster Configuration\n--------------------\nThe following files need to be configured on the Salt Master:\n\n.. code-block:: yaml\n\n    - /etc/salt/master\n    - /etc/salt/cloud.providers.d/ec2.conf\n    - /srv/reactor/ec2-autoscale.sls (from this package)\n\n/etc/salt/master\n~~~~~~~~~~~~~~~~\nThis reactor makes use of the web hooks system introduced in Salt API 0.8.4.\nThe configuration for Salt API is stored in the master configuration file:\n\n.. code-block:: yaml\n\n    external_auth:\n      pam:\n        myuser:\n          - .*\n          - '@runner'\n          - '@wheel'\n    \n    rest_cherrypy:\n      port: 8080\n      host: 0.0.0.0\n      webhook_url: /hook\n      webhook_disable_auth: True\n\nWhen a web request is received, Salt API will fire an event for the reactor\nsystem to pick up:\n\n.. code-block:: yaml\n\n    reactor:\n      - 'salt/netapi/hook/ec2/autoscale':\n        - '/srv/reactor/ec2-autoscale.sls'\n\nThis reactor will examine the web hook received from EC2 and check its\nauthenticity. If issues are encountered, such as an invalid signature, or the\ncertificates being located outside of Amazon, a notification will be sent to\nthe user via email. The following settings are an example of SMTP settings that\nmight be used to connect to the mail server:\n\n.. code-block:: yaml\n\n    smtp.from: 'salt-master@example.com'\n    smtp.to: admin1@example.com.com; admin2@example.com.com\n    smtp.host: smtp.gmail.com\n    smtp.username: 'salt-master@example.com'\n    smtp.password: 'verybadpass'\n    smtp.tls: True\n    smtp.subject: 'Salt'\n\n.. code-block:: yaml\n\nFinally, some extra settings must be set up to point the reactor to the\nnecessary Salt Cloud provider setting. Any additional settings to be used on\nthe target minion, that are not configured in the provider configuration, can\nalso be set here.\n\n.. code-block:: yaml\n\n    ec2.autoscale:\n      provider: my-ec2-config\n      ssh_username: ec2-user\n\n/etc/salt/cloud.providers.d/ec2.conf\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nExisting Salt Cloud provider configuration can be used with this reactor.\nProfile configuration is not necessary on the master; minions will be\nconfigured as per the EC2 Autoscaling Group.\n\n.. code-block:: yaml\n\n    my-ec2-config:\n      id: \u003caws id\u003e\n      key: \u003caws key\u003e\n      keyname: \u003cmy key name\u003e\n      securitygroup: \u003cmy security group\u003e\n      private_key: \u003c/path/to/my/priv_key.pem\u003e\n      location: us-east-1\n      provider: ec2\n      minion:\n        master: saltmaster.example.com\n\n\n/srv/reactor/ec2-autoscale.sls\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nThis package includes a file in its ``reactor/`` directory called\n``ec2-autoscale.sls``. Create the ``/src/reactor/`` directory on the Salt\nMaster if it doesn't already exist, and copy this file into it.\n\n\nEC2 Configuration\n-----------------\nThe following must be configured in the EC2 account to be used:\n\n.. code-block:: yaml\n\n    - SNS HTTP Notification\n    - Launch Configuration\n    - Autoscaling Group\n\n\nSNS HTTP(S) Notification\n~~~~~~~~~~~~~~~~~~~~~~~~\nIn order to notify the reactor that an instance is being autoscaled up or down,\nAWS SNS must be configured with the URL to send the notification webhook to.\nBoth HTTP and HTTPS are available, but it is highly recommended that HTTPS is\nused.\n\nFrom the AWS Console, select SNS (Push Notification Service). This will take\nyou to the SNS dashboard.\n\nClick the button to Create New Topic. Enter a Topic Name, and a human-readable\nDisplay Name, and select the Create Topic button. This will take you to the\nTopic Details area.\n\nInside the Topic Details, click the button to Create Subscription. Select HTTP\nor HTTPS as appropriate, and enter the URL to your Salt API server as the\nendpoint. Assuming it is set up at ``https://saltmaster.example.com/``, the\nendpoint will look like:\n\n.. code-block:: yaml\n\n    https://saltmaster.example.com/hook/ec2/autoscale\n\nIn this URL, ``/hook`` notifies Salt API that a webhook is being used, and\n``/ec2/autoscale`` will be used to tag the event that the reactor uses to\nprocess it. The tag that will be created by this URL will be\n\n.. code-block:: yaml\n\n    salt/netapi/hook/ec2/autoscale\n\nClicking the Subscribe button will cause a subscription notification to be sent\nimmediately to the endpoint. If the Master configuration is correct, the\nreactor will forward the subscription notication to the configured email\naddress(es). This message will contain a subscribe URL which, when visited,\nwill activate the Subscription.\n\nIf the Salt Master is not properly configured, the endpoint can be re-entered,\nand another subscription notifcation will be sent. It should be noted that once\nconfigured, a subscription may not be deleted via the web interface until the\nsubscribe URL has been visited and confirmed.\n\n\nLaunch Configuration\n~~~~~~~~~~~~~~~~~~~~\nIn order to start autoscaling instances, EC2 requires a launch configuration to\nbe set. This defines the EC2-specific variables (AMI, disks, etc.) that will be\nused to spin up new instances.\n\nFrom the AWS Console, select EC2 (Virtual Servers in the Cloud), which will\nlead to the EC2 Management Console. From there, select Launch Configurations\nfrom the left-hand menu.\n\nClick the Create Launch Configuration button. Follow the wizard to select the\nappropriate AMI and configuration to use. At the Review screen, click the\nCreate Launch Configuration button to save.\n\n\nAutoscaling Group\n~~~~~~~~~~~~~~~~~\nOnce a launch configuration is defined, an autoscaling group may be configured\nwhich defines variables such as the minimum and maximum number of instances,\nand under what circumstances to add and remove instances.\n\nFrom the AWS Console, select Auto Scaling Groups from the left-hand menu. Click\nthe Create Auto Scaling Group button. Select the option to \"Create an Auto\nScaling group from an existing launch configuration\". Select the Launch\nConfiguration, and click Next Step.\n\nFollow the wizard to the \"Configure Notifications\" screen. Click the \"Add\nNotification\" button and select the notification that was configured on SNS.\nComplete the wizard as normal.\n\n\nBasic Usage\n-----------\nOnce the Salt Master and AWS have been configured, the reactor will manage\nitself. When the autoscaler adds a new instance, Salt Cloud will be notified to\nwait for it to become available, and bootstrap it with Salt. Its key will be\nautomatically accepted, and if the minion configuration includes the appropriate\nstartup state, then the minion will configure itself, and go to work.\n\nWhen the autoscaler spins down a machine, the Wheel system inside of Salt will\nbe notified to delete its key from the master. This causes instances to be\ncompletely autonomous, both in setup and tear-down.\n\nCaveats\n-------\nAs instances will be launched and destroyed automatically by EC2, they will not\nhave the opportunity to be configured with user-definable names, and will\ntherefore be identified to the master by their ``instance-id``. In the event\nthat more detailed identifying information needs to be available, the instances\nshould be configured to include EC2 tags, which can later be read and displayed\nto the user via Salt Cloud.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaltstack-formulas%2Fec2-autoscale-reactor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaltstack-formulas%2Fec2-autoscale-reactor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaltstack-formulas%2Fec2-autoscale-reactor/lists"}