Skip to content

Basic terraform + aws foundation, leveraging on modules when possible. It's a base to build on.

License

Notifications You must be signed in to change notification settings

NicolasMas/terraform-aws-basic-stack

Repository files navigation

A Terraform approach to building a solid infrastructure foundation on AWS

This is a WIP of a basic terraform + aws foundation code approach, trying to follow best practices. It's a base to build on. Reading the doc at https://www.terraform.io/docs/index.html is highly advised.

Setup

Requires:

  • terraform binaries on your machine - if you are a mac user, you can use the package management system homebrew https://brew.sh/ (installing it is very easy). Once you are done, open a terminal and perform a brew update && brew upgrade && brew install terraform
  • AWS account and the proper set of permission, plus a key-pair.
  • AWS CLI on your machine

Note: you might incur some small charges from AWS (unless you are still on the free tier), so it's highly recommended to destroy the infra if you are not using it.

tested with:

  • Terraform v0.9.11
  • Terraform v10.07

To run this you need to clone this repository on your local machine, then with the console go to the Singapore directory.

Once done, you need to ensure terraform works properly

| ~/Development/Singapore @ nicolasmbp (nicolasmas)
| => terraform --version
Terraform v10.07

Running it

AWS credentials setup

AWS credentials need to be stored on your local machine, under the ~/.aws/credentials file (MacOSX and Linux)

| ~/Development/Singapore @ nicolasmbp (nicolasmas)
| => cat ~/.aws/credentials
[default]
aws_access_key_id = XXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXX

[terraform-dev]
aws_access_key_id = XXXXXXXXXX
aws_secret_access_key = XXXXXXXXXX

It can be done with the following AWS CLI command (replace the profile name with whatever you like):

aws configure --profile terraform-dev

And follow the instructions. Once this is done, please modify the main.tf profile value with the profile you just created.

provider "aws" {
    profile = "terraform-dev"
    region = "${var.region}"
}

Retrieving the modules

You need to retrieve the modules (for example:)

| ~/Development/Singapore @ nicolasmbp (nicolas)
| => terraform get
Get: file:///modules/m-vpc
Get: file:///modules/m-bastion

Building the infrastructure

You are all set. Basic commands are:

terraform validate #syntax validation
terraform plan  #dry run
terraform apply #execute the code against AWS
terraform destroy #remove everything you just created from AWS

Examples

About

Basic terraform + aws foundation, leveraging on modules when possible. It's a base to build on.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published