> For the complete documentation index, see [llms.txt](https://docs.projectreclass.org/infrastructure/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.projectreclass.org/infrastructure/aws-opsworks.md).

# AWS OpsWorks

How to configure AWS Ops Works

{% hint style="info" %}
Ensure ***any*** Instance you create is on the [approved list](https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os-linux.html) for AWS Ops Works&#x20;
{% endhint %}

## Register an Instance

Ensure your IAM user has the proper policy configuration to register an instance. This can be a preexisting instance. I performed the registration via command line so I needed the permission: `AWSOpsWorksRegisterCLI_EC2`&#x20;

Next, I ran the registration command:

```
$ aws opsworks register --use-instance-profile  \
--infrastructure-class ec2 \
 --region us-east-2  \
 --stack-id a08f26f4-4362-4f34-9d57-71492e210e43 \
 --ssh-username [username] \
 --ssh-private-key [private-key-path] i-0aa4b421d6fe86cb8
```

{% hint style="info" %}
When you register an instance through the AWS Ops Works console, a command will be created for you that will require some editing.&#x20;

I actually removed the `use-instance-profile` option to allow AWS Ops Works to create a new user for registration.
{% endhint %}

Once your instance is registered ensure your IAM user has been uploaded to the stack in the user section:&#x20;

![Import IAM User](https://3774373334-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MbNAC5C7H01i7puPRcA%2F-MduR8s7iKcmPxbm4vu9%2F-MduTgFunASePyw9XsLC%2FScreen%20Shot%202021-07-06%20at%201.21.22%20AM.png?alt=media\&token=60020773-0594-4300-83ef-f526a3ce599c)

From this page you can also edit your user, change the permissions to allow SSH access, as well as sudo permissions if necessary. Finally, you can upload your own public key to this user!

{% hint style="info" %}
You can change your public key as you wish, this makes it easy to quickly gain access and create new keys if necessary.&#x20;

Administrators should ensure proper offboarding to include deleting users not currently requiring access to AWS Ops Works. Access keys should also have lifetimes, and offboarded users should have their access keys and accounts deleted
{% endhint %}

### **Using an Instance Profile**

If you want to register your instance with the `use-instance-profile` argument in the command above, you must create an [instance profile](https://docs.aws.amazon.com/codedeploy/latest/userguide/getting-started-create-iam-instance-profile.html) as an IAM role and assign it to both the instance you are registering and the stack. (You can add it to a stack that already exists by editing its settings, or include this information in your new stack under "Default IAM Instance Profile".)

Ensure that the IAM role has permission to register an instance in Ops Works, and is the same for the instance and the stack. AWS Ops Works will use this profile for registration instead of creating a new one.
