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

fix validation parameter and style #22418

Merged
merged 3 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/22418.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_vpc_ipam_pool_cidr_allocation: update `cidr` and `netmask_length` attributes netmask to a minimum of 0 and maximum of 32
```
18 changes: 9 additions & 9 deletions internal/service/ec2/vpc_ipam_pool_cidr_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (

func ResourceVPCIpamPoolCidrAllocation() *schema.Resource {
return &schema.Resource{
Create: ResourceVPCIpamPoolCidrAllocationCreate,
Read: ResourceVPCIpamPoolCidrAllocationRead,
Delete: ResourceVPCIpamPoolCidrAllocationDelete,
Create: resourceVPCIpamPoolCidrAllocationCreate,
Read: resourceVPCIpamPoolCidrAllocationRead,
Delete: resourceVPCIpamPoolCidrAllocationDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Expand All @@ -32,7 +32,7 @@ func ResourceVPCIpamPoolCidrAllocation() *schema.Resource {
ConflictsWith: []string{"netmask_length"},
ValidateFunc: validation.Any(
verify.ValidIPv4CIDRNetworkAddress,
validation.IsCIDRNetwork(VPCCIDRMinIPv4, VPCCIDRMaxIPv4),
validation.IsCIDRNetwork(0, 32),
),
},
"description": {
Expand All @@ -53,7 +53,7 @@ func ResourceVPCIpamPoolCidrAllocation() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
ValidateFunc: validation.IntBetween(VPCCIDRMinIPv4, VPCCIDRMaxIPv4),
ValidateFunc: validation.IntBetween(0, 32),
ConflictsWith: []string{"cidr"},
},
"resource_id": {
Expand All @@ -76,7 +76,7 @@ const (
IpamPoolAllocationNotFound = "InvalidIpamPoolCidrAllocationId.NotFound"
)

func ResourceVPCIpamPoolCidrAllocationCreate(d *schema.ResourceData, meta interface{}) error {
func resourceVPCIpamPoolCidrAllocationCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).EC2Conn
pool_id := d.Get("ipam_pool_id").(string)

Expand Down Expand Up @@ -104,10 +104,10 @@ func ResourceVPCIpamPoolCidrAllocationCreate(d *schema.ResourceData, meta interf
}
d.SetId(encodeIpamPoolCidrAllocationID(aws.StringValue(output.IpamPoolAllocation.IpamPoolAllocationId), pool_id))

return ResourceVPCIpamPoolCidrAllocationRead(d, meta)
return resourceVPCIpamPoolCidrAllocationRead(d, meta)
}

func ResourceVPCIpamPoolCidrAllocationRead(d *schema.ResourceData, meta interface{}) error {
func resourceVPCIpamPoolCidrAllocationRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).EC2Conn

cidr_allocation, pool_id, err := FindIpamPoolCidrAllocation(conn, d.Id())
Expand Down Expand Up @@ -140,7 +140,7 @@ func ResourceVPCIpamPoolCidrAllocationRead(d *schema.ResourceData, meta interfac
return nil
}

func ResourceVPCIpamPoolCidrAllocationDelete(d *schema.ResourceData, meta interface{}) error {
func resourceVPCIpamPoolCidrAllocationDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*conns.AWSClient).EC2Conn

input := &ec2.ReleaseIpamPoolAllocationInput{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The following arguments are supported:
* `cidr` - (Optional) The CIDR you want to assign to the pool.
* `description` - (Optional) The description for the allocation.
* `ipam_pool_id` - (Required) The ID of the pool to which you want to assign a CIDR.
* `netmask_length` - (Optional) The netmask length of the CIDR you would like to allocate to the IPAM pool.
* `netmask_length` - (Optional) The netmask length of the CIDR you would like to allocate to the IPAM pool. Valid Values: `0-32`.

## Attributes Reference

Expand Down