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:
- Please make sure you are using the latest Spotinst Policy
- Please make sure you cancel the auto-healing feature of OpsWorks.
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 AWSOpsWorksRegisterCLI and AWSOpsWorksRole.
- 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, select the IAM Role from the previous step and set the user data (startup script) with the following command to register your the instance with your desired stack.
Please note: For regional opsworks stacks, the elastigroup must be in the same region as the stack. Do not change the instances hostname, as we are using this to identify the instance in opsWorks.
Look for 'API endpoint region' parameter under 'advanced options' in OpsWorks. Put the stack type parameter as part of the following script. The possible values are either 'REGIONAL' or 'CLASSIC', according to your type.
#!/bin/bash curl -fsSL https://s3.amazonaws.com/spotinst-public/integrations/opsworks/spotinst_aws_opsworks_v5.sh | \
Note: Before using this user-data shell script, please set the following parameters:OPSWORKS_STACK_ID=”myStackID”OPSWORKS_LAYER_ID=”myLayerID”OPSWORKS_STACK_TYPE="myStackType"
Step 4: Register your Stack and Layer ID
- For regional opsworks stacks, the elastigroup must be in the same region as the stack. Do not change the instances hostname, as we are using this to identify the instance in opsWorks.
- Please verify you cancel the auto-healing feature of OpsWorks.