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: Use real Terraform version in UA header #9570

Merged
merged 1 commit into from
Sep 25, 2019
Merged

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Jul 31, 2019

The existing implementation leverages Terraform's version package as Terraform currently provides the SDK for interacting with core and is therefore imported by the provider, including the version package.

The side effect of this is that provider reports version of vendored Terraform (i.e. plugin SDK), not the version which actually talks to the provider's gRPC server and parses the configuration.

This PR is leveraging recent changes introduced in 0.12 to fix that and report accurate version.


I also wanted to change the header from the following

APN/1.0 HashiCorp/1.0 Terraform/X.Y.Z (+https://www.terraform.io)

to

APN/1.0 HashiCorp Terraform/X.Y.Z (+https://www.terraform.io)

to align it better with other providers.

The point of versioning of HashiCorp was (IMO rightfully) questioned during the implementation of hashicorp/terraform#22272 and the version was dropped from that helper function.

However the upstream AWS SDK helpers used here for building the UA string may need to be tuned to reflect the RFC where version of products is optional. Dropping the Version part would otherwise produce

APN/1.0 HashiCorp/ Terraform/X.Y.Z (+https://www.terraform.io)

which is most likely undesired.

An example of a full UA string with this patch follows

aws-sdk-go/1.23.0 (go1.12.7; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.7 (+https://www.terraform.io)

I think it would be worth exploring ways of moving SDK/Go versions towards the end, to reflect RFC7231, specifically this part:

By convention, the product identifiers are listed in decreasing order of their significance for identifying the user agent software. Each product identifier consists of a name and optional version.

IMO Terraform is more significant in this context than the SDK - but I will leave that for another discussion/PR.

@radeksimko radeksimko added the provider Pertains to the provider itself, rather than any interaction with AWS. label Jul 31, 2019
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. dependencies Used to indicate dependency changes. labels Jul 31, 2019
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. and removed size/XXL Managed by automation to categorize the size of a PR. labels Aug 21, 2019
@radeksimko radeksimko force-pushed the f-user-agent branch 2 times, most recently from 7be4a6b to 3d61671 Compare August 21, 2019 14:53
@radeksimko radeksimko marked this pull request as ready for review August 21, 2019 15:03
@radeksimko radeksimko requested a review from a team August 21, 2019 15:03
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. and removed dependencies Used to indicate dependency changes. labels Aug 29, 2019
@bflad
Copy link
Contributor

bflad commented Sep 6, 2019

Hey @radeksimko 👋 I think this is looking okay -- can you please also fix the other usage of VersionString() at aws/resource_aws_opsworks_stack.go:390?

$ tf-sdk-migrator check
...
Checking whether provider uses deprecated SDK packages or identifiers...
Deprecated SDK packages in use: [github.com/hashicorp/terraform/flatmap]
Deprecated SDK identifiers in use: [Ident VersionString from package github.com/hashicorp/terraform/terraform is used at [/Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/config.go:338:43 /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_opsworks_stack.go:390:110]]

Some constraints not satisfied. Please resolve these before migrating to the new SDK.

Thanks!

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Sep 6, 2019
@radeksimko
Copy link
Member Author

Yeah, I was looking at it, but I wasn't sure what was the motivation there to have a separate resource-specific logic for handling sessions etc. - happy to look into it, although I hoped we could deal with it in a separate PR 😃

@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2019
@bflad bflad added this to the v2.30.0 milestone Sep 25, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 I will followup with the other session code.

Output from acceptance testing:

User-Agent: aws-sdk-go/1.24.4 (go1.13; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.7 (+https://www.terraform.io)

Output from Terraform 0.12.9 using updated provider binary:

User-Agent: aws-sdk-go/1.24.4 (go1.13; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.9 (+https://www.terraform.io)

Output from Terraform 0.11.14 using updated provider binary:

User-Agent: aws-sdk-go/1.24.4 (go1.13; darwin; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.11+compatible (+https://www.terraform.io)

@bflad bflad merged commit 84396c3 into master Sep 25, 2019
@bflad bflad deleted the f-user-agent branch September 25, 2019 19:25
bflad added a commit that referenced this pull request Sep 25, 2019
bflad added a commit that referenced this pull request Sep 25, 2019
… 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
```
@ghost
Copy link

ghost commented Sep 26, 2019

This has been released in version 2.30.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Nov 1, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. provider Pertains to the provider itself, rather than any interaction with AWS. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants