• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to get all CIDR’s of a existing VPC and add them to security group as inbound rules using Terraform?

Resolved: How to get all CIDR’s of a existing VPC and add them to security group as inbound rules using Terraform?

0
By Isaac Tonny on 15/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve How to get all CIDR’s of a existing VPC and add them to security group as inbound rules using Terraform?

Question:

I have an existing VPC which has 4 CIDR’s and I need to retrieve those CIDR’s and add them to a security as Inbound rules. Is there any way to do it in Terraform? I didn’t find a way to do that Terraform
I have tried above snippet but the output value is giving only Primary CIDR.
Terraform Version: v0.14.5

Best Answer:

To get both the default CIDR block and the associated ones you need to use the cidr_block_associations attribute of the aws_vpc data source:
The cidr_block_associations attribute looks like this:
As you can see, it’s a list of objects with 3 attributes. To extract just the cidr_block values I used Terraform splat expression in my example.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

terraform terraform-provider-aws
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Java Swing center JLabel in JPanel with two JLabels

27/03/2023

Resolved: How to compare two text files and and change the sign of the data in powershell?

27/03/2023

Resolved: Java Virtual Machines deleted

27/03/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.