By using AWS CLI, I am trying to create a clone of my OpsWorks stack at a specified DateTime.
In order to do so, I made sure I have the following :
- Hourly snapshots of my running EBS Backed OpsWorks instances.
- Point-In-Time RDS snapshots of my Databases
Everything RDS-related is working just fine, but I cannot seem to be able to attach an EC2 instance properly in OpsWorks.
At first, I tried to create an AMI from my snapshot, run it as an EC2 instance and then register it into my stack, which produced the following error :
[Thu, 12 Mar 2015 11:48:14 +0000] opsworks-init: Starting the installer Building native extensions. This could take a while... /tmp/opsworks-agent-installer.APUKk5gzWGKpIB4l/opsworks-agent-installer/opsworks-agent/lib/bootstrap/installer.rb:74:in
install_instance_agent': /opt/aws/opsworks/releases/20150210181912_33600020150210181912 already exists and is current - aborting. (RuntimeError) from /tmp/opsworks-agent-installer.APUKk5gzWGKpIB4l/opsworks-agent-installer/opsworks-agent/lib/bootstrap/instance_agent_registration_installer.rb:30:inblock in run' from /tmp/opsworks-agent-installer.APUKk5gzWGKpIB4l/opsworks-agent-installer/opsworks-agent/lib/bootstrap/log.rb:96:inmeasure' from /tmp/opsworks-agent-installer.APUKk5gzWGKpIB4l/opsworks-agent-installer/opsworks-agent/lib/bootstrap/instance_agent_registration_installer.rb:30:inrun' from /tmp/opsworks-agent-installer.APUKk5gzWGKpIB4l/opsworks-agent-installer/opsworks-agent/lib/bootstrap/instance_agent_registration_installer.rb:13:inrun' from /tmp/opsworks-agent-installer.APUKk5gzWGKpIB4l/opsworks-agent-installer/opsworks-agent/bin/opsworks-agent-registration-installer.rb:18:in' [Thu, 12 Mar 2015 11:50:08 +0000] opsworks-init: Agent installation failed. [Thu, 12 Mar 2015 11:50:08 +0000] opsworks-init: Please verify the log files found under /var/log/aws/opsworks and submit findings to AWS Support.
My second attempt was to create a volume with my snapshot and then replace the root device of my EC2 instance with it. It resulted in this :
A client error (IncorrectState) occurred when calling the DetachVolume operation: Unable to detach root volume [...]
Then, I thought I would test attaching a freshly created EC2 Instance using Amazon's Ubuntu LTS 14.04 AMI, which was not successful either :
Command '['ssh', '-tt', '', u'/bin/sh -c \'set -e\numask 007\nAGENT_TMP_DIR=$(mktemp -d /tmp/opsworks-agent-installer.XXXXXXXXXXXXXXXX)\ncurl --retry 5 -L https://opsworks-instance-agent.s3.amazonaws.com/33600020150210181912/opsworks-agent-installer.tgz | tar xz -C $AGENT_TMP_DIR\ncat >$AGENT_TMP_DIR/opsworks-agent-installer/preconfig <https://opsworks-instance-agent.s3.amazonaws.com"\n:agent_installer_tgz: "opsworks-agent-installer.tgz"\n:assets_download_bucket: "opsworks-instance-assets-us-east-1.s3.amazonaws.com"\n:charlie_public_key: "-----BEGIN PUBLIC KEY----------END PUBLIC KEY-----"\n:import: true\n:instance_service_endpoint: "opsworks-instance-service.us-east-1.amazonaws.com"\n:instance_service_port: "443"\n:instance_service_region: "us-east-1"\n:instance_service_ssl_verify_peer: "true"\n:instance_service_use_ssl: "true"\n:ops_works_endpoint: "opsworks.us-east-1.amazonaws.com"\n:ops_works_port: "443"\n:ops_works_region: "us-east-1"\n:ops_works_ssl_verify_peer: "true"\n:ops_works_use_ssl: "true"\n:secret_access_key: "YCsdiyHlR9zwUO7WvQrr3xNPIQqL89XcgmgIUC7h"\n:stack_id: "54bc78bc-d9bd-469a-ae31-2fae7e43762e"\n:verbose: "false"\n:wait_between_runs: "60"\nEOF\nexec sudo /bin/sh -c "OPSWORKS_ASSETS_DOWNLOAD_BUCKET=opsworks-instance-assets-us-east-1.s3.amazonaws.com $AGENT_TMP_DIR/opsworks-agent-installer/boot-registration; rm -rf $AGENT_TMP_DIR"\n\'']' returned non-zero exit status 255
It seems like I run into some problems when attempting to install the OpsWorks agents on the machine.
What is the best way to register a clone of a running EBS Backed Opsworks stack in a completely new stack by using AWS CLI ?
Thank you !