AWS -codedeploy and pipeline

Sebastian Velez Zuluaga
5 min readJun 27, 2020

How to set up aws to codeploy our you code in different devices, This text work on raspbian.

  1. You need a aws account or create one, is very easy. On AWS page go to Create an AWS account, put the information on the files and credit card information. NOTE: just select the servicies that say free tier.
  2. Lets give some security to the console, go to IAM service, and watch the level . We need to try in my opinion have 4 check in the security status. Click in each one and follow the steps.
MFA: multi factor auth

Trick, check for the user can use the AWS console, create a group with administrator access (the first one on the list). That is all. Rember 4 for 5 check is good I think 🤪.

3. We need to create one user for the devices, I am using one rapsberry PI, but in the same process for any device. I give the same user to whole devices is really easy to remember it.

You can set the permission I prefer give the permission when I need to use services, Just need to create a user.

4. On my case I am using UBUNTU 20. LTS like S.O, we need to install some thing :

Forever and forever-service:
$ sudo npm install -g forever
$ sudo npm install -g forever-service
https://github.com/zapty/forever-service
Node:
$ sudo apt intall Nodejs
AWS CLI V1 — some version of Linux:
$ sudo apt install python3-pip
$ sudo pip3 install — upgrade — user awscli
$ sudo nano .profile
add in the end export PATH=$HOME/.local/bin:$PATH
$ source ~/.profile
AWS CLI — ubuntu server 20.LTS
$ sudo apt install awscli

Check with the flag -V that the package were install

5. Configure aws
$ aws configure
Go to aws console, IAM, user, security credential and take the Access Key ID, paste in the steps. Or Create access key.

Note: We have the configuration ready with the user that we created on IAM and configure in our device to access the aws services.

6. Adding parameter on System manager — parameter Store with create parameter on the file value you can put where you can, I am using this parameters for don’t expose my github credential.

7. Get parameter from device, remember give it the permission to your user; for acces the system manager service in IAM section.

$ aws ssm get-parameter — name “test_parameter”

if you see this erro : “An error occurred (AccessDeniedException) when calling the GetParameter operation: User: arn:aws:iam::110540341588:user/app_deploy is not authorized to perform: ssm:GetParameter on resource: arn:aws:ssm:us-east-2:110540341588:parameter/test_parameter”; go to IAM and renew the security access.

8. Install codeploy agent
https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install-ubuntu.html
$ sudo apt install ruby
$ sudo apt-get install wget
$ wget https:// https://aws-codedeploy-us-east-2.s3.amazonaws.com/latest/install
$ chmod +x ./install
$ sudo ./install auto

9. In the console go to AIM and give those permission to the user that you create, IAMfullaccess, CodeDeployfullAccess. Wait few minutes before the user has the permission.

10 . Check that you device will be in the Codedeploy list, is very important remember the tags that you give it in last step.

11. After the codedeply agent and device were regiter you can delete the permission .

12. You have to copy one file that the console say you in a location, depends of the S.O

12. Now we can create our file to synchronise the code with our devices. In my repo you can get the important files, the scrip folder and the .YML

https://github.com/sebastianvz/aws_codedeploy_appTest

In the .YML you configure the path of the source files and where you want to will be copy, the order or the .sh script and the action of each one.

In the .YML is important to change in the key runas, for the user of your device.

13. On the Codedeploy service you have to create the the aplication, the group of aplication and the deploy this is the order to crete one deploy.

14. The last step is create the pipeline.

The origin information is in this course from UdeMy :

https://www.udemy.com/course/awsraspberrypi/

--

--