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

provider: Stabilization of remaining data source id attributes and enable R015, R016, R017 linters #15896

Merged
merged 2 commits into from
Oct 29, 2020
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
3 changes: 3 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ awsproviderlint:
-R012 \
-R013 \
-R014 \
-R015 \
-R016 \
-R017 \
-S001 \
-S002 \
-S003 \
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_autoscaling_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log"
"sort"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/autoscaling"
Expand Down Expand Up @@ -52,7 +51,6 @@ func dataSourceAwsAutoscalingGroupsRead(d *schema.ResourceData, meta interface{}
conn := meta.(*AWSClient).autoscalingconn

log.Printf("[DEBUG] Reading Autoscaling Groups.")
d.SetId(time.Now().UTC().String())

var rawName []string
var rawArn []string
Expand Down Expand Up @@ -103,6 +101,8 @@ func dataSourceAwsAutoscalingGroupsRead(d *schema.ResourceData, meta interface{}
return fmt.Errorf("Error fetching Autoscaling Groups: %s", err)
}

d.SetId(meta.(*AWSClient).region)

sort.Strings(rawName)
sort.Strings(rawArn)

Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_caller_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package aws
import (
"fmt"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -44,7 +44,7 @@ func dataSourceAwsCallerIdentityRead(d *schema.ResourceData, meta interface{}) e

log.Printf("[DEBUG] Received Caller Identity: %s", res)

d.SetId(time.Now().UTC().String())
d.SetId(aws.StringValue(res.Account))
d.Set("account_id", res.Account)
d.Set("arn", res.Arn)
d.Set("user_id", res.UserId)
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_ebs_snapshot_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/hashcode"
)

func dataSourceAwsEbsSnapshotIds() *schema.Resource {
Expand Down Expand Up @@ -74,7 +73,8 @@ func dataSourceAwsEbsSnapshotIdsRead(d *schema.ResourceData, meta interface{}) e
snapshotIds = append(snapshotIds, *snapshot.SnapshotId)
}

d.SetId(fmt.Sprintf("%d", hashcode.String(params.String())))
d.SetId(meta.(*AWSClient).region)

d.Set("ids", snapshotIds)

return nil
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_ebs_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log"

"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
Expand Down Expand Up @@ -67,7 +66,8 @@ func dataSourceAwsEbsVolumesRead(d *schema.ResourceData, meta interface{}) error
volumes = append(volumes, *volume.VolumeId)
}

d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

if err := d.Set("ids", volumes); err != nil {
return fmt.Errorf("error setting ids: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_ec2_coip_pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package aws
import (
"fmt"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
Expand Down Expand Up @@ -66,7 +65,8 @@ func dataSourceAwsEc2CoipPoolsRead(d *schema.ResourceData, meta interface{}) err
coippools = append(coippools, aws.StringValue(coippool.PoolId))
}

d.SetId(time.Now().UTC().String())
d.SetId(meta.(*AWSClient).region)

if err := d.Set("pool_ids", coippools); err != nil {
return fmt.Errorf("Error setting coip pool ids: %s", err)
}
Expand Down
3 changes: 1 addition & 2 deletions aws/data_source_aws_ec2_instance_type_offerings.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
Expand Down Expand Up @@ -79,7 +78,7 @@ func dataSourceAwsEc2InstanceTypeOfferingsRead(d *schema.ResourceData, meta inte
return fmt.Errorf("error setting instance_types: %s", err)
}

d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

return nil
}
4 changes: 2 additions & 2 deletions aws/data_source_aws_ec2_local_gateway_route_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package aws
import (
"fmt"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
Expand Down Expand Up @@ -62,7 +61,8 @@ func dataSourceAwsEc2LocalGatewayRouteTablesRead(d *schema.ResourceData, meta in
localgatewayroutetables = append(localgatewayroutetables, aws.StringValue(localgatewayroutetable.LocalGatewayRouteTableId))
}

d.SetId(time.Now().UTC().String())
d.SetId(meta.(*AWSClient).region)

if err := d.Set("ids", localgatewayroutetables); err != nil {
return fmt.Errorf("Error setting local gateway route table ids: %s", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)
Expand Down Expand Up @@ -65,7 +64,7 @@ func dataSourceAwsEc2LocalGatewayVirtualInterfaceGroupsRead(d *schema.ResourceDa
localGatewayVirtualInterfaceIds = append(localGatewayVirtualInterfaceIds, group.LocalGatewayVirtualInterfaceIds...)
}

d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

if err := d.Set("ids", ids); err != nil {
return fmt.Errorf("error setting ids: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_ec2_local_gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package aws
import (
"fmt"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
Expand Down Expand Up @@ -66,7 +65,8 @@ func dataSourceAwsEc2LocalGatewaysRead(d *schema.ResourceData, meta interface{})
localgateways = append(localgateways, aws.StringValue(localgateway.LocalGatewayId))
}

d.SetId(time.Now().UTC().String())
d.SetId(meta.(*AWSClient).region)

if err := d.Set("ids", localgateways); err != nil {
return fmt.Errorf("Error setting local gateway ids: %s", err)
}
Expand Down
3 changes: 1 addition & 2 deletions aws/data_source_aws_ec2_spot_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -82,7 +81,7 @@ func dataSourceAwsEc2SpotPriceRead(d *schema.ResourceData, meta interface{}) err

d.Set("spot_price", resultSpotPrice.SpotPrice)
d.Set("spot_price_timestamp", (*resultSpotPrice.Timestamp).Format(time.RFC3339))
d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

return nil
}
3 changes: 1 addition & 2 deletions aws/data_source_aws_efs_access_points.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package aws

import (
"fmt"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/efs"
Expand Down Expand Up @@ -62,7 +61,7 @@ func dataSourceAwsEfsAccessPointsRead(d *schema.ResourceData, meta interface{})
return fmt.Errorf("no matching EFS Access Points for File System (%s) found", fileSystemId)
}

d.SetId(time.Now().UTC().String())
d.SetId(fileSystemId)

var arns, ids []string

Expand Down
3 changes: 1 addition & 2 deletions aws/data_source_aws_glue_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/glue"
Expand Down Expand Up @@ -123,7 +122,7 @@ func dataSourceAwsGlueScriptRead(d *schema.ResourceData, meta interface{}) error
return errors.New("script not created")
}

d.SetId(time.Now().UTC().String())
d.SetId(meta.(*AWSClient).region)
d.Set("python_script", output.PythonScript)
d.Set("scala_code", output.ScalaCode)

Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_inspector_rules_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"log"
"sort"
"time"

"github.com/aws/aws-sdk-go/service/inspector"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand All @@ -29,7 +28,6 @@ func dataSourceAwsInspectorRulesPackagesRead(d *schema.ResourceData, meta interf
conn := meta.(*AWSClient).inspectorconn

log.Printf("[DEBUG] Reading Rules Packages.")
d.SetId(time.Now().UTC().String())

var arns []string

Expand All @@ -49,6 +47,8 @@ func dataSourceAwsInspectorRulesPackagesRead(d *schema.ResourceData, meta interf
return errors.New("No rules packages found.")
}

d.SetId(meta.(*AWSClient).region)

sort.Strings(arns)
d.Set("arns", arns)

Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
Expand Down Expand Up @@ -114,7 +113,8 @@ func dataSourceAwsInstancesRead(d *schema.ResourceData, meta interface{}) error

log.Printf("[DEBUG] Found %d instances via given filter", len(instanceIds))

d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

err = d.Set("ids", instanceIds)
if err != nil {
return err
Expand Down
5 changes: 2 additions & 3 deletions aws/data_source_aws_kms_ciphertext.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package aws
import (
"encoding/base64"
"log"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/kms"
Expand Down Expand Up @@ -43,8 +42,6 @@ func dataSourceAwsKmsCiphertext() *schema.Resource {
func dataSourceAwsKmsCiphertextRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).kmsconn

d.SetId(time.Now().UTC().String())

req := &kms.EncryptInput{
KeyId: aws.String(d.Get("key_id").(string)),
Plaintext: []byte(d.Get("plaintext").(string)),
Expand All @@ -60,6 +57,8 @@ func dataSourceAwsKmsCiphertextRead(d *schema.ResourceData, meta interface{}) er
return err
}

d.SetId(aws.StringValue(resp.KeyId))

d.Set("ciphertext_blob", base64.StdEncoding.EncodeToString(resp.CiphertextBlob))

return nil
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_network_acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)
Expand Down Expand Up @@ -84,7 +83,8 @@ func dataSourceAwsNetworkAclsRead(d *schema.ResourceData, meta interface{}) erro
networkAcls = append(networkAcls, aws.StringValue(networkAcl.NetworkAclId))
}

d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

if err := d.Set("ids", networkAcls); err != nil {
return fmt.Errorf("Error setting network ACL ids: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_network_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags"
)
Expand Down Expand Up @@ -71,7 +70,8 @@ func dataSourceAwsNetworkInterfacesRead(d *schema.ResourceData, meta interface{}
networkInterfaces = append(networkInterfaces, aws.StringValue(networkInterface.NetworkInterfaceId))
}

d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

if err := d.Set("ids", networkInterfaces); err != nil {
return fmt.Errorf("Error setting network interfaces ids: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions aws/data_source_aws_organizations_organizational_units.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/organizations"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -46,7 +45,6 @@ func dataSourceAwsOrganizationsOrganizationalUnitsRead(d *schema.ResourceData, m
conn := meta.(*AWSClient).organizationsconn

parent_id := d.Get("parent_id").(string)
d.SetId(resource.UniqueId())

params := &organizations.ListOrganizationalUnitsForParentInput{
ParentId: aws.String(parent_id),
Expand All @@ -65,6 +63,8 @@ func dataSourceAwsOrganizationsOrganizationalUnitsRead(d *schema.ResourceData, m
return fmt.Errorf("error listing Organizations Organization Units for parent (%s): %s", parent_id, err)
}

d.SetId(parent_id)

if err := d.Set("children", flattenOrganizationsOrganizationalUnits(children)); err != nil {
return fmt.Errorf("Error setting children: %s", err)
}
Expand Down
3 changes: 1 addition & 2 deletions aws/data_source_aws_outposts_outposts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/outposts"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -91,7 +90,7 @@ func dataSourceAwsOutpostsOutpostsRead(d *schema.ResourceData, meta interface{})
return fmt.Errorf("error setting ids: %w", err)
}

d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

return nil
}
3 changes: 1 addition & 2 deletions aws/data_source_aws_outposts_sites.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/outposts"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -54,7 +53,7 @@ func dataSourceAwsOutpostsSitesRead(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("error setting ids: %w", err)
}

d.SetId(resource.UniqueId())
d.SetId(meta.(*AWSClient).region)

return nil
}
Loading