Skip to content

Commit

Permalink
resource/aws_opsworks_stack: Switch custom Opsworks client User-Agent…
Browse files Browse the repository at this point in the history
… to real Terraform version

Reference: hashicorp/terraform#13024
Reference: #9570

This migration is required for migrating to the standalone Terraform Plugin SDK and removing our dependency on github.com/hashicorp/terraform in the future.

Output from acceptance testing:

```
--- PASS: TestAccAWSOpsWorksStack_classic_endpoints (28.89s)
```

User-Agent from testing above:

```
User-Agent: aws-sdk-go/1.24.4 (go1.13; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.7
```
  • Loading branch information
bflad committed Sep 25, 2019
1 parent 59770ed commit 983760b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ type AWSClient struct {
stsconn *sts.STS
supportedplatforms []string
swfconn *swf.SWF
terraformVersion string
transferconn *transfer.Transfer
wafconn *waf.WAF
wafregionalconn *wafregional.WAFRegional
Expand Down Expand Up @@ -481,6 +482,7 @@ func (c *Config) Client() (interface{}, error) {
storagegatewayconn: storagegateway.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["storagegateway"])})),
stsconn: sts.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sts"])})),
swfconn: swf.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["swf"])})),
terraformVersion: c.terraformVersion,
transferconn: transfer.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["transfer"])})),
wafconn: waf.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["waf"])})),
wafregionalconn: wafregional.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["wafregional"])})),
Expand Down
3 changes: 1 addition & 2 deletions aws/resource_aws_opsworks_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/arn"
Expand Down Expand Up @@ -387,7 +386,7 @@ func opsworksConnForRegion(region string, meta interface{}) (*opsworks.OpsWorks,
return nil, fmt.Errorf("Error creating AWS session: %s", err)
}

sess.Handlers.Build.PushBack(request.MakeAddToUserAgentHandler("APN/1.0 HashiCorp/1.0 Terraform", terraform.VersionString()))
sess.Handlers.Build.PushBack(request.MakeAddToUserAgentHandler("APN/1.0 HashiCorp/1.0 Terraform", meta.(*AWSClient).terraformVersion))

newSession := sess.Copy(&aws.Config{Region: aws.String(region)})
newOpsworksconn := opsworks.New(newSession)
Expand Down

0 comments on commit 983760b

Please sign in to comment.