Integrate Elastigroup with Your OpsWorks Stack in 3 Easy Steps
AWS OpsWorks is a configuration management service that uses Chef, an automation platform that treats server configurations as code. OpsWorks uses Chef to automate how servers are configured, deployed and managed across your instances. You can easily associate your Elastigroup instances with your OpsWorks stack and layers with this simple three steps guide.
Step 1: Choose your AWS OpsWorks Stack
To get started, you need an OpsWorks Stack, Go to AWS OpsWorks console and have your desired stack-id for the next steps.
Step 2: Configure IAM Role for OpsWorks
In order to register your Spot instances into OpsWorks, you need to create an IAM role first and associate it with your Elastigroup.
- Sign in to the AWS Management Console and open the IAM console.
- In the navigation pane of the console, click Roles and search for aws-opsworks-ec2-role.
- Click on the role name, and then in the Permissions tab click on “Attach Policy“.
- Search for the policies AWSOpsWorksCMServiceRole, AWSOpsWorksInstanceRegistration and AWSOpsWorksRegisterCLI.
- Click on the policies to select them and then click “Attach Policy“.
Step 3: Create your Elastigroup with IAM Role and a custom startup-script
Once you have configured the IAM role, your Instances can perform operations and attach themselves to any OpsWorks stack.
- Launch the Elastigroup Creation Wizard: Creating your first Elastigroup
- In the Compute tab under Advanced Configurations, select the IAM Role from the previous step.
- Under Integrations in the Compute tab, select the OpsWork integration, add it and set the
Layer IDfor your environment.
Once configured Elastigroup will retrieve the user data. Use the Copy feature to copy the user data from there:
4. Paste the user data script in the User Data section under Additional Configuration. See the example template below:
#!/bin/bash curl -fsSL https://s3.amazonaws.com/spotinst-public/integrations/opsworks/spotinst_aws_opsworks_v5.sh | \ OPSWORKS_STACK_TYPE="myStackType" \ OPSWORKS_STACK_ID="myStackID" \ OPSWORKS_LAYER_ID="myLayerID" \ bash
Set the following parameters in the user data script:
OPSWORKS_STACK_ID – The OpsWorks provided Stack ID – ”myStackID”
OPSWORKS_LAYER_ID – The OpsWorks provided Layer ID – ”myLayerID”
OPSWORKS_STACK_TYPE- The OpsWorks stack type. This information can be found via ‘API endpoint region’ parameter under ‘advanced options’ in OpsWorks. The possible values are ‘REGIONAL’ or ‘CLASSIC’.
- For regional opsworks stacks, the Elastigroup must be in the same region as the stack.
- Do not change the instances hostname, as it is used to identify the instance in OpsWorks.
- Please verify you cancel the auto-healing feature of OpsWorks. failure to do so will cause the creation of new instances by OpsWorks once an Elastigroup terminates an instance (For scale down for example)
- The AMI used in the Elastigroup should have Python installed (part of OpsWorks requirements)