From a3b920ebd8dc4931597d8a72e0fb5668f4ab8882 Mon Sep 17 00:00:00 2001 From: shuheiktgw Date: Fri, 5 Mar 2021 07:53:07 +0900 Subject: [PATCH] resource_aws_ec2_traffic_mirror_session: Correct ARN --- aws/resource_aws_ec2_traffic_mirror_session.go | 8 ++++++-- aws/resource_aws_ec2_traffic_mirror_session_test.go | 1 + website/docs/r/ec2_traffic_mirror_session.html.markdown | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_ec2_traffic_mirror_session.go b/aws/resource_aws_ec2_traffic_mirror_session.go index 631aa1ac602..fcfa758b01b 100644 --- a/aws/resource_aws_ec2_traffic_mirror_session.go +++ b/aws/resource_aws_ec2_traffic_mirror_session.go @@ -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, @@ -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 diff --git a/aws/resource_aws_ec2_traffic_mirror_session_test.go b/aws/resource_aws_ec2_traffic_mirror_session_test.go index e72729664d4..1b5c7cde223 100644 --- a/aws/resource_aws_ec2_traffic_mirror_session_test.go +++ b/aws/resource_aws_ec2_traffic_mirror_session_test.go @@ -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-.+`)), ), }, diff --git a/website/docs/r/ec2_traffic_mirror_session.html.markdown b/website/docs/r/ec2_traffic_mirror_session.html.markdown index 4f609b32c5b..28fbf5b97c5 100644 --- a/website/docs/r/ec2_traffic_mirror_session.html.markdown +++ b/website/docs/r/ec2_traffic_mirror_session.html.markdown @@ -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