add modules 5-9

This commit is contained in:
sid palas
2021-05-27 14:35:03 -07:00
parent 1d095e337a
commit 4de9385fce
34 changed files with 1331 additions and 87 deletions

View File

@@ -0,0 +1,11 @@
- Note about using separate AWS projects (avoids prefix issues, improved IAM control)
- Cover this in advanced section?
```
provider “aws” {
region = “us-east-1”
assume_role {
role_arn = “arn:aws:iam::123456789012:role/iac”
}
}
```

View File

@@ -0,0 +1,46 @@
terraform {
# Assumes s3 bucket and dynamo DB table already set up
# See /code/03-basics/aws-backend
backend "s3" {
bucket = "devops-directive-tf-state"
key = "07-managing-multiple-environments/production/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-state-locking"
encrypt = true
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
variable "db_pass" {
description = "password for database"
type = string
sensitive = true
}
locals {
environment_name = "production"
}
module "web_app" {
source = "../../../06-organization-and-modules/web-app-module"
# Input Variables
bucket_name = "devops-directive-web-app-data-${local.environment_name}"
domain = "mysuperawesomesite.com"
environment_name = local.environment_name
instance_type = "t2.small"
create_dns_zone = true
db_name = "${local.environment_name}mydb"
db_user = "foo"
db_pass = var.db_pass
}

View File

@@ -0,0 +1,46 @@
terraform {
# Assumes s3 bucket and dynamo DB table already set up
# See /code/03-basics/aws-backend
backend "s3" {
bucket = "devops-directive-tf-state"
key = "07-managing-multiple-environments/staging/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-state-locking"
encrypt = true
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
variable "db_pass" {
description = "password for database"
type = string
sensitive = true
}
locals {
environment_name = "staging"
}
module "web_app" {
source = "../../../06-organization-and-modules/web-app-module"
# Input Variables
bucket_name = "devops-directive-web-app-data-${local.environment_name}"
domain = "mysuperawesomesite.com"
environment_name = local.environment_name
instance_type = "t2.micro"
create_dns_zone = false
db_name = "${local.environment_name}mydb"
db_user = "foo"
db_pass = var.db_pass
}