Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CidrBlock, CidrBlockAssociationSet and Ipv6CidrBlockAssociationSet to Vpc struct. #1338

Open
charlierm opened this issue Sep 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@charlierm
Copy link

Describe the solution you'd like
Currently GetVpcById() returns a struct with no information about the CIDR associated with the VPC.

type Vpc struct {
	Id            string            // The ID of the VPC
	Name          string            // The name of the VPC
	Subnets       []Subnet          // A list of subnets in the VPC
	Tags          map[string]string // The tags associated with the VPC
	Cidr          string
	SecondaryCidr []string
}

I am writing a test which checks the IPv4 CIDR and secondary associations as well as IPv6, looking into GetVpcByID() it looks like it uses DescribeVpcs() which includes this information.

https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/#Vpc

I could make the call to rather than using the helper functions in terratest but it would be nice to use them! I propose adding the following new fields to the vpc struct:

type Vpc struct {
    CidrBlock *string  // The primary IPv4 CIDR block for the VPC.
    CidrAssociations *[]string
    Ipv6CidrAssociations *[]string
}

Bit of a rough and ready proposal but you get the idea! Would be great to get some feedback, I am happy to implement this 😄

This would allow me to quickly setup a test which is something like this:

terraform.InitAndApply(t, terraformOptions)
vpcId := terraform.Output(t, terraformOptions, "vpc_id")
vpc := aws.GetVpcById(t, vpcId, "eu-west-1")
Assert.NotEmpty(t, vpc. Ipv6CidrAssociations)

Thanks!

@charlierm charlierm added the enhancement New feature or request label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant