From 05a050af920a369caa53be74eaa11a122dae76ac Mon Sep 17 00:00:00 2001 From: Mikael Davis Date: Fri, 1 Nov 2024 15:40:31 -0400 Subject: [PATCH] add initial files and README --- .../terraform/.gitignore | 61 +++++++++++++++++++ .../terraform/README.md | 59 ++++++++++++++++++ .../terraform/main.tf | 13 ++++ .../terraform/terraform.tfvars.example | 3 + .../terraform/variables.tf | 6 ++ 5 files changed, 142 insertions(+) create mode 100644 {{cookiecutter.project_slug}}/terraform/.gitignore create mode 100644 {{cookiecutter.project_slug}}/terraform/README.md create mode 100644 {{cookiecutter.project_slug}}/terraform/main.tf create mode 100644 {{cookiecutter.project_slug}}/terraform/terraform.tfvars.example create mode 100644 {{cookiecutter.project_slug}}/terraform/variables.tf diff --git a/{{cookiecutter.project_slug}}/terraform/.gitignore b/{{cookiecutter.project_slug}}/terraform/.gitignore new file mode 100644 index 000000000..acac2de52 --- /dev/null +++ b/{{cookiecutter.project_slug}}/terraform/.gitignore @@ -0,0 +1,61 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +crash.*.log + +# Exclude all .tfvars files, which are likely to contain sensitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +*.tfvars +*.tfvars.json + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc + +# Ignore Mac/OSX system files +.DS_Store + +# Ignore any compiled binaries +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Ignore any log files +*.log + +# Ignore the dist folder which might contain built artifacts +dist/ + +# Ignore any local environment files +.env + +# Ignore any temporary files +*.tmp +*.bak +*.swp + +# Ignore .pem files +*.pem \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/terraform/README.md b/{{cookiecutter.project_slug}}/terraform/README.md new file mode 100644 index 000000000..2987524c0 --- /dev/null +++ b/{{cookiecutter.project_slug}}/terraform/README.md @@ -0,0 +1,59 @@ +# Terraform AWS Configuration + +This folder contains the files necessary to deploy a front-end app, server, and database to AWS. + +## Quickstart + +`cd` into to this folder, then run: + +``` +terraform init +terraform plan +terraform apply +``` + +## Prerequisites + +### 1. [Install AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions) + +### 2. Configure AWS Profile + +Log in to the [console](https://aws.amazon.com/console), and [generate an access key](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-key-self-managed.html). Then set up a profile for this account locally by running the following command: + +``` +aws configure --profile +``` + +### 3. Initialize Terraform + +If it's your first time deploying from this directory, run `terraform init`. This will download + +### 4. Deploy + +`terraform plan` + +## Reference + +### Terraform + +- [Terraform Docs](https://developer.hashicorp.com/terraform/intro) - _On this page there's a helpful 18 minute video on what Terraform is and how it works, worth watching_ +- [Terraform AWS Tutorial](https://developer.hashicorp.com/terraform/tutorials/aws-get-started) - _You can start from the top and go through everything, or just pick a section you'd like to understand better_ +- [Terraform AWS Provider Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) - _This is where you'll find all the details for configuring each of the resources in these configuration files_ + +### AWS + +#### Networking + +- [VPC User Guide](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) - _For understanding `Subnets`, `Route Tables`, and `Internet Gateways`. Also explains `Security Groups`, a fundamental concept_ +- [ELB User Guide](https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/what-is-load-balancing.html) - _For understanding `Load Balancers`, `Listeners`, and `Target Groups`_ + +#### Access Management + +- [IAM User Guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started.html) - _For understanding IAM `Identities`, `Roles`, and `Policies`_ + +#### Database + +- [RDS User Guide](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html) - _For understanding database deployment details_ + +#### Application Deployment +- [ECS Docs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html) - _For understanding how to run Dockerized applications_ \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/terraform/main.tf b/{{cookiecutter.project_slug}}/terraform/main.tf new file mode 100644 index 000000000..31d7843bf --- /dev/null +++ b/{{cookiecutter.project_slug}}/terraform/main.tf @@ -0,0 +1,13 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } +} + +provider "aws" { + region = "us-east-1" + profile = var.aws_profile +} \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/terraform/terraform.tfvars.example b/{{cookiecutter.project_slug}}/terraform/terraform.tfvars.example new file mode 100644 index 000000000..3a59960fb --- /dev/null +++ b/{{cookiecutter.project_slug}}/terraform/terraform.tfvars.example @@ -0,0 +1,3 @@ +# This file is where you can store values for variables that are declared in your configuration +# If you provide a value here, you won't be prompted for each value when running `terraform apply` +profile="tn-staging" \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/terraform/variables.tf b/{{cookiecutter.project_slug}}/terraform/variables.tf new file mode 100644 index 000000000..396a8532f --- /dev/null +++ b/{{cookiecutter.project_slug}}/terraform/variables.tf @@ -0,0 +1,6 @@ +# This file is where you'll store any variables used in your configuration +variable "aws_profile" { + type = string + description = "The AWS profile to use for deployment" + default = "default" +} \ No newline at end of file