From 7dd9a655e5654291e29332b6f43c8065ad60a11b Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Thu, 10 Feb 2022 14:43:34 -0500 Subject: [PATCH] fix: Pin version to v3 due to number of breaking changes in v4 (#136) Co-authored-by: Anton Babenko --- .gitignore | 2 ++ .pre-commit-config.yaml | 2 +- README.md | 4 ++-- examples/complete/README.md | 4 ++-- examples/complete/main.tf | 12 ++++++++++++ examples/complete/versions.tf | 10 ++++++++-- examples/notification/.gitignore | 1 - examples/notification/README.md | 4 ++-- examples/notification/main.tf | 12 ++++++++++++ examples/notification/versions.tf | 15 ++++++++++++--- examples/object/.gitignore | 1 - examples/object/README.md | 4 ++-- examples/object/main.tf | 6 +++++- examples/object/versions.tf | 10 ++++++++-- examples/s3-replication/README.md | 6 +++--- examples/s3-replication/main.tf | 28 +++++++++++++++++++++------- examples/s3-replication/versions.tf | 10 ++++++++-- modules/notification/README.md | 4 ++-- modules/notification/main.tf | 8 ++++---- modules/notification/versions.tf | 5 ++++- modules/object/README.md | 4 ++-- modules/object/versions.tf | 5 ++++- versions.tf | 5 ++++- 23 files changed, 120 insertions(+), 42 deletions(-) delete mode 100644 examples/notification/.gitignore delete mode 100644 examples/object/.gitignore diff --git a/.gitignore b/.gitignore index 397af322..bd2b8f33 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ override.tf.json # Ignore CLI configuration files .terraformrc terraform.rc + +*.zip diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 093121e0..8a010fdd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.62.3 + rev: v1.64.0 hooks: - id: terraform_fmt - id: terraform_validate diff --git a/README.md b/README.md index 3c3a95bf..5223ecee 100644 --- a/README.md +++ b/README.md @@ -108,13 +108,13 @@ inputs = { | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.69 | +| [aws](#requirement\_aws) | ~> 3.69 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.69 | +| [aws](#provider\_aws) | ~> 3.69 | ## Modules diff --git a/examples/complete/README.md b/examples/complete/README.md index 6971346e..9dae0710 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -30,14 +30,14 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.60 | +| [aws](#requirement\_aws) | ~> 3.69 | | [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.60 | +| [aws](#provider\_aws) | ~> 3.69 | | [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/complete/main.tf b/examples/complete/main.tf index 33e7c4ac..f4b18fd7 100644 --- a/examples/complete/main.tf +++ b/examples/complete/main.tf @@ -1,5 +1,17 @@ +provider "aws" { + region = local.region + + # Make it faster by skipping something + skip_get_ec2_platforms = true + skip_metadata_api_check = true + skip_region_validation = true + skip_credentials_validation = true + skip_requesting_account_id = true +} + locals { bucket_name = "s3-bucket-${random_pet.this.id}" + region = "eu-west-1" } data "aws_canonical_user_id" "current" {} diff --git a/examples/complete/versions.tf b/examples/complete/versions.tf index 92ae3442..57a001e6 100644 --- a/examples/complete/versions.tf +++ b/examples/complete/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.60" - random = ">= 2.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.69" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/notification/.gitignore b/examples/notification/.gitignore deleted file mode 100644 index c4c4ffc6..00000000 --- a/examples/notification/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.zip diff --git a/examples/notification/README.md b/examples/notification/README.md index 87d246d3..1819f4d2 100644 --- a/examples/notification/README.md +++ b/examples/notification/README.md @@ -20,7 +20,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.50 | +| [aws](#requirement\_aws) | ~> 3.69 | | [null](#requirement\_null) | >= 2.0 | | [random](#requirement\_random) | >= 2.0 | @@ -28,7 +28,7 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.50 | +| [aws](#provider\_aws) | ~> 3.69 | | [null](#provider\_null) | >= 2.0 | | [random](#provider\_random) | >= 2.0 | diff --git a/examples/notification/main.tf b/examples/notification/main.tf index 116c70ed..71788bf5 100644 --- a/examples/notification/main.tf +++ b/examples/notification/main.tf @@ -1,5 +1,17 @@ +provider "aws" { + region = local.region + + # Make it faster by skipping something + skip_get_ec2_platforms = true + skip_metadata_api_check = true + skip_region_validation = true + skip_credentials_validation = true + skip_requesting_account_id = true +} + locals { bucket_name = "s3-bucket-${random_pet.this.id}" + region = "eu-west-1" } resource "random_pet" "this" { diff --git a/examples/notification/versions.tf b/examples/notification/versions.tf index fa4f83a8..4dee4042 100644 --- a/examples/notification/versions.tf +++ b/examples/notification/versions.tf @@ -2,8 +2,17 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.50" - random = ">= 2.0" - null = ">= 2.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.69" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } + null = { + source = "hashicorp/null" + version = ">= 2.0" + } } } diff --git a/examples/object/.gitignore b/examples/object/.gitignore deleted file mode 100644 index c4c4ffc6..00000000 --- a/examples/object/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.zip diff --git a/examples/object/README.md b/examples/object/README.md index 8dcadb39..c24cbc33 100644 --- a/examples/object/README.md +++ b/examples/object/README.md @@ -20,14 +20,14 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.50 | +| [aws](#requirement\_aws) | ~> 3.69 | | [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.50 | +| [aws](#provider\_aws) | ~> 3.69 | | [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/object/main.tf b/examples/object/main.tf index b0fdc156..1aca0f0e 100644 --- a/examples/object/main.tf +++ b/examples/object/main.tf @@ -1,5 +1,5 @@ provider "aws" { - region = "eu-west-1" + region = local.region # Make it faster by skipping something skip_get_ec2_platforms = true @@ -9,6 +9,10 @@ provider "aws" { skip_requesting_account_id = true } +locals { + region = "eu-west-1" +} + module "object" { source = "../../modules/object" diff --git a/examples/object/versions.tf b/examples/object/versions.tf index b23248e5..57a001e6 100644 --- a/examples/object/versions.tf +++ b/examples/object/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.50" - random = ">= 2.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.69" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/examples/s3-replication/README.md b/examples/s3-replication/README.md index 92a03d3b..f70b1ea2 100644 --- a/examples/s3-replication/README.md +++ b/examples/s3-replication/README.md @@ -22,15 +22,15 @@ Note that this example may create resources which cost money. Run `terraform des | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.69 | +| [aws](#requirement\_aws) | ~> 3.69 | | [random](#requirement\_random) | >= 2.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.69 | -| [aws.replica](#provider\_aws.replica) | >= 3.69 | +| [aws](#provider\_aws) | ~> 3.69 | +| [aws.replica](#provider\_aws.replica) | ~> 3.69 | | [random](#provider\_random) | >= 2.0 | ## Modules diff --git a/examples/s3-replication/main.tf b/examples/s3-replication/main.tf index 904abbf3..b9e5b197 100644 --- a/examples/s3-replication/main.tf +++ b/examples/s3-replication/main.tf @@ -1,18 +1,32 @@ -locals { - bucket_name = "origin-s3-bucket-${random_pet.this.id}" - destination_bucket_name = "replica-s3-bucket-${random_pet.this.id}" - origin_region = "eu-west-1" - replica_region = "eu-central-1" -} - provider "aws" { region = local.origin_region + + # Make it faster by skipping something + skip_get_ec2_platforms = true + skip_metadata_api_check = true + skip_region_validation = true + skip_credentials_validation = true + skip_requesting_account_id = true } provider "aws" { region = local.replica_region alias = "replica" + + # Make it faster by skipping something + skip_get_ec2_platforms = true + skip_metadata_api_check = true + skip_region_validation = true + skip_credentials_validation = true + skip_requesting_account_id = true +} + +locals { + bucket_name = "origin-s3-bucket-${random_pet.this.id}" + destination_bucket_name = "replica-s3-bucket-${random_pet.this.id}" + origin_region = "eu-west-1" + replica_region = "eu-central-1" } data "aws_caller_identity" "current" {} diff --git a/examples/s3-replication/versions.tf b/examples/s3-replication/versions.tf index c02358ca..57a001e6 100644 --- a/examples/s3-replication/versions.tf +++ b/examples/s3-replication/versions.tf @@ -2,7 +2,13 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.69" - random = ">= 2.0" + aws = { + source = "hashicorp/aws" + version = "~> 3.69" + } + random = { + source = "hashicorp/random" + version = ">= 2.0" + } } } diff --git a/modules/notification/README.md b/modules/notification/README.md index 1d49f4f2..824715c7 100644 --- a/modules/notification/README.md +++ b/modules/notification/README.md @@ -8,13 +8,13 @@ Creates S3 bucket notification resource with all supported types of deliveries: | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.28 | +| [aws](#requirement\_aws) | ~> 3.28 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.28 | +| [aws](#provider\_aws) | ~> 3.28 | ## Modules diff --git a/modules/notification/main.tf b/modules/notification/main.tf index ec7ed26a..8bd7405e 100644 --- a/modules/notification/main.tf +++ b/modules/notification/main.tf @@ -75,7 +75,7 @@ data "aws_arn" "queue" { } data "aws_iam_policy_document" "sqs" { - for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({}) + for_each = { for k, v in var.sqs_notifications : k => v if var.create_sqs_policy } statement { sid = "AllowSQSS3BucketNotification" @@ -102,7 +102,7 @@ data "aws_iam_policy_document" "sqs" { } resource "aws_sqs_queue_policy" "allow" { - for_each = var.create_sqs_policy ? var.sqs_notifications : tomap({}) + for_each = { for k, v in var.sqs_notifications : k => v if var.create_sqs_policy } queue_url = lookup(each.value, "queue_id", lookup(local.queue_ids, each.key, null)) policy = data.aws_iam_policy_document.sqs[each.key].json @@ -110,7 +110,7 @@ resource "aws_sqs_queue_policy" "allow" { # SNS Topic data "aws_iam_policy_document" "sns" { - for_each = var.create_sns_policy ? var.sns_notifications : tomap({}) + for_each = { for k, v in var.sns_notifications : k => v if var.create_sns_policy } statement { sid = "AllowSNSS3BucketNotification" @@ -137,7 +137,7 @@ data "aws_iam_policy_document" "sns" { } resource "aws_sns_topic_policy" "allow" { - for_each = var.create_sns_policy ? var.sns_notifications : tomap({}) + for_each = { for k, v in var.sns_notifications : k => v if var.create_sns_policy } arn = each.value.topic_arn policy = data.aws_iam_policy_document.sns[each.key].json diff --git a/modules/notification/versions.tf b/modules/notification/versions.tf index 97ec7511..9324c89a 100644 --- a/modules/notification/versions.tf +++ b/modules/notification/versions.tf @@ -2,6 +2,9 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.28" + aws = { + source = "hashicorp/aws" + version = "~> 3.28" + } } } diff --git a/modules/object/README.md b/modules/object/README.md index 62ff5074..9656be3f 100644 --- a/modules/object/README.md +++ b/modules/object/README.md @@ -8,13 +8,13 @@ Creates S3 bucket objects with different configurations. | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.36 | +| [aws](#requirement\_aws) | ~> 3.36 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.36 | +| [aws](#provider\_aws) | ~> 3.36 | ## Modules diff --git a/modules/object/versions.tf b/modules/object/versions.tf index ca4d5ea9..fd876394 100644 --- a/modules/object/versions.tf +++ b/modules/object/versions.tf @@ -2,6 +2,9 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.36" + aws = { + source = "hashicorp/aws" + version = "~> 3.36" + } } } diff --git a/versions.tf b/versions.tf index a4e6edb4..126d7041 100644 --- a/versions.tf +++ b/versions.tf @@ -2,6 +2,9 @@ terraform { required_version = ">= 0.13.1" required_providers { - aws = ">= 3.69" + aws = { + source = "hashicorp/aws" + version = "~> 3.69" + } } }