Skip to content

Commit

Permalink
Merge branch 'master' into issue-3288
Browse files Browse the repository at this point in the history
  • Loading branch information
ddcprg authored Mar 21, 2018
2 parents 05b981a + 83ec4fb commit ec7dacf
Show file tree
Hide file tree
Showing 568 changed files with 45,418 additions and 10,320 deletions.
25 changes: 25 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ Specifically, we have provided checklists below for each type of issue and pull
request that can happen on the project. These checklists represent everything
we need to be able to review and respond quickly.

<!-- TOC depthFrom:2 -->

- [HashiCorp vs. Community Providers](#hashicorp-vs-community-providers)
- [Issues](#issues)
- [Issue Reporting Checklists](#issue-reporting-checklists)
- [Bug Reports](#bug-reports)
- [Feature Requests](#feature-requests)
- [Questions](#questions)
- [Issue Lifecycle](#issue-lifecycle)
- [Pull Requests](#pull-requests)
- [Pull Request Lifecycle](#pull-request-lifecycle)
- [Checklists for Contribution](#checklists-for-contribution)
- [Documentation Update](#documentation-update)
- [Enhancement/Bugfix to a Resource](#enhancementbugfix-to-a-resource)
- [New Resource](#new-resource)
- [New Provider](#new-provider)
- [New Region](#new-region)
- [Terraform Schema and Code Idiosyncracies](#terraform-schema-and-code-idiosyncracies)
- [Writing Acceptance Tests](#writing-acceptance-tests)
- [Acceptance Tests Often Cost Money to Run](#acceptance-tests-often-cost-money-to-run)
- [Running an Acceptance Test](#running-an-acceptance-test)
- [Writing an Acceptance Test](#writing-an-acceptance-test)

<!-- /TOC -->

## HashiCorp vs. Community Providers

We separate providers out into what we call "HashiCorp Providers" and
Expand Down
275 changes: 229 additions & 46 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions aws/cloudfront_distribution_configuration_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,11 @@ func expandCacheBehavior(m map[string]interface{}) *cloudfront.CacheBehavior {
ViewerProtocolPolicy: aws.String(m["viewer_protocol_policy"].(string)),
TargetOriginId: aws.String(m["target_origin_id"].(string)),
ForwardedValues: expandForwardedValues(m["forwarded_values"].(*schema.Set).List()[0].(map[string]interface{})),
MinTTL: aws.Int64(int64(m["min_ttl"].(int))),
MaxTTL: aws.Int64(int64(m["max_ttl"].(int))),
DefaultTTL: aws.Int64(int64(m["default_ttl"].(int))),
MaxTTL: aws.Int64(int64(m["max_ttl"].(int))),
MinTTL: aws.Int64(int64(m["min_ttl"].(int))),
}

if v, ok := m["trusted_signers"]; ok {
cb.TrustedSigners = expandTrustedSigners(v.([]interface{}))
} else {
Expand Down
28 changes: 14 additions & 14 deletions aws/cloudfront_distribution_configuration_structure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ func defaultCacheBehaviorConf() map[string]interface{} {
"viewer_protocol_policy": "allow-all",
"target_origin_id": "myS3Origin",
"forwarded_values": schema.NewSet(forwardedValuesHash, []interface{}{forwardedValuesConf()}),
"min_ttl": 86400,
"min_ttl": 0,
"trusted_signers": trustedSignersConf(),
"lambda_function_association": lambdaFunctionAssociationsConf(),
"max_ttl": 365000000,
"max_ttl": 31536000,
"smooth_streaming": false,
"default_ttl": 86400,
"allowed_methods": allowedMethodsConf(),
Expand Down Expand Up @@ -270,14 +270,14 @@ func TestCloudFrontStructure_expandDefaultCacheBehavior(t *testing.T) {
if reflect.DeepEqual(dcb.ForwardedValues.Headers.Items, expandStringList(headersConf())) != true {
t.Fatalf("Expected Items to be %v, got %v", headersConf(), dcb.ForwardedValues.Headers.Items)
}
if *dcb.MinTTL != 86400 {
t.Fatalf("Expected MinTTL to be 86400, got %v", *dcb.MinTTL)
if *dcb.MinTTL != 0 {
t.Fatalf("Expected MinTTL to be 0, got %v", *dcb.MinTTL)
}
if reflect.DeepEqual(dcb.TrustedSigners.Items, expandStringList(trustedSignersConf())) != true {
t.Fatalf("Expected TrustedSigners.Items to be %v, got %v", trustedSignersConf(), dcb.TrustedSigners.Items)
}
if *dcb.MaxTTL != 365000000 {
t.Fatalf("Expected MaxTTL to be 365000000, got %v", *dcb.MaxTTL)
if *dcb.MaxTTL != 31536000 {
t.Fatalf("Expected MaxTTL to be 31536000, got %v", *dcb.MaxTTL)
}
if *dcb.SmoothStreaming != false {
t.Fatalf("Expected SmoothStreaming to be false, got %v", *dcb.SmoothStreaming)
Expand Down Expand Up @@ -322,14 +322,14 @@ func TestCloudFrontStructure_expandCacheBehavior(t *testing.T) {
if reflect.DeepEqual(cb.ForwardedValues.Headers.Items, expandStringList(headersConf())) != true {
t.Fatalf("Expected Items to be %v, got %v", headersConf(), cb.ForwardedValues.Headers.Items)
}
if *cb.MinTTL != 86400 {
t.Fatalf("Expected MinTTL to be 86400, got %v", *cb.MinTTL)
if *cb.MinTTL != 0 {
t.Fatalf("Expected MinTTL to be 0, got %v", *cb.MinTTL)
}
if reflect.DeepEqual(cb.TrustedSigners.Items, expandStringList(trustedSignersConf())) != true {
t.Fatalf("Expected TrustedSigners.Items to be %v, got %v", trustedSignersConf(), cb.TrustedSigners.Items)
}
if *cb.MaxTTL != 365000000 {
t.Fatalf("Expected MaxTTL to be 365000000, got %v", *cb.MaxTTL)
if *cb.MaxTTL != 31536000 {
t.Fatalf("Expected MaxTTL to be 31536000, got %v", *cb.MaxTTL)
}
if *cb.SmoothStreaming != false {
t.Fatalf("Expected SmoothStreaming to be false, got %v", *cb.SmoothStreaming)
Expand Down Expand Up @@ -384,14 +384,14 @@ func TestCloudFrontStructure_flattenCacheBehavior(t *testing.T) {
if len(diff.List()) > 0 {
t.Fatalf("Expected out[forwarded_values] to be %v, got %v, diff: %v", out["forwarded_values"], in["forwarded_values"], diff)
}
if out["min_ttl"] != int(86400) {
t.Fatalf("Expected out[min_ttl] to be 86400 (int), got %v", out["forwarded_values"])
if out["min_ttl"] != int(0) {
t.Fatalf("Expected out[min_ttl] to be 0 (int), got %v", out["min_ttl"])
}
if reflect.DeepEqual(out["trusted_signers"], in["trusted_signers"]) != true {
t.Fatalf("Expected out[trusted_signers] to be %v, got %v", in["trusted_signers"], out["trusted_signers"])
}
if out["max_ttl"] != int(365000000) {
t.Fatalf("Expected out[max_ttl] to be 365000000 (int), got %v", out["max_ttl"])
if out["max_ttl"] != int(31536000) {
t.Fatalf("Expected out[max_ttl] to be 31536000 (int), got %v", out["max_ttl"])
}
if out["smooth_streaming"] != false {
t.Fatalf("Expected out[smooth_streaming] to be false, got %v", out["smooth_streaming"])
Expand Down
37 changes: 36 additions & 1 deletion aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import (
"github.com/aws/aws-sdk-go/service/acm"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/aws/aws-sdk-go/service/applicationautoscaling"
"github.com/aws/aws-sdk-go/service/appsync"
"github.com/aws/aws-sdk-go/service/athena"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/batch"
"github.com/aws/aws-sdk-go/service/cloud9"
"github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/aws/aws-sdk-go/service/cloudfront"
"github.com/aws/aws-sdk-go/service/cloudtrail"
Expand All @@ -35,6 +37,7 @@ import (
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider"
"github.com/aws/aws-sdk-go/service/configservice"
"github.com/aws/aws-sdk-go/service/databasemigrationservice"
"github.com/aws/aws-sdk-go/service/dax"
"github.com/aws/aws-sdk-go/service/devicefarm"
"github.com/aws/aws-sdk-go/service/directconnect"
"github.com/aws/aws-sdk-go/service/directoryservice"
Expand Down Expand Up @@ -65,6 +68,7 @@ import (
"github.com/aws/aws-sdk-go/service/mediastore"
"github.com/aws/aws-sdk-go/service/mq"
"github.com/aws/aws-sdk-go/service/opsworks"
"github.com/aws/aws-sdk-go/service/organizations"
"github.com/aws/aws-sdk-go/service/rds"
"github.com/aws/aws-sdk-go/service/redshift"
"github.com/aws/aws-sdk-go/service/route53"
Expand Down Expand Up @@ -138,6 +142,7 @@ type Config struct {

type AWSClient struct {
cfconn *cloudformation.CloudFormation
cloud9conn *cloud9.Cloud9
cloudfrontconn *cloudfront.CloudFront
cloudtrailconn *cloudtrail.CloudTrail
cloudwatchconn *cloudwatch.CloudWatch
Expand All @@ -146,6 +151,7 @@ type AWSClient struct {
cognitoconn *cognitoidentity.CognitoIdentity
cognitoidpconn *cognitoidentityprovider.CognitoIdentityProvider
configconn *configservice.ConfigService
daxconn *dax.DAX
devicefarmconn *devicefarm.DeviceFarm
dmsconn *databasemigrationservice.DatabaseMigrationService
dsconn *directoryservice.DirectoryService
Expand Down Expand Up @@ -189,6 +195,7 @@ type AWSClient struct {
lightsailconn *lightsail.Lightsail
mqconn *mq.MQ
opsworksconn *opsworks.OpsWorks
organizationsconn *organizations.Organizations
glacierconn *glacier.Glacier
guarddutyconn *guardduty.GuardDuty
codebuildconn *codebuild.CodeBuild
Expand All @@ -206,6 +213,7 @@ type AWSClient struct {
athenaconn *athena.Athena
dxconn *directconnect.DirectConnect
mediastoreconn *mediastore.MediaStore
appsyncconn *appsync.AppSync
}

func (c *AWSClient) S3() *s3.S3 {
Expand Down Expand Up @@ -398,6 +406,7 @@ func (c *Config) Client() (interface{}, error) {
client.apigateway = apigateway.New(awsApigatewaySess)
client.appautoscalingconn = applicationautoscaling.New(sess)
client.autoscalingconn = autoscaling.New(sess)
client.cloud9conn = cloud9.New(sess)
client.cfconn = cloudformation.New(awsCfSess)
client.cloudfrontconn = cloudfront.New(sess)
client.cloudtrailconn = cloudtrail.New(sess)
Expand All @@ -410,8 +419,9 @@ func (c *Config) Client() (interface{}, error) {
client.configconn = configservice.New(sess)
client.cognitoconn = cognitoidentity.New(sess)
client.cognitoidpconn = cognitoidentityprovider.New(sess)
client.dmsconn = databasemigrationservice.New(sess)
client.codepipelineconn = codepipeline.New(sess)
client.daxconn = dax.New(awsDynamoSess)
client.dmsconn = databasemigrationservice.New(sess)
client.dsconn = directoryservice.New(sess)
client.dynamodbconn = dynamodb.New(awsDynamoSess)
client.ecrconn = ecr.New(awsEcrSess)
Expand All @@ -436,6 +446,7 @@ func (c *Config) Client() (interface{}, error) {
client.lightsailconn = lightsail.New(sess)
client.mqconn = mq.New(sess)
client.opsworksconn = opsworks.New(sess)
client.organizationsconn = organizations.New(sess)
client.r53conn = route53.New(r53Sess)
client.rdsconn = rds.New(awsRdsSess)
client.redshiftconn = redshift.New(sess)
Expand All @@ -455,6 +466,7 @@ func (c *Config) Client() (interface{}, error) {
client.athenaconn = athena.New(sess)
client.dxconn = directconnect.New(sess)
client.mediastoreconn = mediastore.New(sess)
client.appsyncconn = appsync.New(sess)

// Workaround for https://github.com/aws/aws-sdk-go/issues/1376
client.kinesisconn.Handlers.Retry.PushBack(func(r *request.Request) {
Expand Down Expand Up @@ -484,6 +496,29 @@ func (c *Config) Client() (interface{}, error) {
}
})

// See https://github.com/aws/aws-sdk-go/pull/1276
client.dynamodbconn.Handlers.Retry.PushBack(func(r *request.Request) {
if r.Operation.Name != "PutItem" && r.Operation.Name != "UpdateItem" && r.Operation.Name != "DeleteItem" {
return
}
if isAWSErr(r.Error, dynamodb.ErrCodeLimitExceededException, "Subscriber limit exceeded:") {
r.Retryable = aws.Bool(true)
}
})

client.kinesisconn.Handlers.Retry.PushBack(func(r *request.Request) {
if r.Operation.Name == "CreateStream" {
if isAWSErr(r.Error, kinesis.ErrCodeLimitExceededException, "simultaneously be in CREATING or DELETING") {
r.Retryable = aws.Bool(true)
}
}
if r.Operation.Name == "CreateStream" || r.Operation.Name == "DeleteStream" {
if isAWSErr(r.Error, kinesis.ErrCodeLimitExceededException, "Rate exceeded for stream") {
r.Retryable = aws.Bool(true)
}
}
})

return &client, nil
}

Expand Down
4 changes: 2 additions & 2 deletions aws/core_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAWSVPC_coreMismatchedDiffs(t *testing.T) {
func TestAccAWSVpc_coreMismatchedDiffs(t *testing.T) {
var vpc ec2.Vpc

resource.Test(t, resource.TestCase{
Expand All @@ -32,7 +32,7 @@ const testMatchedDiffs = `resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
tags {
Name = "Repro GH-4965"
Name = "terraform-testacc-repro-GH-4965"
}
lifecycle {
Expand Down
6 changes: 3 additions & 3 deletions aws/data_source_aws_acm_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const ACMCertificateRe = `^arn:[^:]+:acm:[^:]+:[^:]+:certificate/.+$`

func TestAccAwsAcmCertificateDataSource_singleIssued(t *testing.T) {
func TestAccAWSAcmCertificateDataSource_singleIssued(t *testing.T) {
if os.Getenv("ACM_CERTIFICATE_ROOT_DOMAIN") == "" {
t.Skip("Environment variable ACM_CERTIFICATE_ROOT_DOMAIN is not set")
}
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestAccAwsAcmCertificateDataSource_singleIssued(t *testing.T) {
})
}

func TestAccAwsAcmCertificateDataSource_multipleIssued(t *testing.T) {
func TestAccAWSAcmCertificateDataSource_multipleIssued(t *testing.T) {
if os.Getenv("ACM_CERTIFICATE_ROOT_DOMAIN") == "" {
t.Skip("Environment variable ACM_CERTIFICATE_ROOT_DOMAIN is not set")
}
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestAccAwsAcmCertificateDataSource_multipleIssued(t *testing.T) {
})
}

func TestAccAwsAcmCertificateDataSource_noMatchReturnsError(t *testing.T) {
func TestAccAWSAcmCertificateDataSource_noMatchReturnsError(t *testing.T) {
if os.Getenv("ACM_CERTIFICATE_ROOT_DOMAIN") == "" {
t.Skip("Environment variable ACM_CERTIFICATE_ROOT_DOMAIN is not set")
}
Expand Down
14 changes: 2 additions & 12 deletions aws/data_source_aws_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
)

func dataSourceAwsAmi() *schema.Resource {
Expand All @@ -27,7 +28,7 @@ func dataSourceAwsAmi() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validateNameRegex,
ValidateFunc: validation.ValidateRegexp,
},
"most_recent": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -432,14 +433,3 @@ func amiProductCodesHash(v interface{}) int {
buf.WriteString(fmt.Sprintf("%s-", m["product_code_type"].(string)))
return hashcode.String(buf.String())
}

func validateNameRegex(v interface{}, k string) (ws []string, errors []error) {
value := v.(string)

if _, err := regexp.Compile(value); err != nil {
errors = append(errors, fmt.Errorf(
"%q contains an invalid regular expression: %s",
k, err))
}
return
}
3 changes: 2 additions & 1 deletion aws/data_source_aws_ami_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
)

func dataSourceAwsAmiIds() *schema.Resource {
Expand All @@ -26,7 +27,7 @@ func dataSourceAwsAmiIds() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validateNameRegex,
ValidateFunc: validation.ValidateRegexp,
},
"owners": {
Type: schema.TypeList,
Expand Down
51 changes: 0 additions & 51 deletions aws/data_source_aws_ami_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,57 +174,6 @@ func TestAccAWSAmiDataSource_localNameFilter(t *testing.T) {
})
}

func TestResourceValidateNameRegex(t *testing.T) {
type testCases struct {
Value string
ErrCount int
}

invalidCases := []testCases{
{
Value: `\`,
ErrCount: 1,
},
{
Value: `**`,
ErrCount: 1,
},
{
Value: `(.+`,
ErrCount: 1,
},
}

for _, tc := range invalidCases {
_, errors := validateNameRegex(tc.Value, "name_regex")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected %q to trigger a validation error.", tc.Value)
}
}

validCases := []testCases{
{
Value: `\/`,
ErrCount: 0,
},
{
Value: `.*`,
ErrCount: 0,
},
{
Value: `\b(?:\d{1,3}\.){3}\d{1,3}\b`,
ErrCount: 0,
},
}

for _, tc := range validCases {
_, errors := validateNameRegex(tc.Value, "name_regex")
if len(errors) != tc.ErrCount {
t.Fatalf("Expected %q not to trigger a validation error.", tc.Value)
}
}
}

func testAccCheckAwsAmiDataSourceDestroy(s *terraform.State) error {
return nil
}
Expand Down
Loading

0 comments on commit ec7dacf

Please sign in to comment.