Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

ec2_securitygroup handles 'Name' tag poorly #506

Open
philomory opened this issue May 24, 2018 · 0 comments
Open

ec2_securitygroup handles 'Name' tag poorly #506

philomory opened this issue May 24, 2018 · 0 comments
Labels

Comments

@philomory
Copy link

philomory commented May 24, 2018

EC2 Security Groups have a dedicated 'group name' attribute which is used for identifying a group and is unique (at least within a given VPC). They also allow tags, including the 'Name' tag.

The ec2_securitygroup resource matches the name parameter against the SG's 'group_name' in AWS. It also fully supports setting arbitrary tags on security groups, including the 'Name' tag. However, when retrieving information from AWS, it unnecessarily filters the 'Name' tag out of the Tags list; thus, if you set the Name tag on an ec2_securitygroup resource, your puppet runs will never show as in sync. For example:

ec2_securitygroup { 'example-sg':
  ensure      => present,
  description => "An example security group demonstrating this issue",
  region      => "us-east-2",
  vpc         => "some-vpc",
  ingress     => [{
    protocol  => -1,
    cidr      => '0.0.0.0/0',
    from_port => 0,
    to_port   => 0,
  }],
  tags        => {
    'Name' => 'Example Security Group",
  }
}

If you run this code, a security group will be created, and it's Name tag will be set to "Example Security Group" as expected. However, on every subsequent puppet run, the message Notice: /Stage[main]/Ec2_securitygroup[example-sg]/tags: tags changed {} to {"Name"=>"Example Security Group"} will display, and if you're watching e.g. PuppetDB reports, it will appear as if this resource is constantly being changed externally and then reverted by puppet.

@gregohardy gregohardy added the bug label Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants