Devops covers at least the following areas:
Why AWS
What is Devops
It is a blanket term for tooling, practices, and ideas that allow organization sto build better software - faster. It includes:
What is CI/CD
Version control systems, VCS
Git flow
Github flow
Benefits of CodeCommit-
Working with AWS CodeCommit
Using admin account create a CodeCommit repo
Add IAM user with specific permissions
Users can generate credentials and used them to get CodeCommit repo
How to use CodeCommit
Open the CodeCommit console
Click Create repository
Type repository name
Click Create, this will create a repo using the root account. WE need to create IAM
Go to the IAM console
Creat new user by clicking “Users”, left side
Type name of the user, select Programatic access and AWS management console access, click next
Add permissions to this user:
NOTE: Once you click create, you will have ONLY ONE CHANGE TO copy - Secret access key - Password - Access key ID - Sigin link
**----> Copy them to a safe place**
First push to CodeCommit
We need to create an SSH key for the repository we will work on: - Click on the repository - Click on SSH - From you local directory, generate a pair of SSH keys. - Upload the PUBLIC key in the AIM access manager - Open AIM console - CLick on users, and find your user - Click en security credentials - CLick on “upload ssh key public” - Copy the SSH KEY ID
- Add an entry in your `.ssh/config` file with the following
Host git-codecomit.*.amazonaws.com
User YOUR AIM SSH KEY ID
Identify ~/.ssh/id_rsa <-- private key
Note:
- .ssh/config permission should be 600
- Now you can clone from your local as:
$ git clone ssh://git-codecommit.us-east-1.amazonaws.clm/v1/repos/test
Benefits:
Not expensive, cost management
Reproducible
Secure
AWS cloud formation
What is?
Basic concepts
Tools
AWS cloud development kit
AWS serverless application model: LAMBDA
AWS code deploy
Permissions
Security for CloudFormation with CI/CD
Deploying CloudFormation
Now that the resource were created, to verify them:
Here an example of how looks like a template:
Deploying CloudFormatoin from CLI
# To deploy a stack
$ aws cloudformation deploy \
--template-file myTemplate-stack.json \
--stack-name demoStack
# To delete a stack
$ aws cloudformation delete-stack \
--stack-name demoStack
Parameter store in Lambda functions
# To create a parameter
$ aws ssm put-parameter \
--name MyParameter1 \
--value Hello \
--type SecureString <== this means encrypted
# To get the value of a parameter with an encrypted value
$ aws ssm get-parameter \
--name MyParameter1 \
# To get the value of a parameter with an decrypted value
$ aws ssm get-parameter \
--name MyParameter1 \
--with-decryption
# TO update the value of the paramter
$ aws ssm put-parameter \
--name MyParameter1 \
--value HiHi \
--type SecureString \
--overwrite
Deploying parameters in Lambda function
# Create a stack with AIM capabilities
$ aws cloudformation deploy \
--template-file myTemplate-stack.json \
--stack-name demoStack
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM <= allows you to use roles
# To list Lambda functions
$ aws lambda list-functions
If the last command is too long, alternative way to find a specific is: - Open the Lambda console - Order the deployed lambda functions by “last modified”. Copy the name fo the lambda function
```bash
# To retrieve the value of the lambda function
$ aws lambda invoke \
--function-name XXXXASFASXZXXXXXX \ <-- name of the function copy from the lambda console
result.txt <-- Will save output in a file
```
What is AWS CodeBuild
CodeBuild concepts: