Skip to content

Commit

Permalink
fixing code example and adding clarifications to docs (#2781)
Browse files Browse the repository at this point in the history
  • Loading branch information
RanVaknin authored Sep 11, 2024
1 parent 264eff1 commit 6ae12f1
Show file tree
Hide file tree
Showing 211 changed files with 1,236 additions and 996 deletions.
118 changes: 118 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions content/en/docs/configuring-sdk/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ $ export AWS_SESSION_TOKEN=TOKEN
### Specify Credentials Programmatically
`config.LoadDefaultConfig` allows you to provide an explicit
[aws.CredentialProvider]({{< apiref "aws#CredentialsProvider" >}}) when loading the shared configuration sources.
To pass an explicity credential provider when loading shared configuration use
To pass an explicit credential provider when loading shared configuration use
[config.WithCredentialsProvider]({{< apiref "config#WithCredentialsProvider" >}}). For example, if `customProvider`
references an instance of `aws.CredentialProvider` implementation, it can be passed during configuration loading
like so:
Expand All @@ -341,8 +341,7 @@ If you explicitly provide credentials, as in this example, the SDK uses only tho

{{% pageinfo color="info" %}}
All credential providers passed to or returned by `LoadDefaultConfig` are wrapped in a
[CredentialsCache]({{< apiref "aws#CredentialsCache" >}}) automatically. This enables caching and concurrency safe
credential access. If you explicitly configure a provider on `aws.Config` directly you must explicitly wrap the provider
[CredentialsCache]({{< apiref "aws#CredentialsCache" >}}) automatically. This enables caching, and credential rotation that is concurrency safe. If you explicitly configure a provider on `aws.Config` directly you must also explicitly wrap the provider
with this type using [NewCredentialsCache]({{< apiref "aws#NewCredentialsCache" >}}).
{{% /pageinfo %}}

Expand Down
4 changes: 2 additions & 2 deletions content/en/docs/configuring-sdk/custom-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ description: "Create a custom HTTP client with the AWS SDK for Go V2 to specify

The {{% alias sdk-go %}} uses a default HTTP client with default configuration values. Although you can change some of
these configuration values, the default HTTP client and transport are not sufficiently configured for customers using
the {{% alias sdk-go %}} in an environment with high throughput and low latency requirements. This section describes how
to configure a custom HTTP client, and use that client to create {{% alias sdk-go %}} calls.
the {{% alias sdk-go %}} in an environment with high throughput and low latency requirements. For more information, please refer to our [FAQ]({{% ref "faq.md" %}}) as configuration recommendations vary based on specific workloads.
This section describes how to configure a custom HTTP client, and use that client to create {{% alias sdk-go %}} calls.

To assist you in creating a custom HTTP client, this section describes how to the
[NewBuildableClient]({{< apiref "aws/transport/http#NewBuildableClient" >}}) to configure custom settings, and use
Expand Down
64 changes: 64 additions & 0 deletions content/en/docs/migrating/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1448,3 +1448,67 @@ been condensed:

To learn how to migrate to the 3.x major version of the encryption client, see
[this guide](https://docs.aws.amazon.com/amazon-s3-encryption-client/latest/developerguide/go-v3-migration.html).


## Service Customizations Changes

### S3
When migrating from AWS SDK for Go v1 to v2, an important change to be aware of involves the handling of the `SSECustomerKey` used for server-side encryption with customer-provided keys (SSE-C). In Go SDK v1, the encoding of the `SSECustomerKey` to Base64 was handled internally by the SDK. In SDK v2, this automatic encoding has been removed, and it is now required to manually encode the `SSECustomerKey` to Base64 before passing it to the SDK.

Example Adjustment:

```go
// V1

import (
"context"
"encoding/base64"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
)
// ... more code

plainTextKey := "12345678901234567890123456789012" // 32 bytes in length

// calculate md5..

_, err = client.PutObjectWithContext(context.Background(), &s3.PutObjectInput{
Bucket: aws.String("your-bucket-name"),
Key: aws.String("your-object-key"),
Body: strings.NewReader("hello-world"),
SSECustomerKey: &plainTextKey,
SSECustomerKeyMD5: &base64Md5,
SSECustomerAlgorithm: aws.String("AES256"),
})

// ... more code
```

```go
// V2

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
)

// ... more code

plainTextKey := "12345678901234567890123456789012" // 32 bytes in length
base64EncodedKey := base64.StdEncoding.EncodeToString([]byte(plainTextKey))

// calculate md5..

_, err = client.PutObject(context.Background(), &s3.PutObjectInput{
Bucket: aws.String("your-bucket-name"),
Key: aws.String("your-object-key"),
Body: strings.NewReader("hello-world"),
SSECustomerKey: &base64EncodedKey,
SSECustomerKeyMD5: &base64Md5,
SSECustomerAlgorithm: aws.String("AES256"),
})

// ... more code
```

8 changes: 4 additions & 4 deletions content/en/docs/sdk-utilities/ec2-imds.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ Then use the service client to retrieve information from a metadata category suc
(the private IP address of the instance).

```go
localip, err := client.GetMetadata(context.TODO(), &imds.GetMetadataInput{
Path: "local-ipv4",
localIp, err := client.GetMetadata(context.TODO(), &imds.GetMetadataInput{
Path: "local-ipv4",
})
if err != nil {
log.Printf("Unable to retrieve the private IP address from the EC2 instance: %s\n", err)
return
}

fmt.Printf("local-ip: %v\n", localip)
content, _ := io.ReadAll(localIp.Content)
fmt.Printf("local-ip: %v\n", string(content))
```

For a list of all metadata categories, see
Expand Down
6 changes: 3 additions & 3 deletions docs/404.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!doctype html>
<html itemscope itemtype="http://schema.org/WebPage" lang="en" class="no-js">
<head>
<head><script src="/aws-sdk-go-v2/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=aws-sdk-go-v2/livereload" data-no-instant defer></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="generator" content="Hugo 0.115.4">
Expand All @@ -23,7 +23,7 @@
<meta property="og:title" content="404 Page not found" />
<meta property="og:description" content="The AWS SDK for Go V2 provides APIs and utilities that developers can use to build Go applications that use AWS services." />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://aws.github.io/aws-sdk-go-v2/404.html" />
<meta property="og:url" content="http://localhost:1313/aws-sdk-go-v2/404.html" />
<meta itemprop="name" content="404 Page not found">
<meta itemprop="description" content="The AWS SDK for Go V2 provides APIs and utilities that developers can use to build Go applications that use AWS services."><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="404 Page not found"/>
Expand Down Expand Up @@ -99,7 +99,7 @@
aria-label="Search this site…"
autocomplete="off"

data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.9f33279f24e0567986b8fc9db212092b.json"
data-offline-search-index-json-src="/aws-sdk-go-v2/offline-search-index.30b245754e63db1f94dcbaa3ba0f9915.json"
data-offline-search-base-href="/"
data-offline-search-max-results="10"
>
Expand Down
Loading

0 comments on commit 6ae12f1

Please sign in to comment.