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 tier argument to aws_vpc_ipam resource #36504

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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/36504.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_vpc_ipam: Add `tier` argument
```
12 changes: 12 additions & 0 deletions internal/service/ec2/ipam_.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ func ResourceIPAM() *schema.Resource {
Type: schema.TypeInt,
Computed: true,
},
"tier": {
Type: schema.TypeString,
Optional: true,
mmourick marked this conversation as resolved.
Show resolved Hide resolved
},
names.AttrTags: tftags.TagsSchema(),
names.AttrTagsAll: tftags.TagsSchemaComputed(),
},
Expand Down Expand Up @@ -128,6 +132,10 @@ func resourceIPAMCreate(ctx context.Context, d *schema.ResourceData, meta interf
input.Description = aws.String(v.(string))
}

if v, ok := d.GetOk("tier"); ok {
input.Tier = aws.String(v.(string))
}

output, err := conn.CreateIpamWithContext(ctx, input)

if err != nil {
Expand Down Expand Up @@ -211,6 +219,10 @@ func resourceIPAMUpdate(ctx context.Context, d *schema.ResourceData, meta interf
}
}

if d.HasChange("tier") {
input.Tier = aws.String(d.Get("tier").(string))
}

_, err := conn.ModifyIpamWithContext(ctx, input)

if err != nil {
Expand Down
42 changes: 42 additions & 0 deletions internal/service/ec2/ipam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,35 @@ func TestAccIPAM_cascade(t *testing.T) {
})
}

func TestAccIPAM_tier(t *testing.T) {
ctx := acctest.Context(t)
var ipam ec2.Ipam
resourceName := "aws_vpc_ipam.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.EC2ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckIPAMDestroy(ctx),
Steps: []resource.TestStep{
ewbankkit marked this conversation as resolved.
Show resolved Hide resolved
{
Config: testAccIPAMConfig_tier("free"),
Check: resource.ComposeTestCheckFunc(
testAccCheckIPAMExists(ctx, resourceName, &ipam),
resource.TestCheckResourceAttr(resourceName, "tier", "free"),
),
},
{
Config: testAccIPAMConfig_tier("advanced"),
Check: resource.ComposeTestCheckFunc(
testAccCheckIPAMExists(ctx, resourceName, &ipam),
resource.TestCheckResourceAttr(resourceName, "tier", "advanced"),
),
},
},
})
}

func TestAccIPAM_tags(t *testing.T) {
ctx := acctest.Context(t)
var ipam ec2.Ipam
Expand Down Expand Up @@ -378,3 +407,16 @@ resource "aws_vpc_ipam" "test" {
}
`, tagKey1, tagValue1, tagKey2, tagValue2)
}

func testAccIPAMConfig_tier(tier string) string {
return fmt.Sprintf(`
data "aws_region" "current" {}

resource "aws_vpc_ipam" "test" {
operating_regions {
region_name = data.aws_region.current.name
}
tier = "%s"
}
`, tier)
}
3 changes: 2 additions & 1 deletion website/docs/r/vpc_ipam.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ locals {

This resource supports the following arguments:

* `cascade` - (Optional) Enables you to quickly delete an IPAM, private scopes, pools in private scopes, and any allocations in the pools in private scopes.
* `description` - (Optional) A description for the IPAM.
* `operating_regions` - (Required) Determines which locales can be chosen when you create pools. Locale is the Region where you want to make an IPAM pool available for allocations. You can only create pools with locales that match the operating Regions of the IPAM. You can only create VPCs from a pool whose locale matches the VPC's Region. You specify a region using the [region_name](#operating_regions) parameter. You **must** set your provider block region as an operating_region.
* `tier` - (Optional) specifies the IPAM tier.
mmourick marked this conversation as resolved.
Show resolved Hide resolved
* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `cascade` - (Optional) Enables you to quickly delete an IPAM, private scopes, pools in private scopes, and any allocations in the pools in private scopes.

### operating_regions

Expand Down
Loading