Skip to content

Commit

Permalink
Update EC2 IMDS documentation for package relocation (#986)
Browse files Browse the repository at this point in the history
Updates documentation for #984
that relocates ec2imds to feature/ec2/imds
  • Loading branch information
jasdel authored Dec 16, 2020
1 parent b1bf7d1 commit 39369ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions content/en/docs/migrating/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Module | Description
`github.com/aws/aws-sdk-go-v2` | The SDK core
`github.com/aws/aws-sdk-go-v2/config` | Shared Configuration Loading
`github.com/aws/aws-sdk-go-v2/credentials` | AWS Credential Providers
`github.com/aws/aws-sdk-go-v2/ec2imds` | {{% alias service=EC2 %}} Instance Metadata Service Client
`github.com/aws/aws-sdk-go-v2/feature/ec2/imds` | {{% alias service=EC2 %}} Instance Metadata Service Client
`github.com/aws/aws-sdk-go-v2/service/` | Service Client Modules
`github.com/aws/aws-sdk-go-v2/feature/` | High-Level utilities for services, for example the {{% alias service=S3 %}} Transfer Manager

Expand Down Expand Up @@ -784,7 +784,7 @@ to wait for a {{% alias service=S3 %}} Bucket to exist, you must construct a `Bu

The {{% alias sdk-go %}} provides an {{% alias service=EC2 %}} Instance Metadata Service (IMDS) client that you can use
to query the local IMDS when executing your application on an {{% alias service=EC2 %}} instance. The IMDS client is
a separate Go module that can be added to your application by using `go get github.com/aws/aws-sdk-go-v2/ec2imds`. The
a separate Go module that can be added to your application by using `go get github.com/aws/aws-sdk-go-v2/feature/ec2/imds`. The
client constructor and method operations have been updated to match the design of the other SDK service clients.

#### Example
Expand All @@ -808,11 +808,11 @@ if err != nil {

````go
import "context"
import "github.com/aws/aws-sdk-go-v2/ec2imds"
import "github.com/aws/aws-sdk-go-v2/feature/ec2/imds"

// ...

client := ec2imds.NewFromConfig(cfg)
client := imds.NewFromConfig(cfg)

region, err := client.GetRegion(context.TODO())
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions content/en/docs/sdk-utilities/ec2-imds.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ description: "Using the AWS SDK for Go V2 Amazon EC2 Instance Metadata Service C

You can use the {{% alias sdk-go %}} to access the
[{{% alias service=EC2 %}} Instance Metadata Service](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html).
The [ec2imds]({{% apiref "ec2imds" %}}) Go package provide a [Client]({{% apiref "ec2imds#Client" %}}) type that can
The [feature/ec2/imds]({{% apiref "feature/ec2/imds" %}}) Go package provide a [Client]({{% apiref "imds#Client" %}}) type that can
be used to access the {{% alias service=EC2 %}} Instance Metadata Service. The `Client` and associated operations
can be used similarly to the other AWS service clients provided by the SDK. To learn more information on how to
configure the SDK, and use service clients see [Configuring the SDK]({{% ref "configuring-sdk" %}}) and
[Using AWS Services]({{% ref "making-requests.md" %}}).

The client can help you easily retrieve information about instances on which your applications run, such as its AWS
Region or local IP address. Typically, you must create and submit HTTP requests to retrieve instance metadata. Instead,
create an `ec2imds.Client` to access the {{% alias service=EC2 %}} Instance Metadata Service using a programmatic client
create an `imds.Client` to access the {{% alias service=EC2 %}} Instance Metadata Service using a programmatic client
like other AWS Services.

For example to construct a client:
```go
import "context"
import "github.com/aws/aws-sdk-go-v2/config"
import "github.com/aws/aws-sdk-go-v2/ec2imds"
import "github.com/aws/aws-sdk-go-v2/feature/ec2/imds"

// ...

Expand All @@ -31,14 +31,14 @@ if err != nil {
return
}

client := ec2imds.NewFromConfig(cfg)
client := imds.NewFromConfig(cfg)
```

Then use the service client to retrieve information from a metadata category such as `local-ipv4`
(the private IP address of the instance).

```go
localip, err := client.GetMetadata(context.Background(), &ec2imds.GetMetadataInput{
localip, err := client.GetMetadata(context.TODO(), &imds.GetMetadataInput{
Path: "local-ipv4",
})
if err != nil {
Expand All @@ -60,14 +60,14 @@ instance. Instead, use the included `Region` method to easily return
an instance's Region.

```go
region, err := client.GetRegion(context.Background(), &ec2imds.GetRegionInput{})
region, err := client.GetRegion(context.TODO(), &imds.GetRegionInput{})
if err != nil {
log.Printf("Unable to retrieve the region from the EC2 instance %v\n", err)
}

fmt.Printf("region: %v\n", region)
```

For more information about the EC2 metadata utility, see the [ec2imds]({{< apiref ec2imds >}}) package in the
For more information about the EC2 metadata utility, see the [feature/ec2/imds]({{% apiref "feature/ec2/imds" %}}) package in the
{{% alias sdk-api %}}.

0 comments on commit 39369ba

Please sign in to comment.