default-vpc.tf 1.0 KB

123456789101112131415161718192021222324252627
  1. # Make the default VPC compliant
  2. # tfsec:ignore:aws-vpc-no-default-vpc - tfsec says "Don't use the default VPC". We're just making a note not to.
  3. resource "aws_default_vpc" "default" {
  4. tags = merge(local.standard_tags, var.tags, { "Notes" = "Not connected. For testing only. VPC not for production use." })
  5. }
  6. resource "aws_kms_key" "default-flowlogs" {
  7. enable_key_rotation = true
  8. deletion_window_in_days = 30
  9. }
  10. resource "aws_flow_log" "default-flowlogs" {
  11. iam_role_arn = aws_iam_role.flowlogs.arn
  12. log_destination = aws_cloudwatch_log_group.vpc_flow_logs.arn
  13. traffic_type = "REJECT" # CIS only requires reject, and "ALL" is expensive
  14. vpc_id = aws_default_vpc.default.id
  15. }
  16. # CIS 4.3 - Default security group should restrict all traffic
  17. #
  18. # This resource is special, and clears out existing rules. See:
  19. # See https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_security_group
  20. resource "aws_default_security_group" "default" {
  21. vpc_id = aws_default_vpc.default.id
  22. tags = merge(local.standard_tags, var.tags)
  23. }