Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Commits on Jan 16, 2015
Commits on Jan 17, 2015
Dimiter Naydenov
Merge pull request #19 from dimitern/v3-backport-v2-flaky-test-fix-fo…
…r-go-1.4

Backport flaky test fix for go 1.4 from v2
Commits on Jan 18, 2015
Commits on Feb 10, 2015
Dimiter Naydenov
Merge pull request #26 from surma-dump/feature/put-headers
s3: Add header option to PutXXX() methods
Commits on Feb 12, 2015
Added support for v4 signing to S3.
- S3 constructor now takes a Signer function. This indicates the preferred signing methodology.
- Users can still use the recommended type of signing by using the Signer defined on the region.
Commits on Feb 28, 2015
Commits on Mar 01, 2015
Addressed review issues.
- Minor formatting issues.
- Changed skip message to a comment. Now referencing bug#.
- Documentation cleaned up.
Dimiter Naydenov
Merge pull request #27 from katco-/v3-unstable
Added support for v4 signing to S3.
Dimiter Naydenov
Merge pull request #30 from dimitern/v3
Migrate v3-unstable -> v3
Dimiter Naydenov
Commits on Mar 02, 2015
Commits on Mar 05, 2015
Commits on Mar 12, 2015
Migrated v4 signing process to streaming.
- Migrated v4 signing process to streaming. This limits the amount of data that needs to be stored in memory during the signing process.
Katherine Cox-Buday
Merge pull request #37 from katco-/v4-signing-memory-fix
Migrated v4 signing process to streaming.
Commits on Mar 17, 2015
Revert signature back to v3.
Some users of goamz will not be able to pass in an io.ReadSeeker. Reverted the signature of PutReaderWithHeader to take in an io.Reader. The reader is then converted to an io.ReadSeeker through either a type assertion, or by reading the entire contents into memory. This allows for an optimization to those who pass in an io.ReadSeeker, but allows use for everyone.
Commits on Mar 19, 2015
Commits on Mar 24, 2015
axw
Implement ModifyInstanceAttribute
For now, the test server only handles
SourceDestCheck and BlockDeviceMappings.
Commits on Mar 25, 2015
Commits on Mar 26, 2015
LICENSE updated to provide 'default' copyright
Some files in the repo don't have copyright notice provided.
We may deal with it by providing 'default' copyright which points to the main contributor (Canonical).
Files created by other authors (AppsAttic Ltd., Memeo Inc.) have explicit copyright notice inside.
Dimiter Naydenov
Merge pull request #46 from strikov-canonical/patch-2
LICENSE updated to provide 'default' copyright
Commits on Apr 03, 2015
Signing fixes & error handling.
- EC2 queries now properly return errors from the signing process should they occur.
- The v4 signing process now uses a "/" for the request path if no path is present.
- Added test for describe-account-attributes, which was failing with v4 signing.
Commits on May 06, 2015
Commits on May 22, 2015
axw
ec2test: handle CreateTags action
This commit adds support for the CreateTags
action to the test server, and an accompanying
test. Live tested.
axw
Merge pull request #50 from axw/createtags-tests
ec2test: handle CreateTags action
Commits on Jun 04, 2015
axw
ec2test: set volume status to in-use when attached
In the test server, we will update the volume status
to "in-use" when attached to an instance, and "available"
otherwise.
axw
Merge pull request #48 from zlwu/v3
Add NextMarker to support paging
axw
Merge pull request #51 from axw/volume-status
ec2test: set volume status to in-use when attached
Commits on Jun 25, 2015
Commits on Jun 26, 2015
Commits on Jun 27, 2015
axw
Merge pull request #52 from guilherme-santos/v3
Update EC2 environment variable
Commits on Jun 29, 2015
axw
aws: URL-encode request path segments in signing
The AWS docs for signature derivation specify that
the request path needs to be URL-encoded, excluding
the segment-delimiting forward slashes. This diff
does that, and adds a couple of test cases.
Commits on Jun 30, 2015
axw
s3: close HTTP response body
Response bodies should always be closed.

Fixes #54
Commits on Jul 02, 2015
axw
Merge pull request #53 from axw/sign-v4-canonicaluri
aws: URL-encode request path segments in signing
Commits on Jul 22, 2015
axw
ec2/ec2test: handle "tag:" filter for volumes
Handle the "tag:key=value" type filter for
volumes. This is required for Juju to be able
to list volumes belonging to an environment.
axw
Merge pull request #56 from axw/ec2test-volumes-filter-tag
ec2/ec2test: handle "tag:" filter for volumes
Commits on Jul 24, 2015
axw
ec2: add Instance.RootDevice{Type,Name}
Add the titular fields, as well as an optional
mode for the ec2test server which causes it to
create root disks for instances. We don't do
this by default because the automatically added
volumes can make tests unclear.
Commits on Jul 27, 2015
axw
Merge pull request #57 from axw/ec2-instance-rootdevice
ec2: add Instance.RootDevice{Type,Name}
Commits on Jul 28, 2015
Commits on Aug 03, 2015
Commits on Aug 04, 2015
Commits on Aug 05, 2015
Commits on Aug 07, 2015
Commits on Aug 08, 2015
Commits on Aug 09, 2015
Commits on Aug 10, 2015
Dimiter Naydenov
Merge pull request #60 from dimitern/describe-igw-and-routes-take-2
Discovery of Internet Gateways, RouteTables; ec2test improvements
Commits on Aug 20, 2015
ect/ec2test/helper.go counter was not being used in a thread safe man…
…ner, so now it is a struct with next, get and reset functions. The old next function just incremented an integer and returned the old value. Now accessing by next, get and reset are all atomic.
Dimiter Naydenov
Commits on Jan 15, 2016
Commits on Jan 21, 2016
Martin Packman
Add region endpoint data for ap-northeast-2
New region in Korea. Also some comment formatting pokes.
Commits on Jan 25, 2016
Martin Packman
Merge pull request #65 from bz2/add_ap_northeast_2
Add region endpoint data for ap-northeast-2
Commits on Feb 02, 2016
axw
Merge pull request #64 from guilherme-santos/v3
Add option to inform IAM Instace profile
Commits on Feb 19, 2016
Add tag support to instances
goamz supports filtering by tag by adding a filter with a key
prefixed by "tag." I added this behavior to the current
instance implementation in ec2test.
Commits on Feb 22, 2016
Commits on Feb 24, 2016
Dimiter Naydenov
Merge pull request #66 from perrito666/v3_add_tags_filter_support_to_…
…instances

Add tag support to instances
Commits on Apr 18, 2016
axw
ec2test: handle security group tags
Update CreateTags and security group filtering
to handle tags.
Commits on Apr 20, 2016
Commits on Aug 18, 2016
Commits on Aug 19, 2016
axw
Merge pull request #70 from ben181231/utc-signing-time
Set UTC Date when generating S3 Signed URL
Commits on Oct 06, 2016
axw
ec2/ec2test: add support for isDefault VPC filter
Add support for filtering on isDefault to VPCs.
axw
Merge pull request #71 from axw/vpc-isdefault-filter
ec2/ec2test: add support for isDefault VPC filter
Commits on Oct 19, 2016
Commits on Oct 20, 2016
Martin Packman
Merge pull request #72 from reedobrien/lp/1612645+1634289_new-aws-reg…
…ions

aws/aws.go: New aws regions us-east-2 and ap-south-1

Fixes lp:1612645 and lp:1634289
Commits on Dec 15, 2016
Force requestTime to use UTC
`requestTime()` was using time.Parse, which tries to use the client
location as timezone. This was seen to be confused by daylight savings
time on a client in GMT. This change uses time.ParseInLocation to force
UTC in all cases.
Martin Packman
Martin Packman
Merge pull request #74 from macgreagoir/aws-ca-central-eu-london
Add Canada (Central) and EU (London)
Showing with 7,596 additions and 3,126 deletions.
  1. +10 −0 .gitignore
  2. +1 −1 .travis.yml
  3. +1 −0 AUTHORS.md
  4. +1 −0 LICENSE
  5. +5 −5 README.md
  6. +1 −1 aws/attempt_test.go
  7. +126 −24 aws/aws.go
  8. +10 −1 aws/aws_test.go
  9. +158 −76 aws/sign.go
  10. +64 −6 aws/sign_test.go
  11. +83 −0 ec2/blockdevicemappings_test.go
  12. +96 −28 ec2/ec2.go
  13. +9 −4 ec2/ec2_test.go
  14. +13 −5 ec2/ec2i_test.go
  15. +355 −40 ec2/ec2t_test.go
  16. +71 −0 ec2/ec2test/account_attributes.go
  17. +97 −0 ec2/ec2test/availability_zones.go
  18. +85 −0 ec2/ec2test/block_devices.go
  19. +13 −0 ec2/ec2test/doc.go
  20. +16 −0 ec2/ec2test/export_test.go
  21. +8 −0 ec2/ec2test/filter.go
  22. +152 −0 ec2/ec2test/helpers.go
  23. +533 −0 ec2/ec2test/instances.go
  24. +92 −0 ec2/ec2test/interface_attachments.go
  25. +122 −0 ec2/ec2test/internet_gateways.go
  26. +113 −0 ec2/ec2test/internet_gateways_test.go
  27. +478 −0 ec2/ec2test/network_interfaces.go
  28. +110 −0 ec2/ec2test/private_ips.go
  29. +47 −0 ec2/ec2test/reservations.go
  30. +184 −0 ec2/ec2test/route_tables.go
  31. +154 −0 ec2/ec2test/route_tables_test.go
  32. +547 −0 ec2/ec2test/securty_groups.go
  33. +78 −2,075 ec2/ec2test/server.go
  34. +166 −0 ec2/ec2test/server_internals.go
  35. +267 −0 ec2/ec2test/subnets.go
  36. +129 −0 ec2/ec2test/subnets_test.go
  37. +122 −0 ec2/ec2test/tags.go
  38. +137 −0 ec2/ec2test/volume_attachments.go
  39. +192 −0 ec2/ec2test/volumes.go
  40. +284 −0 ec2/ec2test/vpcs.go
  41. +322 −0 ec2/ec2test/vpcs_test.go
  42. +61 −0 ec2/internet_gateways.go
  43. +64 −0 ec2/internet_gateways_test.go
  44. +326 −58 ec2/networkinterfaces_test.go
  45. +2 −2 ec2/privateips_test.go
  46. +166 −1 ec2/responses_test.go
  47. +119 −0 ec2/route_tables.go
  48. +118 −0 ec2/route_tables_test.go
  49. +22 −0 ec2/subnets.go
  50. +27 −10 ec2/subnets_test.go
  51. +188 −0 ec2/volumes.go
  52. +358 −0 ec2/volumes_test.go
  53. +2 −2 ec2/vpc_test.go
  54. +1 −1 exp/mturk/export_test.go
  55. +1 −1 exp/mturk/mturk.go
  56. +3 −3 exp/mturk/mturk_test.go
  57. +1 −1 exp/mturk/sign.go
  58. +2 −2 exp/mturk/sign_test.go
  59. +1 −1 exp/sdb/export_test.go
  60. +1 −1 exp/sdb/sdb.go
  61. +4 −4 exp/sdb/sdb_test.go
  62. +1 −1 exp/sdb/sign.go
  63. +2 −2 exp/sdb/sign_test.go
  64. +1 −1 exp/sns/sign.go
  65. +1 −1 exp/sns/sns.go
  66. +4 −4 exp/sns/sns_test.go
  67. +1 −1 iam/iam.go
  68. +4 −4 iam/iam_test.go
  69. +3 −3 iam/iami_test.go
  70. +4 −4 iam/iamt_test.go
  71. +1 −1 iam/iamtest/server.go
  72. +1 −1 iam/sign.go
  73. +7 −5 s3/export_test.go
  74. +223 −131 s3/multi.go
  75. +31 −20 s3/multi_test.go
  76. +231 −238 s3/s3.go
  77. +75 −38 s3/s3_test.go
  78. +82 −63 s3/s3i_test.go
  79. +3 −7 s3/s3t_test.go
  80. +1 −1 s3/s3test/server.go
  81. +0 −113 s3/sign.go
  82. +0 −133 s3/sign_test.go
  83. +1 −1 testutil/suite.go
View
@@ -0,0 +1,10 @@
+tags
+!tags/
+TAGS
+!TAGS/
+.emacs.desktop
+.emacs.desktop.lock
+*.test
+*.sw[nop]
+cover
+.#*
View
@@ -10,7 +10,7 @@ install:
before_script:
- export DEFAULT_TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR
- - export TRAVIS_BUILD_DIR=$HOME/gopath/src/gopkg.in/amz.v2
+ - export TRAVIS_BUILD_DIR=$HOME/gopath/src/gopkg.in/amz.v3
- mkdir -p $TRAVIS_BUILD_DIR
- mv -vfT $DEFAULT_TRAVIS_BUILD_DIR $TRAVIS_BUILD_DIR
View
@@ -12,6 +12,7 @@ Please, keep the list sorted.
Full name | E-mail | GitHub account
----------|--------|---------------
+Alexander Surma | surma {at} surmair.de | [@surma](https://github.com/surma)
Andrew Wilkins | andrew.wilkins {at} canonical.com | [@axw](http://github.com/axw)
Dave Cheney | dave.cheney {at} canonical.com | [@davecheney](http://github.com/davecheney)
Dimiter Naydenov | dimiter.naydenov {at} canonical.com | [@dimitern](http://github.com/dimitern)
View
@@ -1,3 +1,4 @@
+Copyright (C) 2011-2015 Canonical Ltd.
This software is licensed under the LGPLv3, included below.
As a special exception to the GNU Lesser General Public License version 3
View
@@ -3,22 +3,22 @@ goamz
Go package to interact with Amazon Web Services
-[![Build Status](https://travis-ci.org/go-amz/amz.svg?branch=v2)](https://travis-ci.org/go-amz/amz) [![GoDoc](https://godoc.org/gopkg.in/amz.v2?status.png)](http://godoc.org/gopkg.in/amz.v2)
+[![Build Status](https://travis-ci.org/go-amz/amz.svg?branch=v3)](https://travis-ci.org/go-amz/amz) [![GoDoc](https://godoc.org/gopkg.in/amz.v3?status.png)](http://godoc.org/gopkg.in/amz.v3)
Instructions
------------
Install the package with:
- go get gopkg.in/amz.v2/...
+ go get gopkg.in/amz.v3/...
Import it with:
- import "gopkg.in/amz.v2/<package>"
+ import "gopkg.in/amz.v3/<package>"
Example:
- import "gopkg.in/amz.v2/ec2"
+ import "gopkg.in/amz.v3/ec2"
and use _ec2_ as the package name inside the code.
The same applies to the other sub-packages: _aws_, _s3_, etc.
@@ -29,7 +29,7 @@ For more details, visit the project page:
and the API documentation:
-* https://gopkg.in/amz.v2
+* https://gopkg.in/amz.v3
Users Group
-----------
View
@@ -5,7 +5,7 @@ import (
. "gopkg.in/check.v1"
- "gopkg.in/amz.v2/aws"
+ "gopkg.in/amz.v3/aws"
)
func (S) TestAttemptTiming(c *C) {
View
@@ -11,27 +11,34 @@ package aws
import (
"errors"
"os"
+ "strings"
)
// Region defines the URLs where AWS services may be accessed.
//
// See http://goo.gl/d8BP1 for more details.
type Region struct {
- Name string // the canonical name of this region.
+ Name string // The canonical name of this region.
EC2Endpoint string
S3Endpoint string
S3BucketEndpoint string // Not needed by AWS S3. Use ${bucket} for bucket name.
S3LocationConstraint bool // true if this region requires a LocationConstraint declaration.
S3LowercaseBucket bool // true if the region requires bucket names to be lower case.
- SDBEndpoint string
+ SDBEndpoint string // Not all regions have simpleDB, e.g. Frankfurt (eu-central-1) does not.
SNSEndpoint string
SQSEndpoint string
IAMEndpoint string
- Sign Signer // Method which will be used to sign requests.
+}
+
+func (r Region) ResolveS3BucketEndpoint(bucketName string) string {
+ if r.S3BucketEndpoint != "" {
+ return strings.ToLower(strings.Replace(r.S3BucketEndpoint, "${bucket}", bucketName, -1))
+ }
+ return strings.ToLower(r.S3Endpoint + "/" + bucketName + "/")
}
var USEast = Region{
- "us-east-1",
+ "us-east-1", // US East (N. Virginia)
"https://ec2.us-east-1.amazonaws.com",
"https://s3.amazonaws.com",
"",
@@ -41,11 +48,23 @@ var USEast = Region{
"https://sns.us-east-1.amazonaws.com",
"https://sqs.us-east-1.amazonaws.com",
"https://iam.amazonaws.com",
- SignV2,
+}
+
+var USEast2 = Region{
+ "us-east-2", // US East (Ohio)
+ "https://ec2.us-east-2.amazonaws.com",
+ "https://s3.us-east-2.amazonaws.com",
+ "",
+ true,
+ true,
+ "",
+ "https://sns.us-east-2.amazonaws.com",
+ "https://sqs.us-east-2.amazonaws.com",
+ "https://iam.amazonaws.com",
}
var USWest = Region{
- "us-west-1",
+ "us-west-1", // US West (N. California)
"https://ec2.us-west-1.amazonaws.com",
"https://s3-us-west-1.amazonaws.com",
"",
@@ -55,11 +74,10 @@ var USWest = Region{
"https://sns.us-west-1.amazonaws.com",
"https://sqs.us-west-1.amazonaws.com",
"https://iam.amazonaws.com",
- SignV2,
}
var USWest2 = Region{
- "us-west-2",
+ "us-west-2", // US West (Oregon)
"https://ec2.us-west-2.amazonaws.com",
"https://s3-us-west-2.amazonaws.com",
"",
@@ -69,11 +87,36 @@ var USWest2 = Region{
"https://sns.us-west-2.amazonaws.com",
"https://sqs.us-west-2.amazonaws.com",
"https://iam.amazonaws.com",
- SignV2,
+}
+
+var USGovWest = Region{
+ "us-gov-west-1", // Isolated regions, AWS GovCloud (US)
+ "https://ec2.us-gov-west-1.amazonaws.com",
+ "https://s3-us-gov-west-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "",
+ "https://sns.us-gov-west-1.amazonaws.com",
+ "https://sqs.us-gov-west-1.amazonaws.com",
+ "https://iam.us-gov.amazonaws.com",
+}
+
+var CACentral = Region{
+ "ca-central-1", // CA (Central)
+ "https://ec2.ca-central-1.amazonaws.com",
+ "https://s3-ca-central-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "",
+ "https://sns.ca-central-1.amazonaws.com",
+ "https://sqs.ca-central-1.amazonaws.com",
+ "https://iam.amazonaws.com",
}
var EUWest = Region{
- "eu-west-1",
+ "eu-west-1", // EU (Ireland)
"https://ec2.eu-west-1.amazonaws.com",
"https://s3-eu-west-1.amazonaws.com",
"",
@@ -83,11 +126,49 @@ var EUWest = Region{
"https://sns.eu-west-1.amazonaws.com",
"https://sqs.eu-west-1.amazonaws.com",
"https://iam.amazonaws.com",
- SignV2,
+}
+
+var EUWest2 = Region{
+ "eu-west-2", // EU (London)
+ "https://ec2.eu-west-2.amazonaws.com",
+ "https://s3-eu-west-2.amazonaws.com",
+ "",
+ true,
+ true,
+ "",
+ "https://sns.eu-west-2.amazonaws.com",
+ "https://sqs.eu-west-2.amazonaws.com",
+ "https://iam.amazonaws.com",
+}
+
+var EUCentral = Region{
+ "eu-central-1", // EU (Frankfurt)
+ "https://ec2.eu-central-1.amazonaws.com",
+ "https://s3-eu-central-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "",
+ "https://sns.eu-central-1.amazonaws.com",
+ "https://sqs.eu-central-1.amazonaws.com",
+ "https://iam.amazonaws.com",
+}
+
+var APSouth = Region{
+ "ap-south-1", // AP (Mumbai)
+ "https://ec2.ap-south-1.amazonaws.com",
+ "https://s3-ap-south-1.amazonaws.com",
+ "",
+ true,
+ true,
+ "",
+ "https://sns.ap-south-1.amazonaws.com",
+ "https://sqs.ap-south-1.amazonaws.com",
+ "https://iam.amazonaws.com",
}
var APSoutheast = Region{
- "ap-southeast-1",
+ "ap-southeast-1", // Asia Pacific (Singapore)
"https://ec2.ap-southeast-1.amazonaws.com",
"https://s3-ap-southeast-1.amazonaws.com",
"",
@@ -97,11 +178,10 @@ var APSoutheast = Region{
"https://sns.ap-southeast-1.amazonaws.com",
"https://sqs.ap-southeast-1.amazonaws.com",
"https://iam.amazonaws.com",
- SignV2,
}
var APSoutheast2 = Region{
- "ap-southeast-2",
+ "ap-southeast-2", // Asia Pacific (Sydney)
"https://ec2.ap-southeast-2.amazonaws.com",
"https://s3-ap-southeast-2.amazonaws.com",
"",
@@ -111,11 +191,10 @@ var APSoutheast2 = Region{
"https://sns.ap-southeast-2.amazonaws.com",
"https://sqs.ap-southeast-2.amazonaws.com",
"https://iam.amazonaws.com",
- SignV2,
}
var APNortheast = Region{
- "ap-northeast-1",
+ "ap-northeast-1", // Asia Pacific (Tokyo)
"https://ec2.ap-northeast-1.amazonaws.com",
"https://s3-ap-northeast-1.amazonaws.com",
"",
@@ -125,11 +204,23 @@ var APNortheast = Region{
"https://sns.ap-northeast-1.amazonaws.com",
"https://sqs.ap-northeast-1.amazonaws.com",
"https://iam.amazonaws.com",
- SignV2,
+}
+
+var APNortheast2 = Region{
+ "ap-northeast-2", // Asia Pacific (Seoul)
+ "https://ec2.ap-northeast-2.amazonaws.com",
+ "https://s3-ap-northeast-2.amazonaws.com",
+ "",
+ true,
+ true,
+ "",
+ "https://sns.ap-northeast-2.amazonaws.com",
+ "https://sqs.ap-northeast-2.amazonaws.com",
+ "https://iam.amazonaws.com",
}
var SAEast = Region{
- "sa-east-1",
+ "sa-east-1", // South America (Sao Paulo)
"https://ec2.sa-east-1.amazonaws.com",
"https://s3-sa-east-1.amazonaws.com",
"",
@@ -139,11 +230,10 @@ var SAEast = Region{
"https://sns.sa-east-1.amazonaws.com",
"https://sqs.sa-east-1.amazonaws.com",
"https://iam.amazonaws.com",
- SignV2,
}
var CNNorth = Region{
- "cn-north-1",
+ "cn-north-1", // Isolated regions, China (Beijing)
"https://ec2.cn-north-1.amazonaws.com.cn",
"https://s3.cn-north-1.amazonaws.com.cn",
"",
@@ -152,20 +242,26 @@ var CNNorth = Region{
"https://sdb.cn-north-1.amazonaws.com.cn",
"https://sns.cn-north-1.amazonaws.com.cn",
"https://sqs.cn-north-1.amazonaws.com.cn",
- "https://iam.amazonaws.com.cn",
- SignV4Factory("cn-north-1"),
+ "https://iam.cn-north-1.amazonaws.com.cn",
}
var Regions = map[string]Region{
APNortheast.Name: APNortheast,
+ APNortheast2.Name: APNortheast2,
+ APSouth.Name: APSouth,
APSoutheast.Name: APSoutheast,
APSoutheast2.Name: APSoutheast2,
EUWest.Name: EUWest,
+ EUWest2.Name: EUWest2,
+ EUCentral.Name: EUCentral,
USEast.Name: USEast,
+ USEast2.Name: USEast2,
USWest.Name: USWest,
USWest2.Name: USWest2,
+ USGovWest.Name: USGovWest,
SAEast.Name: SAEast,
CNNorth.Name: CNNorth,
+ CACentral.Name: CACentral,
}
type Auth struct {
@@ -186,15 +282,21 @@ func init() {
// EnvAuth creates an Auth based on environment information.
// The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment
// variables are used as the first preference, but EC2_ACCESS_KEY
-// and EC2_SECRET_KEY environment variables are also supported.
+// and EC2_SECRET_KEY or AWS_ACCESS_KEY and AWS_SECRET_KEY
+// environment variables are also supported.
func EnvAuth() (auth Auth, err error) {
auth.AccessKey = os.Getenv("AWS_ACCESS_KEY_ID")
auth.SecretKey = os.Getenv("AWS_SECRET_ACCESS_KEY")
- // We fallback to EC2_ env variables if the AWS_ variants are not used.
+ // first fallbaback to EC2_ env variable
if auth.AccessKey == "" && auth.SecretKey == "" {
auth.AccessKey = os.Getenv("EC2_ACCESS_KEY")
auth.SecretKey = os.Getenv("EC2_SECRET_KEY")
}
+ // second fallbaback to AWS_ env variable
+ if auth.AccessKey == "" && auth.SecretKey == "" {
+ auth.AccessKey = os.Getenv("AWS_ACCESS_KEY")
+ auth.SecretKey = os.Getenv("AWS_SECRET_KEY")
+ }
if auth.AccessKey == "" {
err = errors.New("AWS_ACCESS_KEY_ID not found in environment")
}
View
@@ -7,7 +7,7 @@ import (
. "gopkg.in/check.v1"
- "gopkg.in/amz.v2/aws"
+ "gopkg.in/amz.v3/aws"
)
func Test(t *testing.T) {
@@ -63,6 +63,15 @@ func (s *S) TestEnvAuthLegacy(c *C) {
c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
}
+func (s *S) TestEnvAuthAws(c *C) {
+ os.Clearenv()
+ os.Setenv("AWS_SECRET_KEY", "secret")
+ os.Setenv("AWS_ACCESS_KEY", "access")
+ auth, err := aws.EnvAuth()
+ c.Assert(err, IsNil)
+ c.Assert(auth, Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
+}
+
func (s *S) TestEncode(c *C) {
c.Assert(aws.Encode("foo"), Equals, "foo")
c.Assert(aws.Encode("/"), Equals, "%2F")
Oops, something went wrong.

No commit comments for this range