terraform-aws-vpc icon indicating copy to clipboard operation
terraform-aws-vpc copied to clipboard

when using an existing cloudwatch log group for flow logs, `vpc_flow_log_cloudwatch` policy breaks

Open danielmklein opened this issue 1 year ago β€’ 16 comments

Description

When using this module with a pre-existing cloudwatch log groups to be used for the flow log destination, the recent change in 5.12 that attempts to make the flow log policy least-privilege results in an invalid policy document (because there are no resources in the policy).

  • [x] βœ‹ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [5.12+]:

  • Terraform version: 1.7.5

  • Provider version(s): aws v5.62.0 vpc v5.13.0

Reproduction Code [Required]

data "aws_availability_zones" "available" {}

locals {
  availability_zones = [
    data.aws_availability_zones.available.names[0],
    data.aws_availability_zones.available.names[1],
    data.aws_availability_zones.available.names[2]
  ]
  vpc_name         = "my-network"
  vpc_cidr         = "10.2.0.0/16"
  database_subnets = ["10.2.1.0/24", "10.2.2.0/24", "10.2.3.0/24"]
  intra_subnets    = ["10.2.100.0/24"]
  public_subnets   = ["10.2.200.0/28", "10.2.200.16/28"]
}

module "vpc" {
  source           = "terraform-aws-modules/vpc/aws"
  version          = "5.13.0"
  name             = local.vpc_name
  azs              = local.availability_zones
  cidr             = local.vpc_cidr
  database_subnets = local.database_subnets
  intra_subnets    = local.intra_subnets
  public_subnets   = local.public_subnets

  create_database_subnet_route_table = true

  enable_dns_hostnames = true
  enable_dns_support   = true

  map_public_ip_on_launch       = false
  manage_default_security_group = false
  manage_default_route_table    = false
  manage_default_network_acl    = false

  enable_flow_log                     = true
  create_flow_log_cloudwatch_iam_role = true
  flow_log_destination_arn            = "some existing log group ARN goes here"
}

Steps to reproduce the behavior:

You would likely have to run the repro code with version 5.11.0 (or something else less than 5.12.0) in order for it to run successfully and create everything. Then, you would re-run with 5.12.0 or higher.

Expected behavior

The module should not generate a change that results in an invalid policy document.

Actual behavior

The module attempts to entirely remove the resources list from the policy, which yields an invalid policy document -- applying this fails.

danielmklein avatar Sep 04 '24 18:09 danielmklein

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Oct 05 '24 00:10 github-actions[bot]

De-stale thyself

danielmklein avatar Oct 05 '24 00:10 danielmklein

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Nov 06 '24 00:11 github-actions[bot]

This is still valid.

danielmklein avatar Nov 06 '24 01:11 danielmklein

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Dec 07 '24 00:12 github-actions[bot]

Still relevant.

danielmklein avatar Dec 07 '24 02:12 danielmklein

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Jan 08 '25 00:01 github-actions[bot]

Still relevant.

danielmklein avatar Jan 08 '25 00:01 danielmklein

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Feb 09 '25 00:02 github-actions[bot]

Still relevant.

Still relevant.

danielmklein avatar Feb 09 '25 00:02 danielmklein

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Mar 12 '25 00:03 github-actions[bot]

πŸ’

danielmklein avatar Mar 12 '25 00:03 danielmklein

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Apr 13 '25 00:04 github-actions[bot]

πŸ§Ÿβ€β™‚οΈ

danielmklein avatar Apr 23 '25 20:04 danielmklein

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar May 25 '25 00:05 github-actions[bot]

πŸ’

staticaland avatar May 25 '25 09:05 staticaland

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Jun 25 '25 00:06 github-actions[bot]

πŸ–ΌοΈ

yngvark avatar Jun 25 '25 11:06 yngvark

Guys, have you wondered why something you want has not been happening for a long time for free?

Consider sponsoring any of these accounts:

  • https://github.com/sponsors/terraform-aws-modules
  • https://github.com/sponsors/antonbabenko
  • https://github.com/sponsors/bryantbiggs

PS: I would appreciate it if you could bring this up with your employer...

antonbabenko avatar Jun 25 '25 18:06 antonbabenko

This issue has been automatically marked as stale because it has been open 30 days with no activity. Remove stale label or comment or this issue will be closed in 10 days

github-actions[bot] avatar Jul 26 '25 00:07 github-actions[bot]

This issue was automatically closed because of stale in 10 days

github-actions[bot] avatar Aug 05 '25 00:08 github-actions[bot]

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Sep 04 '25 02:09 github-actions[bot]