Skip to content

Commit

Permalink
Merge pull request #11 from cloudandthings/2023-12-18-aws-provider-v5
Browse files Browse the repository at this point in the history
fix: Bump AWS provider to v5
  • Loading branch information
baolsen authored Dec 18, 2023
2 parents da598ca + 6f6541d commit 31eab5f
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ No modules.

| Name | Description |
|------|-------------|
| <a name="output_arn"></a> [arn](#output\_arn) | The bucket ARN that is created. |
| <a name="output_bucket"></a> [bucket](#output\_bucket) | The bucket that is created. |
| <a name="output_bucket_arn"></a> [bucket\_arn](#output\_bucket\_arn) | The bucket ARN that is created. |
| <a name="output_bucket_id"></a> [bucket\_id](#output\_bucket\_id) | The bucket id that is created. |
| <a name="output_default_bucket_policy_document"></a> [default\_bucket\_policy\_document](#output\_default\_bucket\_policy\_document) | Default bucket policy document, attached to the bucket if `var.attach_default_bucket_policy=true`. |
| <a name="output_id"></a> [id](#output\_id) | The bucket id that is created. |
| <a name="output_kms_key_id"></a> [kms\_key\_id](#output\_kms\_key\_id) | The KMS key ID used for encrypting bucket objects. |
| <a name="output_region"></a> [region](#output\_region) | The bucket region. |

Expand All @@ -90,15 +90,15 @@ No modules.

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.9 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 |

----
### Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.9 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | ~> 3.1 |

----
Expand Down
27 changes: 25 additions & 2 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@ resource "aws_kms_key" "key" {
deletion_window_in_days = 7
}
# Optional KMS key policy.
data "aws_caller_identity" "current" {}
resource "aws_kms_key_policy" "key" {
key_id = aws_kms_key.key.id
policy = jsonencode({
Id = "example"
Statement = [
{
Action = "kms:*"
Effect = "Allow"
Principal = {
AWS = data.aws_caller_identity.current.account_id
}
Resource = "*"
Sid = "Enable IAM User Permissions"
},
]
Version = "2012-10-17"
})
}
#--------------------------------------------------------------------------------------
# Example
#--------------------------------------------------------------------------------------
Expand Down Expand Up @@ -73,7 +94,7 @@ module "example" {

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.9 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 |
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.4 |

----
Expand All @@ -82,7 +103,7 @@ module "example" {
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.9 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.4 |

----
Expand All @@ -91,7 +112,9 @@ module "example" {
| Name | Type |
|------|------|
| [aws_kms_key.key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource |
| [aws_kms_key_policy.key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key_policy) | resource |
| [random_integer.naming](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |

----
<!-- END_TF_DOCS -->
21 changes: 21 additions & 0 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@ resource "aws_kms_key" "key" {
deletion_window_in_days = 7
}

# Optional KMS key policy.
data "aws_caller_identity" "current" {}
resource "aws_kms_key_policy" "key" {
key_id = aws_kms_key.key.id
policy = jsonencode({
Id = "example"
Statement = [
{
Action = "kms:*"
Effect = "Allow"
Principal = {
AWS = data.aws_caller_identity.current.account_id
}
Resource = "*"
Sid = "Enable IAM User Permissions"
},
]
Version = "2012-10-17"
})
}

#--------------------------------------------------------------------------------------
# Example
#--------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ terraform {
aws = {
source = "hashicorp/aws"
# V5+ does not exist yet, may contain breaking changes.
version = "~> 4.9"
version = "~> 5.0"
}
random = {
source = "hashicorp/random"
Expand Down
4 changes: 2 additions & 2 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "bucket_arn" {
output "arn" {
description = "The bucket ARN that is created."
value = aws_s3_bucket.this.arn
}
Expand All @@ -8,7 +8,7 @@ output "bucket" {
value = aws_s3_bucket.this.bucket
}

output "bucket_id" {
output "id" {
description = "The bucket id that is created."
value = aws_s3_bucket.this.id
}
Expand Down
4 changes: 2 additions & 2 deletions terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
# V5+ does not exist yet, may contain breaking changes.
version = "~> 4.9"
# V6+ does not exist yet, may contain breaking changes.
version = "~> 5.0"
}
null = { # Delete me
source = "hashicorp/null"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_examples_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def test_s3_bucket_policy(output):
f"arn:aws:s3:::{bucket_name}/*",
]
assert set(statement["Resource"]) == set(expected_resources)
assert "false" == statement["Condition"]["Bool"]["aws:SecureTransport"][0]
assert "false" == statement["Condition"]["Bool"]["aws:SecureTransport"]

# ### Compare apparent to actual
# Change ["false"] to "false" so the next comparison passes
if "false" == statement["Condition"]["Bool"]["aws:SecureTransport"][0]:
if "false" == statement["Condition"]["Bool"]["aws:SecureTransport"]:
statement["Condition"]["Bool"]["aws:SecureTransport"] = "false"

apparent_bucket_policy["Statement"] = [statement]
Expand Down

0 comments on commit 31eab5f

Please sign in to comment.