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.
Before getting started:
How to configure?
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 Rule 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 and AWSOpsWorksInstanceRegistration.
- 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.
- Create an Elastigroup - Creating your first Elastigroup
- Select the IAM Role from the previous step - Advanced setting - Compute Tab
Expand the "Integrations" portion in the Compute tab, select the OpsWork integration, add it and select the Stack type, Stack ID and Layer ID for your environmentUse the Copy feature in order to copy the required user data from there:
4. Paste the user data script in the User Data section under Additional Configuration
It should look like the following template:
#!/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. failiure to do so will cause the creation of new instnaces by OpsWorks once an Elastigroup terminates an instance (For scale down for example)
- The AMI used in the Elastigorup should have Python installed (part of OpsWorks requirements)