diff --git a/03-basics/web-app/main.tf b/03-basics/web-app/main.tf index bf5b8bb..fde2b69 100644 --- a/03-basics/web-app/main.tf +++ b/03-basics/web-app/main.tf @@ -44,7 +44,7 @@ resource "aws_instance" "instance_2" { } resource "aws_s3_bucket" "bucket" { - bucket = "devops-directive-web-app-data" + bucket_prefix = "devops-directive-web-app-data" force_destroy = true } @@ -56,7 +56,7 @@ resource "aws_s3_bucket_versioning" "bucket_versioning" { } resource "aws_s3_bucket_server_side_encryption_configuration" "bucket_crypto_conf" { - bucket = aws_s3_bucket.bucket.bucket + bucket = aws_s3_bucket.bucket.bucket rule { apply_server_side_encryption_by_default { sse_algorithm = "AES256" @@ -203,7 +203,7 @@ resource "aws_route53_record" "root" { } resource "aws_db_instance" "db_instance" { - allocated_storage = 20 + allocated_storage = 20 # This allows any minor version within the major engine_version # defined below, but will also result in allowing AWS to auto # upgrade the minor version of your DB. This may be too risky diff --git a/04-variables-and-outputs/examples/main.tf b/04-variables-and-outputs/examples/main.tf index baf60c6..27043b3 100644 --- a/04-variables-and-outputs/examples/main.tf +++ b/04-variables-and-outputs/examples/main.tf @@ -37,7 +37,7 @@ resource "aws_db_instance" "db_instance" { allocated_storage = 20 storage_type = "gp2" engine = "postgres" - engine_version = "12.4" + engine_version = "12" instance_class = "db.t2.micro" name = "mydb" username = var.db_user diff --git a/04-variables-and-outputs/web-app/main.tf b/04-variables-and-outputs/web-app/main.tf index 34dd47b..972ea61 100644 --- a/04-variables-and-outputs/web-app/main.tf +++ b/04-variables-and-outputs/web-app/main.tf @@ -45,17 +45,22 @@ resource "aws_instance" "instance_2" { } resource "aws_s3_bucket" "bucket" { - bucket = var.bucket_name + bucket_prefix = var.bucket_prefix force_destroy = true - versioning { - enabled = true - } +} - server_side_encryption_configuration { - rule { - apply_server_side_encryption_by_default { - sse_algorithm = "AES256" - } +resource "aws_s3_bucket_versioning" "bucket_versioning" { + bucket = aws_s3_bucket.bucket.id + versioning_configuration { + status = "Enabled" + } +} + +resource "aws_s3_bucket_server_side_encryption_configuration" "bucket_crypto_conf" { + bucket = aws_s3_bucket.bucket.bucket + rule { + apply_server_side_encryption_by_default { + sse_algorithm = "AES256" } } } @@ -202,7 +207,7 @@ resource "aws_db_instance" "db_instance" { allocated_storage = 20 storage_type = "standard" engine = "postgres" - engine_version = "12.5" + engine_version = "12" instance_class = "db.t2.micro" name = var.db_name username = var.db_user diff --git a/04-variables-and-outputs/web-app/terraform.tfvars b/04-variables-and-outputs/web-app/terraform.tfvars index 52b0b73..ba2a942 100644 --- a/04-variables-and-outputs/web-app/terraform.tfvars +++ b/04-variables-and-outputs/web-app/terraform.tfvars @@ -1,5 +1,5 @@ -bucket_name = "devops-directive-web-app-data" -domain = "devopsdeployed.com" -db_name = "mydb" -db_user = "foo" +bucket_prefix = "devops-directive-web-app-data" +domain = "devopsdeployed.com" +db_name = "mydb" +db_user = "foo" # db_pass = "foobarbaz" diff --git a/04-variables-and-outputs/web-app/variables.tf b/04-variables-and-outputs/web-app/variables.tf index af9502b..aa65b52 100644 --- a/04-variables-and-outputs/web-app/variables.tf +++ b/04-variables-and-outputs/web-app/variables.tf @@ -22,8 +22,8 @@ variable "instance_type" { # S3 Variables -variable "bucket_name" { - description = "name of s3 bucket for app data" +variable "bucket_prefix" { + description = "prefix of s3 bucket for app data" type = string } diff --git a/06-organization-and-modules/web-app-module/database.tf b/06-organization-and-modules/web-app-module/database.tf index 567d7af..f372403 100644 --- a/06-organization-and-modules/web-app-module/database.tf +++ b/06-organization-and-modules/web-app-module/database.tf @@ -2,7 +2,7 @@ resource "aws_db_instance" "db_instance" { allocated_storage = 20 storage_type = "standard" engine = "postgres" - engine_version = "12.5" + engine_version = "12" instance_class = "db.t2.micro" name = var.db_name username = var.db_user diff --git a/06-organization-and-modules/web-app-module/storage.tf b/06-organization-and-modules/web-app-module/storage.tf index 584c486..176147d 100644 --- a/06-organization-and-modules/web-app-module/storage.tf +++ b/06-organization-and-modules/web-app-module/storage.tf @@ -1,15 +1,20 @@ resource "aws_s3_bucket" "bucket" { - bucket = var.bucket_name + bucket_prefix = var.bucket_prefix force_destroy = true - versioning { - enabled = true - } +} - server_side_encryption_configuration { - rule { - apply_server_side_encryption_by_default { - sse_algorithm = "AES256" - } +resource "aws_s3_bucket_versioning" "bucket_versioning" { + bucket = aws_s3_bucket.bucket.id + versioning_configuration { + status = "Enabled" + } +} + +resource "aws_s3_bucket_server_side_encryption_configuration" "bucket_crypto_conf" { + bucket = aws_s3_bucket.bucket.bucket + rule { + apply_server_side_encryption_by_default { + sse_algorithm = "AES256" } } } diff --git a/06-organization-and-modules/web-app-module/variables.tf b/06-organization-and-modules/web-app-module/variables.tf index 87c2784..5b1dfab 100644 --- a/06-organization-and-modules/web-app-module/variables.tf +++ b/06-organization-and-modules/web-app-module/variables.tf @@ -34,8 +34,8 @@ variable "instance_type" { # S3 Variables -variable "bucket_name" { - description = "name of s3 bucket for app data" +variable "bucket_prefix" { + description = "prefix of s3 bucket for app data" type = string } diff --git a/06-organization-and-modules/web-app/main.tf b/06-organization-and-modules/web-app/main.tf index 15eedf5..b66b124 100644 --- a/06-organization-and-modules/web-app/main.tf +++ b/06-organization-and-modules/web-app/main.tf @@ -37,11 +37,11 @@ module "web_app_1" { source = "../web-app-module" # Input Variables - bucket_name = "web-app-1-devops-directive-web-app-data" + bucket_prefix = "web-app-1-data" domain = "devopsdeployed.com" app_name = "web-app-1" environment_name = "production" - instance_type = "t2.small" + instance_type = "t2.micro" create_dns_zone = true db_name = "webapp1db" db_user = "foo" @@ -52,11 +52,11 @@ module "web_app_2" { source = "../web-app-module" # Input Variables - bucket_name = "web-app-2-devops-directive-web-app-data" + bucket_prefix = "web-app-2-data" domain = "anotherdevopsdeployed.com" app_name = "web-app-2" environment_name = "production" - instance_type = "t2.small" + instance_type = "t2.micro" create_dns_zone = true db_name = "webapp2db" db_user = "bar" diff --git a/07-managing-multiple-environments/file-structure/production/main.tf b/07-managing-multiple-environments/file-structure/production/main.tf index 610cd0d..6c071da 100644 --- a/07-managing-multiple-environments/file-structure/production/main.tf +++ b/07-managing-multiple-environments/file-structure/production/main.tf @@ -35,10 +35,10 @@ module "web_app" { source = "../../../06-organization-and-modules/web-app-module" # Input Variables - bucket_name = "devops-directive-web-app-data-${local.environment_name}" + bucket_prefix = "web-app-data-${local.environment_name}" domain = "devopsdeployed.com" environment_name = local.environment_name - instance_type = "t2.small" + instance_type = "t2.micro" create_dns_zone = false db_name = "${local.environment_name}mydb" db_user = "foo" diff --git a/07-managing-multiple-environments/file-structure/staging/main.tf b/07-managing-multiple-environments/file-structure/staging/main.tf index 76f35a7..eeca4c2 100644 --- a/07-managing-multiple-environments/file-structure/staging/main.tf +++ b/07-managing-multiple-environments/file-structure/staging/main.tf @@ -35,7 +35,7 @@ module "web_app" { source = "../../../06-organization-and-modules/web-app-module" # Input Variables - bucket_name = "devops-directive-web-app-data-${local.environment_name}" + bucket_prefix = "web-app-data-${local.environment_name}" domain = "devopsdeployed.com" environment_name = local.environment_name instance_type = "t2.micro" diff --git a/07-managing-multiple-environments/workspaces/main.tf b/07-managing-multiple-environments/workspaces/main.tf index bbd558f..45de6c9 100644 --- a/07-managing-multiple-environments/workspaces/main.tf +++ b/07-managing-multiple-environments/workspaces/main.tf @@ -35,10 +35,10 @@ module "web_app" { source = "../../06-organization-and-modules/web-app-module" # Input Variables - bucket_name = "devops-directive-web-app-data-${local.environment_name}" + bucket_prefix = "web-app-data-${local.environment_name}" domain = "devopsdeployed.com" environment_name = local.environment_name - instance_type = "t2.small" + instance_type = "t2.micro" create_dns_zone = terraform.workspace == "production" ? true : false db_name = "${local.environment_name}mydb" db_user = "foo" diff --git a/08-testing/tests/terratest/README.md b/08-testing/tests/terratest/README.md index a95187b..4b2f879 100644 --- a/08-testing/tests/terratest/README.md +++ b/08-testing/tests/terratest/README.md @@ -1,6 +1,7 @@ How to run this test? -Build, then run... - -`go test -v timeout 10m` - +download dependencies, then run the tests... +``` +go mod download +go test -v --timeout 10m +```