Skip to content
Commits on Source (4)
~*
*~
*.sw[op]
*.py[cod]
.DS_Store
__pycache__/
__pypackages__/
.vagrant/
vendor/
Thumbs.db
*.retry
.svn/
.sass-cache/
*.log
*.out
*.so
node_modules/
.npm/
nbproject/
*.ipynb
.idea/
*.egg-info/
*.[ao]
.classpath
.cache/
bower_components/
*.class
*.[ewj]ar
secring.*
.*.kate-swp
.swp.*
.directory
.Trash-*
build/
_build/
dist/
.tox/
*.pdf
*.exe
*.dll
*.gz
*.tgz
*.tar
*.rar
*.zip
*.xz
*.pid
*.lock
*.env
.bundle/
!Pipfile.lock
.terraform
.terraform.*
tfplan
*.tfstate*
*.venv
reports/
# Container images
This directory contains `Containerfile`s for container images.
MIT License
Copyright (c) 2021 Adar Nimrod
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Example IaC project
An example infrastructure-as-code project to show a simple project structure.
## A note on structure
This repo is first divided by the main tool used instead of by the service or
part of the infrastructure. One reason is to document the workflow with that
specific tool in just 1 place, not copied across different READMEs for each
service. Another reason is that we can more easily setup our CI/CD pipeline
trigges. For example, build a container image if files under
`Containerfiles/<service>` have changed.
## License
This software is licensed under the MIT license (see `LICENSE.txt`).
## Author Information
Nimrod Adar, [contact me](mailto:nimrod@shore.co.il) or visit my
[website](https://www.shore.co.il/). Patches are welcome via
[`git send-email`](http://git-scm.com/book/en/v2/Git-Commands-Email). The repository
is located at: <https://git.shore.co.il/explore/>.
# Packer
This directory contains manifests for Packer images.
# Terraform modules
This directory contains Terraform modules and a library of reusable modules
under `library`. Each module deploys a complete service. Although services will
be interconnected and there will be dependencies between services, the goal is
to keep the modules whole so that applying the module deploys the entire
service.
## A word on environments
Each module has a Terraform variables files (`.tfvars`) and a workspace for each
environment that service is deployed to. This puts the emphasis on keeping the
services the same across different environments with little changes, mainly for
scale (eg. 2 instances instead of 5).
## Common workflow
In this example, deploying to the dev environment. A convention is used for the
default workflow (have it be prod or dev or just not used).
```
terraform init
terraform workspace new dev
# Or if the workspace is already present:
terraform workspace select dev
terraform plan -var-file=dev.tfvars -out=tfplan
# Review the changes to be applied.
terraform apply tfplan
```
## Some more information here (like different providers, other conventions)
instance_count = 2
terraform {
backend "s3" {
bucket = "tf-states"
key = "foo.tfstate"
region = "us-east-1"
encrypt = true
dynamodb_table = "tf-locks"
}
}
locals {
env = terraform.workspace == "default" ? "prod" : terraform.workspace
module = basename(abspath(path.root))
}
provider "aws" {
default_tags {
tags = {
Environment = local.env
# Easy to track down which module created a resource.
Module = local.module
}
}
}
variable "instance_count" {
type = number
description = "The number of instances to deploy."
# If the convention is not to use the default workspace, delete the default
# value.
default = 5
}
# Terraform module library
A library of reusable modules (not to deployed by themselves).