From 995fb312d7ff0fdbe04a167e8d33e9f6209596a2 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 31 Aug 2022 11:18:53 +0200 Subject: [PATCH 1/2] simplify prerequisites docs --- 0-bootstrap/README.md | 4 ++++ README.md | 12 +----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/0-bootstrap/README.md b/0-bootstrap/README.md index ad5afae..65c01f3 100644 --- a/0-bootstrap/README.md +++ b/0-bootstrap/README.md @@ -2,6 +2,10 @@ Let’s get started by bootstrapping Terraform and out AWS environment. +## IDE +For the whole workshop we recommend to set up your IDE with Terraform support or to use an IDE with Terraform support +(e.g. [VS Code](https://code.visualstudio.com/) / [Terraform extension](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform)) + ## AWS credentials setup Before you start you will need diff --git a/README.md b/README.md index 8d8f57c..c87e34e 100644 --- a/README.md +++ b/README.md @@ -12,21 +12,11 @@ The workshop empowers you to know the core concepts of *infrastructure as code* * ✅ Deploy multiple environments (e.g. staging and prod) * ✅ Implement a feature flag and learn more about parameterization - -## 👾 Prerequisites - -Before jumping to the first lab, please double-check the list and prepare your computer. - -- Follow the instructions in the [bootstrap section](./0-bootstrap) -- [Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli) -- [AWS credentials in the terminal](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) -- IDE with Terraform support (e.g. [VS Code](https://code.visualstudio.com/) / [Terraform extension](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform)) -- [tfenv (recommended)](https://github.com/tfutils/tfenv) - ## 🤓 Labs We recommend you walk through the labs step by step and follow the instructions. Feel free to further extend the stack, play around with resources and dive deeper. Have fun ✌️ +0. [Boostrap Environment](./0-bootstrap) Please double-check the instructions and set up your working environment 1. [Getting Started](./1-getting-started): Get started with Terraform, deploy some AWS resources, and create a remote backend for the Terraform state 2. [Third Party](./2-third-party/): Use a third-party *module* to easily build and deploy an AWS Lambda function 3. [Module Composition](./3-module-composition/): Improve the growing codebase by introducing custom modules and module composition From 512488de6fc243067553b6b2c760cf3e28cc6127 Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 31 Aug 2022 11:46:26 +0200 Subject: [PATCH 2/2] indicate more precise where the bucket name needs to go --- 1-getting-started/README.md | 6 +++--- 1-getting-started/main.tf | 5 +++++ 2-third-party/README.md | 4 ++-- 3-module-composition/README.md | 4 ++-- 5-parameterization/README.md | 8 ++++---- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/1-getting-started/README.md b/1-getting-started/README.md index 9346803..ed32290 100644 --- a/1-getting-started/README.md +++ b/1-getting-started/README.md @@ -47,7 +47,7 @@ Let’s extend the stack and deploy more resources: ``` -3. Replace the `main.tf` file: +3. Replace the `main.tf` file with: ```tf terraform { required_version = "~> 1.1.7" @@ -107,8 +107,8 @@ Before we continue and go to the next lab, we need to talk about the Terraform s Until now, we used local files for the Terraform state. That’s okay for a workshop but doesn’t work for production workloads. The problem is, that we always need the state to apply changes. So if you want to work on the same stack with a team or some form of automation, then you need to share the state with others. The recommended solution is a remote backend. In this workshop, we focus on an S3 bucket, but you have [different options](https://www.terraform.io/language/settings/backends). Instead of keeping the state locally, we upload the state to the S3 bucket and read the current status from there. -1. Create a new S3 bucket in the [AWS Management Console](https://s3.console.aws.amazon.com/s3/bucket/create?region=eu-central-1). Copy the name of the bucket afterward. -2. Go to the file `main.tf` and replace it: +1. Create a new S3 bucket in the [AWS Management Console](https://s3.console.aws.amazon.com/s3/bucket/create?region=eu-central-1). Copy the name of the bucket and keep for use in **step 3** as well as other workshop units. +2. Go to the file `main.tf` and replace it with: ```tf terraform { required_version = "~> 1.1.7" diff --git a/1-getting-started/main.tf b/1-getting-started/main.tf index 5ca8c2f..2203408 100644 --- a/1-getting-started/main.tf +++ b/1-getting-started/main.tf @@ -1,5 +1,10 @@ terraform { required_version = "~> 1.1.7" + + backend "s3" { + key = "terraform.tfstate" + region = "eu-central-1" + } } provider "aws" { diff --git a/2-third-party/README.md b/2-third-party/README.md index db2d4c4..02c1605 100644 --- a/2-third-party/README.md +++ b/2-third-party/README.md @@ -14,7 +14,7 @@ In the first lab, we bootstrapped Terraform and got familiar with the very basic }; }; ``` -4. Now, go back to the `main.tf` file and replace it: +4. Now, go back to the `main.tf` file and replace it with: ```tf terraform { required_version = "~> 1.1.7" @@ -82,7 +82,7 @@ That’s it for the Lambda function. Let’s go to the API Gateway. ## API Gateway -1. Replace the `main.tf` file: +1. Replace the `main.tf` file with: ```tf terraform { required_version = "~> 1.1.7" diff --git a/3-module-composition/README.md b/3-module-composition/README.md index 501e42f..82e7d06 100644 --- a/3-module-composition/README.md +++ b/3-module-composition/README.md @@ -100,7 +100,7 @@ The previous lab introduced a third-party module to easily deploy a Lambda funct value = "http://${aws_s3_bucket_website_configuration.website.website_endpoint}" } ``` -17. Replace the root `main.tf` file: +17. Replace the root `main.tf` file with: ```tf terraform { required_version = "~> 1.1.7" @@ -123,7 +123,7 @@ The previous lab introduced a third-party module to easily deploy a Lambda funct source = "./modules/api" } ``` -18. Replace the root `outputs.tf` file: +18. Replace the root `outputs.tf` file with: ```tf output "api_url" { description = "Hello World API URL" diff --git a/5-parameterization/README.md b/5-parameterization/README.md index 8f7ce74..591610c 100644 --- a/5-parameterization/README.md +++ b/5-parameterization/README.md @@ -4,7 +4,7 @@ The API becomes more powerful in this lab, but we want to be careful and only ro ## Implement new feature -1. Go to the file `modules/api/variables.tf` and replace it: +1. Go to the file `modules/api/variables.tf` and replace it with: ``` variable "environment" { @@ -19,7 +19,7 @@ variable "enable_greeting_feature" { } ``` -2. Go to the file `modules/api/main.tf` and replace it: +2. Go to the file `modules/api/main.tf` and replace it with: ```tf locals { @@ -54,7 +54,7 @@ resource "aws_apigatewayv2_api" "hello_world" { } ``` -3. Go to the file `modules/api/functions/helloworld.js` and replace it: +3. Go to the file `modules/api/functions/helloworld.js` and replace it with: ```js const greetingEnabled = process.env.GREETING_ENABLED === "true"; @@ -77,7 +77,7 @@ The new feature wouldn’t appear after deployment (feel free to try it and depl ## Rollout -1. Go to the file `staging/main.tf` and replace it: +1. Go to the file `staging/main.tf` and replace it with: ```tf terraform {