Skip to content

metadevpro/terraform-aws-training

Repository files navigation

Terraform training

Infrastructure as Code with Terraform and AWS. Created by Metadev.

Last revision 2024.02.13

Prerequisites

  1. Git
  2. Bash Shell
  3. Editor. Recomended Visual Studio Code + Extension for Terraform
  4. SSH Client (For example: putty.exe on windows)
  5. Terraform Add it to your PATH
  6. aws-cli

To test the examples

  1. Clone the repository to local machine

    git clone git@github.com:metadevpro/terraform-aws-training.git
  2. Enter into each folder for exercices

  3. Configure your own AWS credentials exporting enviromental variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY or, alternatively set AWS_PROFILE.

  4. Create the keys/ folder and place your PEM and PPK files for execices 1, 2, and 4.

  5. Init with terraform init

  6. Validate with terraform validate

  7. Deploy with terraform apply

  8. Destroy with terraform destroy

SSH Keys

AWS requires to setup a pair of SSH keys to access the machines. To do it go to https://eu-south-2.console.aws.amazon.com/ec2/v2/home?region=eu-south-2#KeyPairs: and create a key pair. The keys must be created for an specific AWS region. In this example using Zaragoza = eu-south-2.

  • The public key will be retained by AWS.
  • The private key is the one you are downloading. (Use the PEM format.)
  • You need to place it under a keys/ folder for running examples 1, 2 and 4.

For Windows users using Putty: Putty needs the key in an special format: PPK. To convert the PEM file into a PPK use puttygen.exe to convert the key:

  1. Load the PEM file
  2. Save the private key as PPK file.

Puttygen.exe can be downloaded here.

Key Permissions

When using *.pem files for SSH (especially on Mac OS and Linux) ensure key file has read persmissions for the user only with the command:

chmod 600 <file>.pem

Examples

  1. Create an AWS EC2 virtual machine.
  2. Deploy a complete static website in S3.
  3. Create an AWS EC2 virtual machine + docker containers.
  4. Create a complete CI Server: Teamcity with EC2 and docker.

Disclaimer

Using samples in AWS accounts will incurr in small charges. Remember always to destroy your resources after finalizing the training if not in use.

License

Licensed under CC BY CC BY (c) Metadev 2021-2024.

About

Terraform+AWS training and samples

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published