hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.74k stars 9.1k forks source link

Have resource/aws_iot_topic_rule_destination return the ENI ids created as an attribute #26568

Open MickSheppardWB opened 2 years ago

MickSheppardWB commented 2 years ago

Community Note

Description

When an IOT rule destination is created a pair of ENIs are created with it. In order to make using these easier it would help if the ids of the ENIs were returned as an attribute of the aws_iot_topic_rule_destination resource.

To use a rule destination created in a public subnet you need to attach an Elastic IP (EIP) to each interface. The current method of doing this is quite involved. Adding this attribute would simplify operation and make the code more readable.

New or Affected Resource(s)

Potential Terraform Configuration

resource "aws_iot_topic_rule_destination" "example" {
  vpc_configuration {
    role_arn   = aws_iam_role.iot_core_rule_destination.arn
    vpc_id     = aws_vpc.main.id
    subnet_ids = [aws_subnet.main.id]
  }
}

output "iot_rule_destination_eni_ids" {
  value = aws_iot_topic_rule_destination.example.enis
}

resource "aws_eip" "example" {
  count = 2 # IOT rule destinations always have 2 ENIs

  vpc  = true

  network_interface = aws_iot_topic_rule_destination.example.enis[count.index
}

References

github-actions[bot] commented 3 weeks ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!