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 outpost_arn attribute support #19535

Merged
merged 6 commits into from
May 26, 2021
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
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 support for outpost_arn attribute
```
16 changes: 16 additions & 0 deletions aws/resource_aws_ec2_capacity_reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"fmt"
"log"
"regexp"
"time"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -98,6 +99,16 @@ func resourceAwsEc2CapacityReservation() *schema.Resource {
Required: true,
ForceNew: true,
},
"outpost_arn": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.All(
validation.StringMatch(
regexp.MustCompile(`^arn:aws([a-z-]+)?:outposts:[a-z\d-]+:\d{12}:outpost/op-[a-f0-9]{17}$`),
"must match ^arn:aws([a-z-]+)?:outposts:[a-z\\d-]+:\\d{12}:outpost/op-[a-f0-9]{17}$",
),
richardjennings marked this conversation as resolved.
Show resolved Hide resolved
),
},
"owner_id": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -156,6 +167,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 +229,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