Setting Up Chef Automate on AWS

Navigate to the URL https://console.aws.amazon.com/opsworks/cm/home#/chef/ 
and select Create Chef Automate Server

Step 1: 
- Now select the region and enter the Chef Server Automate Instance (server) name and 
- Select the Instance type too.
Step 2: Select an SSH Key
No room to create a new key (either you select you don’t want to connect using SSH or you select an existing SSH key).
Step 3: Select the right VPC, Subnet, associate the right EIP, security group. 
- Create a service role if non-exists at the moment

“AWS OpsWorks for Chef Automate needs your permission to create an IAM service role that allows us to perform actions in AWS CloudFormation, Amazon EC2, Amazon EC2 Simple Systems Manager, and Amazon S3. By continuing, you are allowing us to create a new role to work with these services.” Create an Instance Profile

“AWS OpsWorks for Chef Automate needs your permission to create an instance profile that allows us to perform actions in Amazon S3, and communicate with a Chef server by using Amazon EC2 Simple Systems Manager (SSM). By continuing, you are allowing us to create a new role to work with these services”

Select your maintenance Windows  to allow AWS OpsWork to install Updates for Chef Automate minor versions or security packages.

Note: Weekends are always better to have this performed. (select whatsoever time suits you).

For AWS OpsWorks Backup: AWS OpsWorks supports two ways to back up your Chef Automate server: manual or automated. Backups are uploaded to your Amazon S3 bucket. If you ever need to restore your Chef Automate server, you can restore it by applying a backup that you choose.

When you choose yes to Enable automated backup, these options below are available

Number of generations to keep: 30 is usually okay but this depends on your organisation policy.

Step 4: Review and Launch: open its Properties page in the AWS OpsWorks for Chef Automate console. The page below will be prompted to show the progress bar of the AWS OpsWork for Chef Automate creation,

Note: Make sure you download the following before your server is online. The download buttons are not available after a new server is online.

Finally, this message will appear on the dashboard stating your Chef Automate Server is successfully launched

Note: The created role will appear in the IAM section under roles as shown below

Now Access he URL (dashboard) of Chef Automate and perform all necessary configurations etc. as shown below

Note: Ensure you have the ChefDK downloaded and Installed on your local PC from  https://downloads.chef.io/chefdk

Otherwise, you cannot work with Chef Automate with Windows 10 . See how to install ChefDk on Windows in the next page

How to Configure AWS CLI

Note: The AWS CLI must be configured on your local work station. simple by downloading it from AWS.

There are different ways to install this but my preferred method is by using an installer which can be downloaded from this site. https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html

Use-Case: Install AWS CLI on Windows
Note: You can also have it installed on MacOS and linux. Please See the URL above for the steps.

The installer can be downloaded here for Windows: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html

After installation, Please verify, it has been installed correctly by using the command below.

aws --version

Follow the next steps below to configure the AWS CLI

$aws configure
AWS Access Key ID [None]: Your Access Key ID 
AWS Secret Access Key [None]: Your Secret Key
Default region name [None]: Enter your desired region in this format (us-west-2)
Default output format [None]: I usually leave this by default as (json)

When you type this command, the AWS CLI prompts you for four pieces of information and stores them in a profile (a collection of settings) named default. This profile is then used any time you run an AWS CLI command that doesn’t explicitly specify a profile to use.

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

How to Copy from a Server to s3 and Vice Versa

s3: Which is known as Simple Storage Service by AWS is an object storage service which offers great scalability, data availability, security, and performance.

Prerequisite:

Note: The AWS CLI must be configured on your local work station. simple by downloading it from AWS. I will create a blog for this in the future. After installing AWS CLI for your Operating System (windows, MacOS or linux)

Follow the next steps now to configure the AWS CLI

$aws configure
AWS Access Key ID [None]: Your Access Key ID 
AWS Secret Access Key [None]: Your Secret Key
Default region name [None]: Enter your desired region in this format (us-west-2)
Default output format [None]: I usually leave this by default as (json)

After configuring the AWS CLI, next would be to enter the right syntax to copy files to and from s3.

Note: You will need to have the right permissions in place to perform these task.

Here are the use cases

Copy from s3 to Host: Here we have a bucket sitting at the root level with a folder in it and file inside the folder. 
Then you will need to specify the path on your server you want this to be copied to.

aws s3 cp s3://s3bucketname/s3foldername/fileexample.7z G:\fileexample.7z

copy from host to s3: What this does is simple to copy the file in drive C and upload it to s3. Here we have the bucket, folder inside the bucket and the file that will reside inside the bucket. followed by the right region you want the file to be uploaded to

aws s3 cp C:\filename.zip s3://s3bucketname/s3foldername/fileexample.zip --region ap-northeast-1