Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moves iam role conditions to trust policy instead of role policy #324

Merged
merged 2 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.0.0
current_version = 3.0.1
commit = True
message = Bumps version to {new_version}
tag = False
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

### [3.0.1](https://github.com/plus3it/terraform-aws-tardigrade-vpc-flow-log/releases/tag/3.0.1)

**Released**: 2024.11.22

**Summary**:

* Moves iam role conditions to trust policy instead of role policy, per aws guidance
for mitigating confused deputy problem. See also:
* https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs-iam-role.html
* https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html

### [3.0.0](https://github.com/plus3it/terraform-aws-tardigrade-vpc-flow-log/releases/tag/3.0.0)

**Released**: 2024.11.20
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Terraform module to create a VPC Flow Log
| [aws_iam_policy_document.cloudwatch_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.cloudwatch_trust](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_partition.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
| [aws_region.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |

## Inputs

Expand Down
29 changes: 14 additions & 15 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ locals {

account_id = data.aws_caller_identity.this.account_id
partition = data.aws_partition.this.partition
region = data.aws_region.this.name
}

data "aws_caller_identity" "this" {}
data "aws_partition" "this" {}
data "aws_region" "this" {}

data "aws_iam_policy_document" "cloudwatch_policy" {
count = local.create_cloudwatch_iam_role ? 1 : 0
Expand All @@ -118,21 +120,6 @@ data "aws_iam_policy_document" "cloudwatch_policy" {
"arn:${local.partition}:logs:*:*:log-group:${local.log_group_name}",
"arn:${local.partition}:logs:*:*:log-group:${local.log_group_name}:*",
]

condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [local.account_id]
}

condition {
test = "ArnLike"
variable = "aws:SourceArn"
values = [
"arn:${local.partition}:logs:*:*:log-group:${local.log_group_name}",
"arn:${local.partition}:logs:*:*:log-group:${local.log_group_name}:*",
]
}
}
}

Expand All @@ -146,5 +133,17 @@ data "aws_iam_policy_document" "cloudwatch_trust" {
type = "Service"
identifiers = ["vpc-flow-logs.amazonaws.com"]
}

condition {
test = "StringEquals"
variable = "aws:SourceAccount"
values = [local.account_id]
}

condition {
test = "ArnLike"
variable = "aws:SourceArn"
values = ["arn:aws:ec2:${local.region}:${local.account_id}:vpc-flow-log/*"]
}
}
}