Skip to content

Commit

Permalink
Merge pull request #27458 from bazza2000/f-aws_ec2_capacity_reservati…
Browse files Browse the repository at this point in the history
…on-placement-group-support

aws_ec2_capacity_reservation placement_group_arn attribute support
  • Loading branch information
ewbankkit authored Oct 25, 2022
2 parents cb92b5b + a663334 commit 8b4f3eb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/27458.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_ec2_capacity_reservation: Add `placement_group_arn` argument
```
10 changes: 10 additions & 0 deletions internal/service/ec2/ec2_capacity_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func ResourceCapacityReservation() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"placement_group_arn": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidARN,
},
"tags": tftags.TagsSchema(),
"tags_all": tftags.TagsSchemaComputed(),
"tenancy": {
Expand Down Expand Up @@ -141,6 +146,10 @@ func resourceCapacityReservationCreate(d *schema.ResourceData, meta interface{})
input.OutpostArn = aws.String(v.(string))
}

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

if v, ok := d.GetOk("tenancy"); ok {
input.Tenancy = aws.String(v.(string))
}
Expand Down Expand Up @@ -194,6 +203,7 @@ func resourceCapacityReservationRead(d *schema.ResourceData, meta interface{}) e
d.Set("instance_type", reservation.InstanceType)
d.Set("outpost_arn", reservation.OutpostArn)
d.Set("owner_id", reservation.OwnerId)
d.Set("placement_group_arn", reservation.PlacementGroupArn)
d.Set("tenancy", reservation.Tenancy)

tags := KeyValueTags(reservation.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig)
Expand Down
1 change: 1 addition & 0 deletions internal/service/ec2/ec2_capacity_reservation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestAccEC2CapacityReservation_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "instance_type", "t2.micro"),
resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""),
acctest.CheckResourceAttrAccountID(resourceName, "owner_id"),
resource.TestCheckResourceAttr(resourceName, "placement_group_arn", ""),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttr(resourceName, "tenancy", "default"),
),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/ec2_capacity_reservation.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The following arguments are supported:
* `instance_platform` - (Required) The type of operating system for which to reserve capacity. Valid options are `Linux/UNIX`, `Red Hat Enterprise Linux`, `SUSE Linux`, `Windows`, `Windows with SQL Server`, `Windows with SQL Server Enterprise`, `Windows with SQL Server Standard` or `Windows with SQL Server Web`.
* `instance_type` - (Required) The instance type for which to reserve capacity.
* `outpost_arn` - (Optional) The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity Reservation.
* `placement_group_arn` - (Optional) The Amazon Resource Name (ARN) of the cluster placement group in which to create the Capacity Reservation.
* `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.
* `tenancy` - (Optional) Indicates the tenancy of the Capacity Reservation. Specify either `default` or `dedicated`.

Expand Down

0 comments on commit 8b4f3eb

Please sign in to comment.