Skip to content

Commit

Permalink
Merge branch 'master' of github.com:coveo/terraform-provider-aws into…
Browse files Browse the repository at this point in the history
… new-ssm-parameters-features
  • Loading branch information
Julien Duchesne committed Nov 10, 2017
2 parents a80788f + d678ba0 commit c1b2a77
Show file tree
Hide file tree
Showing 1,433 changed files with 360,199 additions and 13,401 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ website/vendor

# Keep windows files with windows line endings
*.winfile eol=crlf
dist
25 changes: 25 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Build customization
builds:
- binary: terraform-provider-aws
goos:
- windows
- darwin
- linux
goarch:
- amd64
- 386
ignore:
- goos: darwin
goarch: 386

# Archive customization
archive:
format: zip

replacements:
amd64: 64-bits
386: 32-bits
darwin: macOS

files:
- nothing.*
39 changes: 30 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,46 @@ dist: trusty
sudo: false
language: go
go:
- 1.8.1
- 1.9.1

before_install:
- if [ ${TRAVIS_TAG::1} = v ];
then
cd ../.. &&
mv coveo terraform-providers &&
cd terraform-providers/terraform-provider-aws;
fi

install:
# This script is used by the Travis build to install a cookie for
# go.googlesource.com so rate limits are higher when using `go get` to fetch
# packages that live there.
# See: https://github.com/golang/go/issues/12933
- bash scripts/gogetcookie.sh
- go get github.com/kardianos/govendor
- if [ ${TRAVIS_TAG::1} = v ];
then
bash scripts/gogetcookie.sh &&
go get github.com/kardianos/govendor;
fi

script:
- make test
- make vendor-status
- make vet
- if [ ${TRAVIS_TAG::1} = v ];
then
make test &&
make vendor-status &&
make vet;
fi

branches:
only:
- master
# branches:
# only:
# - master

matrix:
fast_finish: true
allow_failures:
- go: tip

after_success:
- if [ ${TRAVIS_TAG::1} = v ];
then
curl -sL https://git.io/goreleaser | bash;
fi
156 changes: 108 additions & 48 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ make build

Using the provider
----------------------
## Fill in for each provider
If you're building the provider, follow the instructions to [install it as a plugin.](https://www.terraform.io/docs/plugins/basics.html#installing-a-plugin) to install it as a plugin. After placing it into your plugins directory, run `terraform init` to initialize it.

Developing the Provider
---------------------------
Expand All @@ -50,6 +50,8 @@ $ $GOPATH/bin/terraform-provider-aws

In order to test the provider, you can simply run `make test`.

*Note:* Make sure no `AWS_ACCESS_KEY_ID` or `AWS_SECRET_ACCESS_KEY` variables are set, and there's no `[default]` section in the AWS credentials file `~/.aws/credentials`.

```sh
$ make test
```
Expand Down
21 changes: 21 additions & 0 deletions aws/awserr.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,24 @@ func retryOnAwsCode(code string, f func() (interface{}, error)) (interface{}, er
})
return resp, err
}

func retryOnAwsCodes(codes []string, f func() (interface{}, error)) (interface{}, error) {
var resp interface{}
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
var err error
resp, err = f()
if err != nil {
awsErr, ok := err.(awserr.Error)
if ok {
for _, code := range codes {
if awsErr.Code() == code {
return resource.RetryableError(err)
}
}
}
return resource.NonRetryableError(err)
}
return nil
})
return resp, err
}
8 changes: 6 additions & 2 deletions aws/cloudfront_distribution_configuration_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,12 @@ func viewerCertificateHash(v interface{}) int {
} else {
buf.WriteString(fmt.Sprintf("%t-", m["cloudfront_default_certificate"].(bool)))
}
if v, ok := m["minimum_protocol_version"]; ok && v.(string) != "" {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
// if minimum_protocol_version is not specified and we use cloudfront_default_certificate,
// ignore current value of minimum_protocol_version
if c, ok := m["cloudfront_default_certificate"]; !(ok && c.(bool)) {
if v, ok := m["minimum_protocol_version"]; ok && v.(string) != "" {
buf.WriteString(fmt.Sprintf("%s-", v.(string)))
}
}
return hashcode.String(buf.String())
}
Expand Down
3 changes: 3 additions & 0 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (
"github.com/aws/aws-sdk-go/service/redshift"
"github.com/aws/aws-sdk-go/service/route53"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/servicecatalog"
"github.com/aws/aws-sdk-go/service/ses"
"github.com/aws/aws-sdk-go/service/sfn"
"github.com/aws/aws-sdk-go/service/simpledb"
Expand Down Expand Up @@ -144,6 +145,7 @@ type AWSClient struct {
appautoscalingconn *applicationautoscaling.ApplicationAutoScaling
autoscalingconn *autoscaling.AutoScaling
s3conn *s3.S3
scconn *servicecatalog.ServiceCatalog
sesConn *ses.SES
simpledbconn *simpledb.SimpleDB
sqsconn *sqs.SQS
Expand Down Expand Up @@ -379,6 +381,7 @@ func (c *Config) Client() (interface{}, error) {
client.redshiftconn = redshift.New(sess)
client.simpledbconn = simpledb.New(sess)
client.s3conn = s3.New(awsS3Sess)
client.scconn = servicecatalog.New(sess)
client.sesConn = ses.New(sess)
client.sfnconn = sfn.New(sess)
client.snsconn = sns.New(awsSnsSess)
Expand Down
1 change: 0 additions & 1 deletion aws/data_source_aws_availability_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func dataSourceAwsAvailabilityZoneRead(d *schema.ResourceData, meta interface{})
nameSuffix := (*az.ZoneName)[len(*az.RegionName):]

d.SetId(*az.ZoneName)
d.Set("id", az.ZoneName)
d.Set("name", az.ZoneName)
d.Set("name_suffix", nameSuffix)
d.Set("region", az.RegionName)
Expand Down
5 changes: 0 additions & 5 deletions aws/data_source_aws_canonical_user_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ func dataSourceAwsCanonicalUserId() *schema.Resource {
Read: dataSourceAwsCanonicalUserIdRead,

Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
},
"display_name": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -41,7 +37,6 @@ func dataSourceAwsCanonicalUserIdRead(d *schema.ResourceData, meta interface{})
}

d.SetId(aws.StringValue(resp.Owner.ID))
d.Set("id", resp.Owner.ID)
d.Set("display_name", resp.Owner.DisplayName)

return nil
Expand Down
57 changes: 57 additions & 0 deletions aws/data_source_aws_cloudtrail_service_account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package aws

import (
"fmt"

"github.com/hashicorp/terraform/helper/schema"
)

// See http://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-supported-regions.html
var cloudTrailServiceAccountPerRegionMap = map[string]string{
"us-east-1": "086441151436",
"us-east-2": "475085895292",
"us-west-1": "388731089494",
"us-west-2": "113285607260",
"ap-south-1": "977081816279",
"ap-northeast-2": "492519147666",
"ap-southeast-1": "903692715234",
"ap-southeast-2": "284668455005",
"ap-northeast-1": "216624486486",
"ca-central-1": "819402241893",
"eu-central-1": "035351147821",
"eu-west-1": "859597730677",
"eu-west-2": "282025262664",
"sa-east-1": "814480443879",
}

func dataSourceAwsCloudTrailServiceAccount() *schema.Resource {
return &schema.Resource{
Read: dataSourceAwsCloudTrailServiceAccountRead,

Schema: map[string]*schema.Schema{
"region": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"arn": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

func dataSourceAwsCloudTrailServiceAccountRead(d *schema.ResourceData, meta interface{}) error {
region := meta.(*AWSClient).region
if v, ok := d.GetOk("region"); ok {
region = v.(string)
}

if accid, ok := cloudTrailServiceAccountPerRegionMap[region]; ok {
d.SetId(accid)
d.Set("arn", iamArnString(meta.(*AWSClient).partition, accid, "root"))
return nil
}

return fmt.Errorf("Unknown region (%q)", region)
}
40 changes: 40 additions & 0 deletions aws/data_source_aws_cloudtrail_service_account_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package aws

import (
"testing"

"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAWSCloudTrailServiceAccount_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCheckAwsCloudTrailServiceAccountConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_cloudtrail_service_account.main", "id", "113285607260"),
resource.TestCheckResourceAttr("data.aws_cloudtrail_service_account.main", "arn", "arn:aws:iam::113285607260:root"),
),
},
resource.TestStep{
Config: testAccCheckAwsCloudTrailServiceAccountExplicitRegionConfig,
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("data.aws_cloudtrail_service_account.regional", "id", "282025262664"),
resource.TestCheckResourceAttr("data.aws_cloudtrail_service_account.regional", "arn", "arn:aws:iam::282025262664:root"),
),
},
},
})
}

const testAccCheckAwsCloudTrailServiceAccountConfig = `
data "aws_cloudtrail_service_account" "main" { }
`

const testAccCheckAwsCloudTrailServiceAccountExplicitRegionConfig = `
data "aws_cloudtrail_service_account" "regional" {
region = "eu-west-2"
}
`
Loading

0 comments on commit c1b2a77

Please sign in to comment.