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

resource_aws_ec2_traffic_mirror_session: Correct ARN #17938

Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions aws/resource_aws_ec2_traffic_mirror_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func resourceAwsEc2TrafficMirrorSession() *schema.Resource {
Required: true,
ForceNew: true,
},
"owner_id": {
Type: schema.TypeString,
Computed: true,
},
"packet_length": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -217,14 +221,14 @@ func resourceAwsEc2TrafficMirrorSessionRead(d *schema.ResourceData, meta interfa
return fmt.Errorf("error setting tags: %s", err)
}

d.Set("owner_id", session.OwnerId)
arn := arn.ARN{
Partition: meta.(*AWSClient).partition,
Service: ec2.ServiceName,
Region: meta.(*AWSClient).region,
AccountID: meta.(*AWSClient).accountid,
AccountID: aws.StringValue(session.OwnerId),
Resource: fmt.Sprintf("traffic-mirror-session/%s", d.Id()),
}.String()

d.Set("arn", arn)

return nil
Expand Down
1 change: 1 addition & 0 deletions aws/resource_aws_ec2_traffic_mirror_session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestAccAWSEc2TrafficMirrorSession_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "session_number", strconv.Itoa(session)),
resource.TestMatchResourceAttr(resourceName, "virtual_network_id", regexp.MustCompile(`\d+`)),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
testAccCheckResourceAttrAccountID(resourceName, "owner_id"),
testAccMatchResourceAttrRegionalARN(resourceName, "arn", "ec2", regexp.MustCompile(`traffic-mirror-session/tms-.+`)),
),
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/ec2_traffic_mirror_session.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ In addition to all arguments above, the following attributes are exported:

* `arn` - The ARN of the traffic mirror session.
* `id` - The name of the session.
* `owner_id` - The AWS account ID of the session owner.

## Import

Expand Down