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

Add static opsworks endpoint #473

Closed
wants to merge 1 commit into from
Closed

Add static opsworks endpoint #473

wants to merge 1 commit into from

Conversation

catsby
Copy link

@catsby catsby commented Dec 21, 2015

AWS OpsWorks has a single endpoint: opsworks.us-east-1.amazonaws.com and
only supports HTTPS requests. While the region is a thing you can configure when you setup your session, setting it to anything but us-east-1 will fail.

Given this script:

package main

import (
    "log"

    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/opsworks"
)

func main() {
    log.Println("OK start")
    svc := opsworks.New(session.New())
    req := &opsworks.AttachElasticLoadBalancerInput{
        ElasticLoadBalancerName: aws.String("terraform-asg-deployment-example"),
        LayerId:                 aws.String("c5d45635-4cde-4cb6-9f62-b48036cd5dd0"),
    }

    r, err := svc.AttachElasticLoadBalancer(req)

    if err != nil {
        log.Printf("\n\terr: %s\n", err)
    }

    if r != nil {
        log.Printf("R: %s\n", r)
    }
}

You'll get an error if AWS_REGION is anything but us-east-1:

    err: RequestError: send request failed
caused by: Post https://opsworks.us-west-2.amazonaws.com/: dial tcp: lookup opsworks.us-west-2.amazonaws.com: no such host

This PR adds opsworks to the endpoints.json so that by default you'll get the correct region. At least, in my limited testing it has.

I've ran the above script successfully after running make gen-endpoints and make build in the root of the SDK.

Suggestions for a better way welcome!

AWS OpsWorks has a single endpoint: opsworks.us-east-1.amazonaws.com and
only supports HTTPS requests.
@jasdel
Copy link
Contributor

jasdel commented Dec 21, 2015

Thanks for reporting the missing endpoint mapping @catsby. This looks good. I'll regenerate the endpoints_map.go and merge in this change.

@jasdel
Copy link
Contributor

jasdel commented Dec 21, 2015

Hi @catsby after taking a deeper look into this issue the SDK's intentionally do not provide this functionality for Opsworks and similar service that are only present in us-east-1. Adding this override would prevent OpsWorks from expanding to additional regions in the future. Because of this we won't be able to pull in this change.

@jasdel
Copy link
Contributor

jasdel commented Dec 21, 2015

Thanks a lot for the PR and sorry we cannot take pull it in. But to maintain forward compatibility with potential service expansion we don't want to add logic automatically aliasing the region for this service.

@jasdel jasdel closed this Dec 21, 2015
@catsby
Copy link
Author

catsby commented Dec 21, 2015

Fair enough, I understand the reasoning to not merge it.

As a counter point, it is less than ideal that I can rely on the sdk to automatically pick up my credentials from the environment (including default region), only to learn that in order to use OpsWorks I had to explicitly configure the connection to use us-east-1.

Less than ideal, but not the end of world 😄

Thanks!

@catsby
Copy link
Author

catsby commented Dec 21, 2015

Follow up: My specific less than ideal comment is mostly because the error message I got was dial tcp: lookup opsworks.us-west-2.amazonaws.com: no such host, which at first read made me think there was a problem with the service. Only after some debugging did I think to check AWS's endpoints documentation and decipher that I was hitting a bad / nonexistent endpoint.

Still, not a huge deal I suppose. Thanks again

@jasdel
Copy link
Contributor

jasdel commented Dec 21, 2015

@catsby thanks for your feedback. Improving the way these error message to be more specific would definitely clarify why the request failed, and how to resolve it be very nice.

I think this might be a good feature to add better error messaging in this case. Off hand I think we could accomplish this by combining a list of known supported regions with this error message. We wouldn't want to outright block the unsupported region request in case the service has added support for that and the user hasn't updated their SDK. The list of known regions would be needed to ensure that if there actually are routing or connection errors false negative errors won't be reported.

@catsby
Copy link
Author

catsby commented Dec 22, 2015

Understandable @jasdel , thanks 😄

skotambkar pushed a commit to skotambkar/aws-sdk-go that referenced this pull request May 20, 2021
skotambkar pushed a commit to skotambkar/aws-sdk-go that referenced this pull request May 20, 2021
Breaking Change
---
* `service`: Add generated service for wafregional and dynamodbstreams aws#463
  * Updates the wafregional and dynamodbstreams API clients to include all API operations, and types that were previously shared between waf and dynamodb API clients respectively. This update ensures that all API clients include all operations and types needed for that client, and shares no types with another client package.
  * To migrate your applications to use the updated wafregional and dynamodbstreams you'll need to update the package the impacted type is imported from to match the client the type is being used with.
* `aws`: Context has been added to EC2Metadata operations.([aws#461](aws/aws-sdk-go-v2#461))
  * Also updates utilities that directly or indirectly depend on EC2Metadata client. Signer utilities, credential providers now take in context.
* `private/model`: Add utility for validating shape names for structs and enums for the service packages ([aws#471](aws/aws-sdk-go-v2#471))
  * Fixes bug which allowed service package structs, enums to start with non alphabetic character
  * Fixes the incorrect enum types in mediapackage service package, changing enum types __AdTriggersElement, __PeriodTriggersElement to AdTriggersElement, PeriodTriggersElement respectively.
* `aws`: Client, Metadata, and Request structures have been refactored to simplify the usage of resolved endpoints ([aws#473](aws/aws-sdk-go-v2#473))
  * `aws.Client.Endpoint` struct member has been removed, and `aws.Request.Endpoint` struct member has been added of type `aws.Endpoint`
  * `aws.Client.Region` structure member has been removed

Services
---
* Synced the V2 SDK with latest AWS service API definitions.

SDK Features
---
* `aws`: `PartitionID` has been added to `aws.Endpoint` structure, and is used by the endpoint resolver to indicate which AWS partition an endpoint was resolved for ([aws#473](aws/aws-sdk-go-v2#473))
* `aws/endpoints`: Updated resolvers to populate `PartitionID` for a resolved `aws.Endpoint` ([aws#473](aws/aws-sdk-go-v2#473))
* `service/s3`: Add support for Access Point resources
  * Adds support for using Access Point resource with Amazon S3 API operation calls. The Access Point resource are identified by an Amazon Resource Name (ARN).
  * To make operation calls to an S3 Access Point instead of a S3 Bucket, provide the Access Point ARN string as the value of the Bucket parameter. You can create an Access Point for your bucket with the Amazon S3 Control API. The Access Point ARN can be obtained from the S3 Control API. You should avoid building the ARN directly.

SDK Enhancements
---
* `internal/sdkio`: Adds RingBuffer data structure to the sdk [aws#417](aws/aws-sdk-go-v2#417)
  * Adds an implementation of RingBuffer data structure which acts as a revolving buffer of a predefined length. The RingBuffer implements io.ReadWriter interface.
  * Adds unit tests to test the behavior of the ring buffer.
* `aws/ec2metadata`: Adds support for EC2Metadata client to use secure tokens provided by the IMDS ([aws#453](aws/aws-sdk-go-v2#453))
  * Modifies EC2Metadata client to use request context within its operations ([aws#462](aws/aws-sdk-go-v2#462))
  * Reduces the default dialer timeout and response header timeout to help reduce latency for known issues with EC2Metadata client running inside a container
  * Modifies and adds tests to verify the behavior of the EC2Metadata client.
* `service/dynamodb/dynamodbattribute`: Adds clarifying docs on dynamodbattribute.UnixTime ([aws#464](aws/aws-sdk-go-v2#464))
* `example/service/sts/assumeRole`: added sts assume role example ([aws#224](aws/aws-sdk-go-v2#224))
  * Fixes [aws#157](aws/aws-sdk-go-v2#157) by adding an example for Amazon STS assume role to retrieve credentials.

SDK Bugs
---
* `service/dynamodb/dynamodbattribute`: Fixes a panic when decoding into a map with a key string type alias. ([aws#465](aws/aws-sdk-go-v2#465))
  * Fixes [aws#410](aws/aws-sdk-go-v2#410),  by adding support for keys that are string aliases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants