bash ./mover.sh
What the Script does?
- Retrieves the security group IDs, tags, and name of the source instance.
- Creates a new AMI from the source instance.
- Shares the new AMI with the target AWS account.
- Creates a new key pair in the target account.
- Launches a new instance in the target account using the shared AMI and the created key pair.
- Attaches the source instance's security groups to the new instance.
- Copies the source instance's tags to the new instance.
- Unshares the AMI with the source account.
- Deletes the AMI and its associated snapshots.
Note: This script assumes that the same security group names are used in both the source and target accounts. If a security group does not exist in the target account, the script will create it and copy the inbound rules from the source security group.