Skip to content

wagnerjs/aws-course

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Course

Welcome to my AWS Course! This repository contains resources, examples, code samples, and notes from an AWS course designed to help you learn and master Amazon Web Services.

Content

  • Terraform configuration files
    • Implementation of Remote backend using S3
    • Network: VPC with 2 public subnets, 2 private subnets, 1 internet gateway, 1 NAT gateway and 1 EC2 elastic IP
    • SQS Queue (template)

Repository Structure

.
├── README.md               # Course overview and instructions
├── terraform/
|──── main-stack/             # Main infrastructure configuration files
├──── remote-backend-stack/   # Remote backend implementation

Pre requisites

  • aws-cli
  • eksctl
  • ansible
  • kubectl

Getting Started

To get the most out of this course, you’ll need:

  • An AWS account (free tier is sufficient for most exercises)
  • AWS CLI installed and configured
  • Terraform
  • Basic understanding of cloud computing

Terraform

To create infraestructure on AWS, inside terraform/main-stack run:

$ terraform init    # If is the first execution
$ terraform apply

If you setup Remote Backend configuration, is also necessary execute terraform apply inside terraform/remote-backend-stack folder.

Note

Access to EKS cluster

On created EKS cluster, add Access to your user the following policy AmazonEKSClusterAdminPolicy

To add your cluster to kubectl, run:

$ aws eks update-kubeconfig --region us-west-1 --name <CLUSTER_NAME>

# Default CLUSTER_NAME=aws-course

AWS Load Balancer Controller

The install of AWS Load Balancer Controller is following the documentation and implemented using Ansible.

First, you need to update VPC ID variable on ansible/site.yml

Then, from the repository root, run:

$ ansible-playbook ansible/site.yml

To check if Load Balancer Controller is running run:

$ kubectl get po -A                                      

Output example:

NAMESPACE     NAME                                            READY   STATUS    RESTARTS   AGE
kube-system   aws-load-balancer-controller-6b45f567cd-d4t44   1/1     Running   0          114s
kube-system   aws-load-balancer-controller-6b45f567cd-nzxw4   1/1     Running   0          114s
...

NOTE: If Load Balancer Pods is not Ok, you probably need to check if CloudFormation dont already have the stack. If exists, just remove and run again.

Test Apps

Build and Push

docker build --platform linux/amd64 -t <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/aws-course/production/frontend:v1.0 -f apps/frontend/youtube-live-app/Dockerfile apps/frontend/youtube-live-app
docker push <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/aws-course/production/frontend:v1.0

docker build --platform linux/amd64 -t <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/aws-course/production/backend:v1.0 -f apps/backend/YoutubeLiveApp/Dockerfile apps/backend/YoutubeLiveApp
docker push <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/aws-course/production/backend:v1.0

Deploy

First, you need to update alb.ingress.kubernetes.io/subnets on kubernetes/ingress.yml

Then, to deploy test apps, inside kubernetes folder, run:

kubectl apply -k .

Note: This deploy is using kustomize configuration

To check if everithing is ok, run:

kubectl get deploy,rs,svc,pod,ep

Output Example:

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/backend    1/1     1            1           17m
deployment.apps/frontend   1/1     1            1           17m

NAME                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/backend-789467d55c    1         1         1       2m28s
replicaset.apps/frontend-644cbcc6cb   1         1         1       17m

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
service/backend      NodePort    172.20.65.253   <none>        80:30001/TCP   17m
service/frontend     NodePort    172.20.33.54    <none>        80:30002/TCP   17m
service/kubernetes   ClusterIP   172.20.0.1      <none>        443/TCP        66m

NAME                            READY   STATUS    RESTARTS   AGE
pod/backend-789467d55c-v6lt8    1/1     Running   0          2m28s
pod/frontend-644cbcc6cb-dgrgq   1/1     Running   0          17m

NAME                   ENDPOINTS                       AGE
endpoints/backend      10.0.0.163:80                   17m
endpoints/frontend     10.0.0.163:80                   17m
endpoints/kubernetes   10.0.0.173:443,10.0.0.219:443   66m

Then you can get the Load Balancer to access your frontend and backend aplications.

Security Notice

Make sure to never commit any AWS credentials or sensitive information. Use .env files and add them to .gitignore.

About

Resposistory with AWS templates

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published