diff --git a/ch1/ec2-user-data-script/README.md b/ch1/ec2-user-data-script/README.md new file mode 100644 index 0000000..ce82621 --- /dev/null +++ b/ch1/ec2-user-data-script/README.md @@ -0,0 +1,14 @@ +# EC User Data Script + +This folder contains: + +* `user-data.sh`: A script that you can copy into the user data of an EC2 instance to get that instance to run a + simple Node.js "Hello, World" server on port 80. + +For more information, see Chapter 1, "How to Deploy Your App", of [_Fundamentals of DevOps and Software +Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch1/sample-app/README.md b/ch1/sample-app/README.md new file mode 100644 index 0000000..375263b --- /dev/null +++ b/ch1/sample-app/README.md @@ -0,0 +1,14 @@ +# Node.js Sample App for Fly.io + +This folder contains: + +* `app.js`: A simple Node.js "Hello, World" server that listens on port 8080. +* `fly.toml`: A configuration file you can use to run the Node.js app on Fly.io. + +For more information, see Chapter 1, "How to Deploy Your App", of [_Fundamentals of DevOps and Software +Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch2/ansible/README.md b/ch2/ansible/README.md new file mode 100644 index 0000000..de204dd --- /dev/null +++ b/ch2/ansible/README.md @@ -0,0 +1,17 @@ +# Ansible EC2 Instance + +This folder contains: + +* `create_ec2_instance_playbook.yml`: An Ansible playbook to create an EC2 instance. +* `configure_sample_app_playbook.yml`: An Ansible playbook to configure an EC2 instance to run a Node.js "Hello, World" + sample app that listens on port 8080. Under the hood, uses the Ansible roles in the `roles` folder. +* `inventory.aws_ec2.yml`: An Ansible dynamic inventory file to discover EC2 instances, which along with the + `group_vars` folder will allow you to connect to those instances and can configure them. + +For more information, see Chapter 2, "How to Manage Your Infrastructure as Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch2/bash/README.md b/ch2/bash/README.md new file mode 100644 index 0000000..b26e4ac --- /dev/null +++ b/ch2/bash/README.md @@ -0,0 +1,14 @@ +# EC2 Instance Bash Script + +This folder contains: + +* `deploy-ec2-instance.sh`: A Bash script that deploys an EC2 instance and configures it to run a Node.js "Hello, World" + app that listens on port 8080. + +For more information, see Chapter 2, "How to Manage Your Infrastructure as Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch2/packer/README.md b/ch2/packer/README.md new file mode 100644 index 0000000..a790b74 --- /dev/null +++ b/ch2/packer/README.md @@ -0,0 +1,14 @@ +# Node.js Sample App Packer Template + +This folder contains: + +* `app.js`: A Node.js "Hello, World" sample app that listens on port 8080. +* `sample-app.pkr.hcl`: A Packer template that can create an AMI that has the Node.js sample app installed. + +For more information, see Chapter 2, "How to Manage Your Infrastructure as Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch2/tofu/ec2-instance/README.md b/ch2/tofu/ec2-instance/README.md new file mode 100644 index 0000000..3328d3d --- /dev/null +++ b/ch2/tofu/ec2-instance/README.md @@ -0,0 +1,12 @@ +# EC2 Instance OpenTofu Module + +This folder contains a root OpenTofu module that deploys an EC2 instance which runs a Node.js "Hello, World" sample app +that listens on port 8080. + +For more information, see Chapter 2, "How to Manage Your Infrastructure as Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch2/tofu/live/sample-app-github/README.md b/ch2/tofu/live/sample-app-github/README.md new file mode 100644 index 0000000..0e6ea93 --- /dev/null +++ b/ch2/tofu/live/sample-app-github/README.md @@ -0,0 +1,13 @@ +# EC2 Instance OpenTofu Module + +This folder contains a root OpenTofu module that uses the +[ec2-instance reusable OpenTofu module](../../modules/ec2-instance) directly from a GitHub URL to deploy an EC2 +instance which runs a Node.js "Hello, World" sample app that listens on port 8080. + +For more information, see Chapter 2, "How to Manage Your Infrastructure as Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch2/tofu/live/sample-app/README.md b/ch2/tofu/live/sample-app/README.md new file mode 100644 index 0000000..4b3ea07 --- /dev/null +++ b/ch2/tofu/live/sample-app/README.md @@ -0,0 +1,13 @@ +# EC2 Instance OpenTofu Module + +This folder contains a root OpenTofu module that uses the +[ec2-instance reusable OpenTofu module](../../modules/ec2-instance) to deploy an EC2 instance which runs a Node.js +"Hello, World" sample app that listens on port 8080. + +For more information, see Chapter 2, "How to Manage Your Infrastructure as Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch2/tofu/modules/ec2-instance/README.md b/ch2/tofu/modules/ec2-instance/README.md new file mode 100644 index 0000000..bf67fe1 --- /dev/null +++ b/ch2/tofu/modules/ec2-instance/README.md @@ -0,0 +1,12 @@ +# EC2 Instance OpenTofu Module + +This folder contains a reusable OpenTofu module that deploys an EC2 instance which runs a Node.js "Hello, World" sample +app that listens on port 8080. + +For more information, see Chapter 2, "How to Manage Your Infrastructure as Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/ansible/README.md b/ch3/ansible/README.md new file mode 100644 index 0000000..caf5d59 --- /dev/null +++ b/ch3/ansible/README.md @@ -0,0 +1,21 @@ +# Ansible Server Orchestration + +This folder contains an example of how to do server orchestration with Ansible: + +* `create_ec2_instances_playbook.yml`: An Ansible playbook to create multiple EC2 instances. You can use it with + `sample-app-vars.yml` to create EC2 instances for running Node.js sample apps or `nginx-vars.yml` to create an EC2 + instance for running Nginx. +* `configure_sample_app_playbook.yml`: An Ansible playbook to configure an EC2 instance to run a Node.js "Hello, World" + sample app that listens on port 8080. Under the hood, uses the Ansible roles in the `roles` folder. +* `configure_nginx_playbook.yml`: An Ansible playbook to configure an EC2 instance to run Nginx as a load balancer + that routes traffic across EC2 instances running the Node.js sample app. +* `inventory.aws_ec2.yml`: An Ansible dynamic inventory file to discover EC2 instances, which along with the + `group_vars` folder will allow you to connect to those instances and can configure them. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/docker/README.md b/ch3/docker/README.md new file mode 100644 index 0000000..2c61901 --- /dev/null +++ b/ch3/docker/README.md @@ -0,0 +1,14 @@ +# Dockerized Node.js App + +This folder contains: + +* `app.js`: A Node.js "Hello, World" app that listens on port 8080. +* `Dockerfile`: Instructions to build a Docker image for the Node.js sample app. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/kubernetes/README.md b/ch3/kubernetes/README.md new file mode 100644 index 0000000..6f5b669 --- /dev/null +++ b/ch3/kubernetes/README.md @@ -0,0 +1,14 @@ +# Kubernetes Deployment and Service + +This folder contains: + +* `sample-app-deployment.yml`: A Kubernetes `Deployment` for deploying a simple app that listens on port 8080. +* `sample-app-service.yml`: A Kubernetes `Service` to act as a load balancer for the apps in the `Deployment`. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/packer/README.md b/ch3/packer/README.md new file mode 100644 index 0000000..fd6f0f2 --- /dev/null +++ b/ch3/packer/README.md @@ -0,0 +1,15 @@ +# Node.js App Packer Template + +This folder contains: + +* `app.js`: A Node.js "Hello, World" app that listens on port 8080. +* `app.config.js`: A config file for running the Node.js sample app using PM2 as a process supervisor. +* `sample-app.pkr.hcl`: A Packer template for creating an AMI for the Node.js sample app. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/live/asg-sample/README.md b/ch3/tofu/live/asg-sample/README.md new file mode 100644 index 0000000..8527cd1 --- /dev/null +++ b/ch3/tofu/live/asg-sample/README.md @@ -0,0 +1,13 @@ +# VM Orchestration Module + +This folder contains a root OpenTofu module that shows an example of VM orchestration. It uses the +[asg](../../modules/asg) module to deploy an ASG running a Node.js "Hello, World" app, and the [alb](../../modules/alb) +module to deploy an ALB that routes traffic across the ASG. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/live/ecr-sample/README.md b/ch3/tofu/live/ecr-sample/README.md new file mode 100644 index 0000000..5380f61 --- /dev/null +++ b/ch3/tofu/live/ecr-sample/README.md @@ -0,0 +1,12 @@ +# Elastic Container Registry (ECR) Module + +This folder contains a root OpenTofu module that uses the [ecr-repo](../../modules/ecr-repo) module to create an ECR +repo. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/live/eks-sample/README.md b/ch3/tofu/live/eks-sample/README.md new file mode 100644 index 0000000..899fff8 --- /dev/null +++ b/ch3/tofu/live/eks-sample/README.md @@ -0,0 +1,13 @@ +# Container Orchestration Module + +This folder, along with [ecr-sample](../ecr-sample) and the [kubernetes objects](../../../kubernetes), contain an +example of container orchestration. This folder contains a root OpenTofu module that uses the +[eks-cluster](../../modules/eks-cluster) module to create an EKS cluster with a managed node group. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/live/lambda-sample/README.md b/ch3/tofu/live/lambda-sample/README.md new file mode 100644 index 0000000..61aea62 --- /dev/null +++ b/ch3/tofu/live/lambda-sample/README.md @@ -0,0 +1,13 @@ +# Serverless Orchestration Module + +This folder contains an example of serverless orchestration. It contains a root OpenTofu module that uses +the [lambda](../../modules/lambda) to deploy a Node.js "Hello, World" app as Lambda function and the +[api-gateway](../../modules/api-gateway) to configure an API Gateway that sends HTTP requests to the Lambda function. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/modules/alb/README.md b/ch3/tofu/modules/alb/README.md new file mode 100644 index 0000000..01faea3 --- /dev/null +++ b/ch3/tofu/modules/alb/README.md @@ -0,0 +1,12 @@ +# Application Load Balancer (ALB) Module + +This folder contains a reusable OpenTofu module that can deploy an ALB that can route HTTP traffic across and a target +group for an HTTP app. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/modules/api-gateway/README.md b/ch3/tofu/modules/api-gateway/README.md new file mode 100644 index 0000000..9418805 --- /dev/null +++ b/ch3/tofu/modules/api-gateway/README.md @@ -0,0 +1,12 @@ +# API Gateway Module + +This folder contains a reusable OpenTofu module that can deploy an HTTP v2 API Gateway that sends traffic to an AWS +Lambda function. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/modules/asg/README.md b/ch3/tofu/modules/asg/README.md new file mode 100644 index 0000000..b58aa9d --- /dev/null +++ b/ch3/tofu/modules/asg/README.md @@ -0,0 +1,12 @@ +# Auto Scaling Group Module + +This folder contains a reusable OpenTofu module that can deploy an Auto Scaling Group and optionally configure it to use +instance refresh and to register in an ALB target group. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/modules/ecr-repo/README.md b/ch3/tofu/modules/ecr-repo/README.md new file mode 100644 index 0000000..be4abd0 --- /dev/null +++ b/ch3/tofu/modules/ecr-repo/README.md @@ -0,0 +1,11 @@ +# Elastic Container Registry (ECR) Module + +This folder contains a reusable OpenTofu module that can create an ECR repo. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/modules/eks-cluster/README.md b/ch3/tofu/modules/eks-cluster/README.md new file mode 100644 index 0000000..648324b --- /dev/null +++ b/ch3/tofu/modules/eks-cluster/README.md @@ -0,0 +1,11 @@ +# Elastic Kubernetes Service (EKS) Module + +This folder contains a reusable OpenTofu module that can create an EKS cluster with a managed node group. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch3/tofu/modules/lambda/README.md b/ch3/tofu/modules/lambda/README.md new file mode 100644 index 0000000..7d6cde5 --- /dev/null +++ b/ch3/tofu/modules/lambda/README.md @@ -0,0 +1,12 @@ +# AWS Lambda Module + +This folder contains a reusable OpenTofu module that can package up a source folder as a Lambda deployment package +(zip file) and deploy that code as a Lambda function. + +For more information, see Chapter 3, "How to Deploy Many Apps: Orchestration, VMs, Containers, and Serverless", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch4/sample-app-express-with-tests/README.md b/ch4/sample-app-express-with-tests/README.md new file mode 100644 index 0000000..746fade --- /dev/null +++ b/ch4/sample-app-express-with-tests/README.md @@ -0,0 +1,19 @@ +# Express.js and Automated Tests Example + +This folder contains: + +* `app.js`: An Express.js "Hello, World" app. +* `app.test.js`: Automated integration tests for `app.js`. +* `server.js`: Fires up the app in `app.js` to listen on port 8080. +* `reverse.js`: Simple functions to reverse characters and words in a string. +* `reverse.test.js`: Automated unit tests for `reverse.test.js`. +* `package.json`: An NPM build configuration for the Node.js app. +* `Dockerfile`: Instructions on how to package the Node.js app as a Docker image. + +For more information, see Chapter 4, "How to Version, Build, and Test Your Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch4/sample-app-express/README.md b/ch4/sample-app-express/README.md new file mode 100644 index 0000000..b48e9f9 --- /dev/null +++ b/ch4/sample-app-express/README.md @@ -0,0 +1,15 @@ +# Express.js and NPM Example + +This folder contains: + +* `app.js`: An Express.js "Hello, World" app that listens on port 8080. +* `package.json`: An NPM build configuration for the Node.js app. +* `Dockerfile`: Instructions on how to package the Node.js app as a Docker image. + +For more information, see Chapter 4, "How to Version, Build, and Test Your Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch4/sample-app/README.md b/ch4/sample-app/README.md new file mode 100644 index 0000000..93ca960 --- /dev/null +++ b/ch4/sample-app/README.md @@ -0,0 +1,15 @@ +# Node.js and NPM Example + +This folder contains: + +* `app.js`: A Node.js "Hello, World" app that listens on port 8080. +* `package.json`: An NPM build configuration for the Node.js app. +* `Dockerfile`: Instructions on how to package the Node.js app as a Docker image. + +For more information, see Chapter 4, "How to Version, Build, and Test Your Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch4/tofu/live/lambda-sample/README.md b/ch4/tofu/live/lambda-sample/README.md new file mode 100644 index 0000000..bd6864a --- /dev/null +++ b/ch4/tofu/live/lambda-sample/README.md @@ -0,0 +1,17 @@ +# Serverless Module with Automated Tests + +This folder contains: + +* `*.tf` files: A root OpenTofu module that deploys a Node.js "Hello, World" serverless app using AWS Lambda and API + Gateway. +* `deploy.tftest.hcl`: An automated tests that uses the `tofu test` command to validate the serverless app works as + expected +* `terrascan.toml`: A configuration file for Terrascan, which you can use to scan this module for compliance issues. + +For more information, see Chapter 4, "How to Version, Build, and Test Your Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch4/tofu/modules/test-endpoint/README.md b/ch4/tofu/modules/test-endpoint/README.md new file mode 100644 index 0000000..77e55c7 --- /dev/null +++ b/ch4/tofu/modules/test-endpoint/README.md @@ -0,0 +1,13 @@ +# Test Endpoint Module + +This folder contains a reusable OpenTofu module that makes an HTTP request to a specified endpoint and makes the +response available as an output. This is primarily useful as a helper module when writing automated tests with the +`tofu test` command. + +For more information, see Chapter 4, "How to Version, Build, and Test Your Code", of [_Fundamentals of DevOps and +Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/github-actions/README.md b/ch5/github-actions/README.md new file mode 100644 index 0000000..52ec384 --- /dev/null +++ b/ch5/github-actions/README.md @@ -0,0 +1,18 @@ +# GitHub Actions CI/CD Workflows + +This folder contains: + +* `app-tests.yml`: A GitHub Actions workflow to run the automated tests of a Node.js "Hello, World" app. +* `infra-tests.yml`: A GitHub Actions workflow to run the automated tests for an OpenTofu module. +* `tofu-plan.yml`: A GitHub Actions workflow that runs on PRs that modify an OpenTofu module. This workflow runs + `tofu plan` on the module and posts the plan output as a comment in the PR. +* `tofu-plan.yml`: A GitHub Actions workflow that runs on merged PRs that modify an OpenTofu module. This workflow runs + `tofu apply` on the module and posts the apply output as a comment in the PR. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/sample-app/README.md b/ch5/sample-app/README.md new file mode 100644 index 0000000..8078a10 --- /dev/null +++ b/ch5/sample-app/README.md @@ -0,0 +1,19 @@ +# Express.js and Automated Tests Example + +This folder contains: + +* `app.js`: An Express.js "Hello, World" app. +* `app.test.js`: Automated integration tests for `app.js`. +* `server.js`: Fires up the app in `app.js` to listen on port 8080. +* `reverse.js`: Simple functions to reverse characters and words in a string. +* `reverse.test.js`: Automated unit tests for `reverse.test.js`. +* `package.json`: An NPM build configuration for the Node.js app. +* `Dockerfile`: Instructions on how to package the Node.js app as a Docker image. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/tofu/live/ci-cd-permissions/README.md b/ch5/tofu/live/ci-cd-permissions/README.md new file mode 100644 index 0000000..c2fd4d1 --- /dev/null +++ b/ch5/tofu/live/ci-cd-permissions/README.md @@ -0,0 +1,15 @@ +# CI/CD Permissions Module + +This folder contains a root OpenTofu module that can be used to set up permissions for doing CI/CD with GitHub Actions, +AWS, and OpenTofu. This module uses the [github-aws-oidc](../../modules/github-aws-oidc) module to configure GitHub as +an OIDC provider in AWS and the [gh-actions-iam-roles](../../modules/gh-actions-iam-roles) module to create IAM roles +in AWS that you can assume from GitHub Actions workflows (using OIDC) to run automated tests, `tofu plan`, and +`tofu apply`. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/tofu/live/lambda-sample/README.md b/ch5/tofu/live/lambda-sample/README.md new file mode 100644 index 0000000..0be890a --- /dev/null +++ b/ch5/tofu/live/lambda-sample/README.md @@ -0,0 +1,17 @@ +# Serverless Module with Automated Tests + +This folder contains: + +* `*.tf` files: A root OpenTofu module that deploys a Node.js "Hello, World" serverless app using AWS Lambda and API + Gateway. +* `deploy.tftest.hcl`: An automated tests that uses the `tofu test` command to validate the serverless app works as + expected +* `terrascan.toml`: A configuration file for Terrascan, which you can use to scan this module for compliance issues. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/tofu/live/tofu-state/README.md b/ch5/tofu/live/tofu-state/README.md new file mode 100644 index 0000000..0ed2b60 --- /dev/null +++ b/ch5/tofu/live/tofu-state/README.md @@ -0,0 +1,12 @@ +# OpenTofu State Module + +This folder contains a root OpenTofu module that uses the [state-bucket](../../modules/state-bucket) module to create +an S3 bucket and DynamoDB table that can be used for storing OpenTofu state. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/tofu/modules/gh-actions-iam-roles/README.md b/ch5/tofu/modules/gh-actions-iam-roles/README.md new file mode 100644 index 0000000..ea68b65 --- /dev/null +++ b/ch5/tofu/modules/gh-actions-iam-roles/README.md @@ -0,0 +1,16 @@ +# GitHub Actions IAM Roles Module + +This folder contains a reusable OpenTofu module that can create three IAM roles that can be assumed from GitHub Actions +workflows using OIDC: + +* An IAM role for running automated tests against the `lambda-sample` module on any branch. +* An IAM role for running `tofu plan` against the `lambda-sample` module on any branch. +* An IAM role for running `tofu apply` against the `lambda-sample` module on the `main` branch only. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/tofu/modules/github-aws-oidc/README.md b/ch5/tofu/modules/github-aws-oidc/README.md new file mode 100644 index 0000000..5e606ac --- /dev/null +++ b/ch5/tofu/modules/github-aws-oidc/README.md @@ -0,0 +1,11 @@ +# GitHub AWS OIDC Module + +This folder contains a reusable OpenTofu module that can configure GitHub as an OIDC provider in AWS. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/tofu/modules/state-bucket/README.md b/ch5/tofu/modules/state-bucket/README.md new file mode 100644 index 0000000..1d269ae --- /dev/null +++ b/ch5/tofu/modules/state-bucket/README.md @@ -0,0 +1,12 @@ +# OpenTofu State S3 and DynamoDB module + +This folder contains a reusable OpenTofu module that can create an S3 bucket and DynamoDB table for storing OpenTofu +state. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch5/tofu/modules/test-endpoint/README.md b/ch5/tofu/modules/test-endpoint/README.md new file mode 100644 index 0000000..a8b1367 --- /dev/null +++ b/ch5/tofu/modules/test-endpoint/README.md @@ -0,0 +1,13 @@ +# Test Endpoint Module + +This folder contains a reusable OpenTofu module that makes an HTTP request to a specified endpoint and makes the +response available as an output. This is primarily useful as a helper module when writing automated tests with the +`tofu test` command. + +For more information, see Chapter 5, "How to Set Up Continuous Integration (CI) and Continuous Delivery (CD)", of +[_Fundamentals of DevOps and Software Delivery_](https://www.fundamentals-of-devops.com) by Yevgeniy Brikman. + +> [!IMPORTANT] +> This repo contains example code for learning and experimenting only, in conjunction with the book and blog post +> series. This code is _not_ designed for direct production usage. If you're looking for code you can use directly in +> production, check out the [Gruntwork Library](https://www.gruntwork.io/products/library). diff --git a/ch8/live/prod/eks-cluster/terragrunt.hcl b/ch8/live/prod/eks-cluster/terragrunt.hcl deleted file mode 100644 index 58695cc..0000000 --- a/ch8/live/prod/eks-cluster/terragrunt.hcl +++ /dev/null @@ -1,18 +0,0 @@ -terraform { - source = "../../../modules/eks-cluster" -} - -include { - path = find_in_parent_folders() -} - -inputs = { - name = "sample-app-cluster-prod" - - min_size = 1 - max_size = 10 - desired_size = 3 - instance_type = "t2.micro" - - kubernetes_version = "1.29" -} \ No newline at end of file diff --git a/ch8/live/prod/sample-app/terragrunt.hcl b/ch8/live/prod/sample-app/terragrunt.hcl deleted file mode 100644 index 0926406..0000000 --- a/ch8/live/prod/sample-app/terragrunt.hcl +++ /dev/null @@ -1,30 +0,0 @@ -terraform { - source = "../../../modules/eks-app" -} - -include { - path = find_in_parent_folders() -} - -dependency "eks_cluster" { - config_path = "./eks-cluster" -} - -dependency "ecr_repo" { - config_path = "./sample-app-ecr-repo" -} - -inputs = { - name = "sample-app-prod" - replicas = 3 - - image = dependency.ecr_repo.outputs.registry_url - image_version = "v5" - container_port = 8080 - - environment_variables = { - NODE_ENV = production - } - - eks_cluster_name = dependency.eks_cluster.outputs.cluster_name -} \ No newline at end of file diff --git a/ch8/live/shared/sample-app-ecr-repo/terragrunt.hcl b/ch8/live/shared/sample-app-ecr-repo/terragrunt.hcl deleted file mode 100644 index a6eb75d..0000000 --- a/ch8/live/shared/sample-app-ecr-repo/terragrunt.hcl +++ /dev/null @@ -1,11 +0,0 @@ -terraform { - source = "../../../modules/eks-app" -} - -include { - path = find_in_parent_folders() -} - -inputs = { - name = "sample-app" -} \ No newline at end of file diff --git a/ch8/live/stage/eks-cluster/terragrunt.hcl b/ch8/live/stage/eks-cluster/terragrunt.hcl deleted file mode 100644 index 03d4188..0000000 --- a/ch8/live/stage/eks-cluster/terragrunt.hcl +++ /dev/null @@ -1,18 +0,0 @@ -terraform { - source = "../../../modules/eks-cluster" -} - -include { - path = find_in_parent_folders() -} - -inputs = { - name = "sample-app-cluster-stage" - - min_size = 1 - max_size = 3 - desired_size = 2 - instance_type = "t2.micro" - - kubernetes_version = "1.29" -} \ No newline at end of file diff --git a/ch8/live/stage/sample-app/terragrunt.hcl b/ch8/live/stage/sample-app/terragrunt.hcl deleted file mode 100644 index d4770d0..0000000 --- a/ch8/live/stage/sample-app/terragrunt.hcl +++ /dev/null @@ -1,30 +0,0 @@ -terraform { - source = "../../../modules/eks-app" -} - -include { - path = find_in_parent_folders() -} - -dependency "eks_cluster" { - config_path = "./eks-cluster" -} - -dependency "ecr_repo" { - config_path = "./sample-app-ecr-repo" -} - -inputs = { - name = "sample-app-stage" - replicas = 2 - - image = dependency.ecr_repo.outputs.registry_url - image_version = "v5" - container_port = 8080 - - environment_variables = { - NODE_ENV = production - } - - eks_cluster_name = dependency.eks_cluster.outputs.cluster_name -} \ No newline at end of file diff --git a/ch8/live/terragrunt.hcl b/ch8/live/terragrunt.hcl deleted file mode 100644 index 24a8dc0..0000000 --- a/ch8/live/terragrunt.hcl +++ /dev/null @@ -1,16 +0,0 @@ -remote_state { - backend = "s3" - - generate = { - path = "backend.tf" - if_exists = "overwrite" - } - - config = { - bucket = "fundamentals-of-devops-terraform-state" - key = "${path_relative_to_include()}/terraform.tfstate" - region = "us-east-2" - encrypt = true - dynamodb_table = "terraform-locks" - } -} \ No newline at end of file diff --git a/ch8/modules/ecr-repo/.terraform.lock.hcl b/ch8/modules/ecr-repo/.terraform.lock.hcl deleted file mode 100644 index 25e04b3..0000000 --- a/ch8/modules/ecr-repo/.terraform.lock.hcl +++ /dev/null @@ -1,19 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/hashicorp/aws" { - version = "5.45.0" - hashes = [ - "h1:3zU3yp1SY+8vHAQvhfhYdPnFYQpFwXXXar+hOrnofzQ=", - "zh:1d71c406aeaf4ba762eb62e4595ab9c9f8da1a2c9b74bb4277c0acfd9678ae65", - "zh:3b00b13154eadedb37bca99bf7cbd556fa9472e6900c970effa17a270ee9f721", - "zh:6f264e8b70153925ac8abfa83ebffe2c2d5a27ab5557a6b16124269b08ac2441", - "zh:80f7d552faf5c43d7dc22c6c1f7e70557b9f01c67db07abbb0330d5d3fc0e464", - "zh:863a2a2e6ae5b42fc46b209d8f2761c882d46aca481a8c49ef221d290b4fd88e", - "zh:8e3bddeb2da7e6bcfd0b0221a083778d2f7fc5cd64f55de7d8d79bd1f7378bae", - "zh:c726104e46cd743bbf240101d7975f44091d893b6e97b46070df0041779b04d2", - "zh:db73a89b462fdd6eb6f32e6ed464430a895fc2e54fb629e8b99773fc32a6a7a8", - "zh:e35179b89eba358f521ffd4546345b4d0683ca3364a9deb8f3b7b4bf60be6f02", - "zh:e7b54a0faecd34a9c73729d1d1f0cfc1b8f56bae789f95987002616f1265ce72", - ] -} diff --git a/ch8/modules/ecr-repo/main.tf b/ch8/modules/ecr-repo/main.tf deleted file mode 100644 index 1eb88f5..0000000 --- a/ch8/modules/ecr-repo/main.tf +++ /dev/null @@ -1,10 +0,0 @@ -provider "aws" { - region = "us-east-2" -} - -resource "aws_ecr_repository" "sample_app" { - name = var.name - image_tag_mutability = "IMMUTABLE" - - force_delete = true -} diff --git a/ch8/modules/ecr-repo/outputs.tf b/ch8/modules/ecr-repo/outputs.tf deleted file mode 100644 index 33e5404..0000000 --- a/ch8/modules/ecr-repo/outputs.tf +++ /dev/null @@ -1,4 +0,0 @@ -output "registry_url" { - value = aws_ecr_repository.sample_app.repository_url - description = "URL of the ECR repo" -} \ No newline at end of file diff --git a/ch8/modules/ecr-repo/variables.tf b/ch8/modules/ecr-repo/variables.tf deleted file mode 100644 index 78ef390..0000000 --- a/ch8/modules/ecr-repo/variables.tf +++ /dev/null @@ -1,4 +0,0 @@ -variable "name" { - description = "The base name for the ECR repo and all other resources" - type = string -} \ No newline at end of file diff --git a/ch8/modules/eks-app/main.tf b/ch8/modules/eks-app/main.tf deleted file mode 100644 index 17efc9b..0000000 --- a/ch8/modules/eks-app/main.tf +++ /dev/null @@ -1,82 +0,0 @@ -provider "kubernetes" { - host = data.aws_eks_cluster.cluster.endpoint - cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority[0].data) - token = data.aws_eks_cluster_auth.cluster.token -} - -data "aws_eks_cluster" "cluster" { - name = var.eks_cluster_name -} - -data "aws_eks_cluster_auth" "cluster" { - name = var.eks_cluster_name -} - -resource "kubernetes_deployment" "app" { - metadata { - name = "${var.name}-deployment" - } - - spec { - replicas = var.replicas - - template { - metadata { - labels = local.pod_label - } - - spec { - container { - name = var.name - image = "${var.image}:${var.image_version}" - - port { - container_port = var.container_port - } - - dynamic "env" { - for_each = var.environment_variables - content { - name = env.key - value = env.value - } - } - } - } - } - - selector { - match_labels = local.pod_label - } - - strategy { - type = "RollingUpdate" - rolling_update { - max_surge = var.replicas - max_unavailable = 0 - } - } - } -} - -resource "kubernetes_service" "app" { - metadata { - name = "${var.name}-loadbalancer" - } - - spec { - type = "LoadBalancer" - port { - port = 80 - target_port = var.container_port - protocol = "TCP" - } - selector = local.pod_label - } -} - -locals { - pod_label = { - app = "${var.name}-pods" - } -} \ No newline at end of file diff --git a/ch8/modules/eks-app/outputs.tf b/ch8/modules/eks-app/outputs.tf deleted file mode 100644 index d55dec9..0000000 --- a/ch8/modules/eks-app/outputs.tf +++ /dev/null @@ -1,16 +0,0 @@ -output "service_status" { - value = kubernetes_service.app.status - description = "The K8S Service status" -} - -locals { - status = kubernetes_service.app.status -} - -output "service_endpoint" { - value = try( - "http://${local.status[0]["load_balancer"][0]["ingress"][0]["hostname"]}", - "(error parsing hostname from status)" - ) - description = "The K8S Service endpoint" -} diff --git a/ch8/modules/eks-app/variables.tf b/ch8/modules/eks-app/variables.tf deleted file mode 100644 index 8e19056..0000000 --- a/ch8/modules/eks-app/variables.tf +++ /dev/null @@ -1,34 +0,0 @@ -variable "name" { - description = "The base name for the app and all other resources" - type = string -} - -variable "replicas" { - description = "How many replicas to run of this app" - type = number -} - -variable "image" { - description = "The Docker image to deploy for this app" - type = string -} - -variable "image_version" { - description = "The version (tag) of the Docker image to deploy" - type = string -} - -variable "container_port" { - description = "The port the Docker image listens on for HTTP requests" - type = number -} - -variable "environment_variables" { - description = "The environment variables to set for the app" - type = map(string) -} - -variable "eks_cluster_name" { - description = "The name of the EKS cluster" - type = string -} diff --git a/ch8/modules/eks-cluster/.terraform.lock.hcl b/ch8/modules/eks-cluster/.terraform.lock.hcl deleted file mode 100644 index 25e04b3..0000000 --- a/ch8/modules/eks-cluster/.terraform.lock.hcl +++ /dev/null @@ -1,19 +0,0 @@ -# This file is maintained automatically by "tofu init". -# Manual edits may be lost in future updates. - -provider "registry.opentofu.org/hashicorp/aws" { - version = "5.45.0" - hashes = [ - "h1:3zU3yp1SY+8vHAQvhfhYdPnFYQpFwXXXar+hOrnofzQ=", - "zh:1d71c406aeaf4ba762eb62e4595ab9c9f8da1a2c9b74bb4277c0acfd9678ae65", - "zh:3b00b13154eadedb37bca99bf7cbd556fa9472e6900c970effa17a270ee9f721", - "zh:6f264e8b70153925ac8abfa83ebffe2c2d5a27ab5557a6b16124269b08ac2441", - "zh:80f7d552faf5c43d7dc22c6c1f7e70557b9f01c67db07abbb0330d5d3fc0e464", - "zh:863a2a2e6ae5b42fc46b209d8f2761c882d46aca481a8c49ef221d290b4fd88e", - "zh:8e3bddeb2da7e6bcfd0b0221a083778d2f7fc5cd64f55de7d8d79bd1f7378bae", - "zh:c726104e46cd743bbf240101d7975f44091d893b6e97b46070df0041779b04d2", - "zh:db73a89b462fdd6eb6f32e6ed464430a895fc2e54fb629e8b99773fc32a6a7a8", - "zh:e35179b89eba358f521ffd4546345b4d0683ca3364a9deb8f3b7b4bf60be6f02", - "zh:e7b54a0faecd34a9c73729d1d1f0cfc1b8f56bae789f95987002616f1265ce72", - ] -} diff --git a/ch8/modules/eks-cluster/main.tf b/ch8/modules/eks-cluster/main.tf deleted file mode 100644 index 932e49a..0000000 --- a/ch8/modules/eks-cluster/main.tf +++ /dev/null @@ -1,106 +0,0 @@ -provider "aws" { - region = "us-east-2" -} - -resource "aws_eks_cluster" "cluster" { - name = var.name - role_arn = aws_iam_role.cluster.arn - version = var.kubernetes_version - - vpc_config { - subnet_ids = data.aws_subnets.default.ids - } - - # Ensure that IAM Role permissions are created before and deleted after - # the EKS Cluster. Otherwise, EKS will not be able to properly delete - # EKS managed EC2 infrastructure such as Security Groups. - depends_on = [ - aws_iam_role_policy_attachment.AmazonEKSClusterPolicy - ] -} - -resource "aws_eks_node_group" "nodes" { - cluster_name = aws_eks_cluster.cluster.name - node_group_name = var.name - node_role_arn = aws_iam_role.node_group.arn - subnet_ids = data.aws_subnets.default.ids - instance_types = [var.instance_type] - - scaling_config { - min_size = var.min_size - max_size = var.max_size - desired_size = var.desired_size - } - - # Ensure that IAM Role permissions are created before and deleted after - # the EKS Node Group. Otherwise, EKS will not be able to properly - # delete EC2 Instances and Elastic Network Interfaces. - depends_on = [ - aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy, - aws_iam_role_policy_attachment.AmazonEC2ContainerRegistryReadOnly, - aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy, - ] -} - -resource "aws_iam_role" "cluster" { - name = "${var.name}-cluster" - assume_role_policy = data.aws_iam_policy_document.cluster_assume_role.json -} - -data "aws_iam_policy_document" "cluster_assume_role" { - statement { - effect = "Allow" - actions = ["sts:AssumeRole"] - principals { - type = "Service" - identifiers = ["eks.amazonaws.com"] - } - } -} - -resource "aws_iam_role_policy_attachment" "AmazonEKSClusterPolicy" { - policy_arn = "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy" - role = aws_iam_role.cluster.name -} - -resource "aws_iam_role" "node_group" { - name = "${var.name}-workers" - assume_role_policy = data.aws_iam_policy_document.node_assume_role.json -} - -data "aws_iam_policy_document" "node_assume_role" { - statement { - effect = "Allow" - actions = ["sts:AssumeRole"] - principals { - type = "Service" - identifiers = ["ec2.amazonaws.com"] - } - } -} - -resource "aws_iam_role_policy_attachment" "AmazonEKSWorkerNodePolicy" { - policy_arn = "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy" - role = aws_iam_role.node_group.name -} - -resource "aws_iam_role_policy_attachment" "AmazonEC2ContainerRegistryReadOnly" { - policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly" - role = aws_iam_role.node_group.name -} - -resource "aws_iam_role_policy_attachment" "AmazonEKS_CNI_Policy" { - policy_arn = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy" - role = aws_iam_role.node_group.name -} - -data "aws_vpc" "default" { - default = true -} - -data "aws_subnets" "default" { - filter { - name = "vpc-id" - values = [data.aws_vpc.default.id] - } -} diff --git a/ch8/modules/eks-cluster/outputs.tf b/ch8/modules/eks-cluster/outputs.tf deleted file mode 100644 index f14b459..0000000 --- a/ch8/modules/eks-cluster/outputs.tf +++ /dev/null @@ -1,19 +0,0 @@ -output "cluster_name" { - value = aws_eks_cluster.cluster.name - description = "Name of the EKS cluster" -} - -output "cluster_arn" { - value = aws_eks_cluster.cluster.arn - description = "ARN of the EKS cluster" -} - -output "cluster_endpoint" { - value = aws_eks_cluster.cluster.endpoint - description = "Endpoint of the EKS cluster" -} - -output "cluster_certificate_authority" { - value = aws_eks_cluster.cluster.certificate_authority - description = "Certificate authority of the EKS cluster" -} \ No newline at end of file diff --git a/ch8/modules/eks-cluster/variables.tf b/ch8/modules/eks-cluster/variables.tf deleted file mode 100644 index df87abb..0000000 --- a/ch8/modules/eks-cluster/variables.tf +++ /dev/null @@ -1,34 +0,0 @@ -variable "name" { - description = "The base name for the EKS cluster and all other resources" - type = string -} - -variable "min_size" { - description = "The minimum number of worker nodes to deploy" - type = number - default = 1 -} - -variable "max_size" { - description = "The maximum number of worker nodes to deploy" - type = number - default = 10 -} - -variable "desired_size" { - description = "The desired number of worker nodes to deploy initiall" - type = number - default = 3 -} - -variable "kubernetes_version" { - description = "The version of Kubernetes to use in the EKS cluster" - type = string - default = "1.29" -} - -variable "instance_type" { - description = "The type of EC2 instance to use for worker nodes" - type = string - default = "t2.micro" -} \ No newline at end of file