Skip to content

padhle/some_code

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Exercise

You are supplied with an initial terraform solution, your task is to follow the instructions below and update the given terraform in order to solve the steps. You are given a local GIT repository, after each step, you should commit your code including any appropriate comments. DO NOT push the code to a remote repository, upon completion please ZIP the WHOLE folder including the .git folder and any other subfolders you have created but EXCLUDING the generated .terraform folders and send to CPP for review.

DO NOT send any access tokens or other credentials within the code.

General Guidelines

  1. The provided solution MUST work correctly when "terrafrom init" and "terraform apply" are ran against it. There should be no syntax or other errors.

  2. The code should be be constructed as module(s) that accept input parameters and define outputs. Where necessary, terraform functionality such as loops, conditions, etc should be used to efficiently deploy the resources across multiple environments. Assume additional environments may be required in future.

  3. The code should work for DIFFERENT environments without any changes other than to variable files

  4. ALL resources should INCLUDE a set of default tags, whilst allowing additional tags to be specified where required. Additional tags provided as a parameter should be accepted and merged with the following defaults:

The default tags for all resources are:

  • resource-name
  • environment
  • region
  • source (this is terraform)
  • creation time (this should be fixed across subsequent terraform apply commands)
  1. Where necessary define outputs and/or variables as required by the requirements. Feel free to add any other useful outputs or optional variables.

  2. The terraform should be structured in multiple files for readability. All required terraform should be provided, this includes but isn't limited to:

    • main
    • variables
    • outputs
    • data
    • providers
  3. All mandatory properties should be defined against a resource, include where appropriate any optional resource properties as deemed necessary

  4. Add any supporting comments in the code

  5. Use the access and secret keys below to query resources as required. The ap-south-1 (mumbai) region should be used throughout AKIAUZHJCWUETMQMM5MT - rlnKod9oeWeO8ksLOMOO+6J0jo3Ug8R8XP+SCaNV

steps

  1. Add tfvars files for any defined variables, create one each for test and production environments. Update these files as required for the subsequent steps.
  2. Add the missing tags to the current resources (source, environment, region & creation time). Add these tags to all new resources.
  3. Split the EC2 and subnet resources into 2 different modules, add any additional files to support parameters for each resource. Create parameters for each resource in the module and output appropriate values. Use these modules in main.tf
  4. Set the ec2 instance size to be t3.medium in test and c5.large in production
  5. Modify the subnet definition such that it uses the second available /24 subnet in the given VPC. This should be calculated, for example if the VPC was 172.1.0.0/16 then the subnet should be 172.1.1.0/24. The VPC CIDR block should be obtained from AWS
  6. Add an EBS volume taking a size which is either 8 for test or 16Gb for production. This shouldn't be hardcoded
  7. Add a security group for the EC2 instance, it should accept a list of TCP ports that are opened to public incoming traffic. For test these should be 22, 456 & 1234 , for production they should be 21 & 567.
  8. Add a module for an RDS (mysql) instance. It should have as a baseline the following config: test - single t3.medium node, 8gb storage production - multi-az c5.large node, 16gb storage
  9. Add an Elastic IP to the EC2 instance and return the value as an output
  10. Add a NAT gateway to the VPC in each of the availability zones - you should lookup the availability zones

About

just a shell script

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 92.3%
  • Shell 7.7%