Skip to content

Commit

Permalink
Merge pull request hashicorp#19535 from richardjennings/19509
Browse files Browse the repository at this point in the history
aws_ec2_capacity_reservation outpost_arn attribute support
  • Loading branch information
ewbankkit authored May 26, 2021
2 parents fe831e6 + f135b68 commit 10935ba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/19535.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_ec2_capacity_reservation: Add `outpost_arn` argument
```
10 changes: 10 additions & 0 deletions aws/resource_aws_ec2_capacity_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func resourceAwsEc2CapacityReservation() *schema.Resource {
Required: true,
ForceNew: true,
},
"outpost_arn": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateArn,
},
"owner_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -156,6 +161,10 @@ func resourceAwsEc2CapacityReservationCreate(d *schema.ResourceData, meta interf
opts.InstanceMatchCriteria = aws.String(v.(string))
}

if v, ok := d.GetOk("outpost_arn"); ok {
opts.OutpostArn = aws.String(v.(string))
}

if v, ok := d.GetOk("tenancy"); ok {
opts.Tenancy = aws.String(v.(string))
}
Expand Down Expand Up @@ -214,6 +223,7 @@ func resourceAwsEc2CapacityReservationRead(d *schema.ResourceData, meta interfac
d.Set("instance_match_criteria", reservation.InstanceMatchCriteria)
d.Set("instance_platform", reservation.InstancePlatform)
d.Set("instance_type", reservation.InstanceType)
d.Set("outpost_arn", reservation.OutpostArn)
d.Set("owner_id", reservation.OwnerId)

tags := keyvaluetags.Ec2KeyValueTags(reservation.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig)
Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_ec2_capacity_reservation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func TestAccAWSEc2CapacityReservation_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "instance_match_criteria", "open"),
resource.TestCheckResourceAttr(resourceName, "instance_platform", "Linux/UNIX"),
resource.TestCheckResourceAttr(resourceName, "instance_type", "t2.micro"),
resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""),
testAccCheckResourceAttrAccountID(resourceName, "owner_id"),
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 @@ -34,6 +34,7 @@ The following arguments are supported:
* `instance_match_criteria` - (Optional) Indicates the type of instance launches that the Capacity Reservation accepts. Specify either `open` or `targeted`.
* `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.
* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://www.terraform.io/docs/providers/aws/index.html#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 10935ba

Please sign in to comment.