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

aws_ec2_capacity_reservation placement_group_arn attribute support #27458

Merged
merged 3 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
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