is now a part of Cisco. Learn More

About Cisco

Moving OpsWorks Layer to CMPUTE

Steps to move your OpsWorks layer:

Create an instance profile associated with the following permissions.

Open the IAM console, choose Roles, and then choose Create New Role. Type a name for the role, and then choose Next Step. Choose the Amazon EC2 Role, and then select the check box next to the AWSOpsWorksInstanceRegistration policy. Finally, choose Next Step, and then choose Create Role. As the name suggests, the AWSOpsWorksInstanceRegistration policy only allows the API calls required to register an instance. Because you will have to make two more calls for this demo, add the following inline policy to the new role.


                    "Version": "2012-10-17",

                    "Statement": [


                            "Effect": "Allow",

                            "Action": [




                            "Resource": [






Use the following userdata script

Please use the script specified below in your userdata script. It will register and assign the instance to a opswork layer.

  • Replace the YOUR-OPSWORKS-STACK-ID with your opsworks stack id

  • Replace the YOUR-OPSWORKS-LAYER-ID with your opsworks layer id

You can find these id’s in the opsworks dashboard in your AWS management console.


    sed -i'' -e 's/.*requiretty.*//' /etc/sudoers

    pip install --upgrade awscli

    INSTANCE_ID=$(/usr/bin/aws opsworks register --use-instance-profile --infrastructure-class ec2 --region us-east-1 --stack-id YOUR-OPSWORKS-STACK-ID --override-hostname $(tr -cd 'a-z' < /dev/urandom |head -c8) --local 2>&1 |grep -o 'Instance ID: .*' |cut -d' ' -f3)

    /usr/bin/aws opsworks wait instance-registered --region us-east-1 --instance-id $INSTANCE_ID
  • In cmpute ,if you are using a Custom AMI app. Please follow the steps mentioned here to setup the Custom AMI job -

  • For an Autoscaling group, Create an Autoscaling group in EC2 with the same set of attributes (VPC, subnets, security group, ELB, keypair, instance profile) of the Opswork layer. Use the instance profile and the userdata script specified in steps 1 and 2.

After creating the autoscaling group, please follow the steps mentioned here to setup the Autoscaling job -