M Smith
M Smith

Reputation: 78

Can you tag inbound Name on inbound rules on an AWS security group using terraform?

I'm trying to set individual names against each entry in my security group.

My example code that doesn't work below, I'd expect this to yield the result in the picture but the Name tag remains blank (i set this one as an example in the picture through the console). This tag works other places like the "Allow-Google" name tag against the security group. Is there a way I can achieve this ?

resource "aws_security_group" "allow-google-dns" {
  name        = "allow-google-dns"
  description = "Allows google dns"
  vpc_id      = var.vpcid

  ingress = [
    {
      description      = "allows google in"
      from_port        = 0
      to_port          = 0
      protocol         = "-1"
      cidr_blocks = ["8.8.8.8/32" ]
      ipv6_cidr_blocks = []
      prefix_list_ids = []
      security_groups = []
      self = false
      tags = {
    Name = "MyName"
           }
    }
  ]

  tags = {
    Name = "Allow-Google"
  }
}

AWS Console

Upvotes: 5

Views: 1920

Answers (1)

mhvelplund
mhvelplund

Reputation: 2341

Marcin is right (for the time being).

As of Terraform 1.0.7 with version 3.60.0 of the AWS provider, tagging rules isn't supported, neither in inline format or in external aws_security_group_rule resources.

But Terraform doesn't notice any tags that are in place, so you could conceivably add them after creation, and Terraform won't detect it as a change whenever you reapply.

Upvotes: 1

Related Questions