Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Guimove committed Sep 20, 2018
2 parents 2d41b1a + 39dcb45 commit dbb2e31
Show file tree
Hide file tree
Showing 584 changed files with 17,706 additions and 8,489 deletions.
26 changes: 26 additions & 0 deletions .gometalinter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"Deadline": "5m",
"Enable": [
"errcheck",
"gofmt",
"ineffassign",
"interfacer",
"misspell",
"structcheck",
"unconvert",
"varcheck",
"vet"
],
"EnableGC": true,
"Linters": {
"errcheck": {
"Command": "errcheck -abspath {not_tests=-ignoretests} -ignore github.com/hashicorp/terraform/helper/schema:ForceNew|Set -ignore io:Close"
}
},
"Sort": [
"path",
"line"
],
"Vendor": true,
"WarnUnmatchedDirective": true
}
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ install:
# packages that live there.
# See: https://github.com/golang/go/issues/12933
- bash scripts/gogetcookie.sh
- go get github.com/kardianos/govendor
- make tools

script:
- make lint
- make test
- make vendor-status
- make vet
- make website-lint
- make website-test

branches:
Expand Down
69 changes: 66 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,75 @@
## 1.35.0 (Unreleased)
## 1.38.0 (Unreleased)

ENHANCEMENTS:

* resource/aws_iam_role: Allow empty string (`""`) value for `permissions_boundary` argument [GH-5740]
* data-source/aws_autoscaling_groups: Add `arns` attribute [GH-5766]
* resource/aws_codebuild_project: Add `secondary_artifacts` and `secondary_sources` arguments [GH-5939]
* resource/aws_launch_template: Support `credit_specification` configuration of T3 instance types [GH-5922]

## 1.37.0 (September 19, 2018)

FEATURES:

* **New Resource:** `aws_dx_bgp_peer` ([#5886](https://github.com/terraform-providers/terraform-provider-aws/issues/5886))

ENHANCEMENTS:

* data-source/aws_ami_ids: Add `sort_ascending` argument ([#5912](https://github.com/terraform-providers/terraform-provider-aws/issues/5912))
* resource/aws_iam_role_policy_attachment: Support resource import ([#5910](https://github.com/terraform-providers/terraform-provider-aws/issues/5910))
* resource/aws_s3_bucket_inventory: Allow SSE-S3 encryption ([#5870](https://github.com/terraform-providers/terraform-provider-aws/issues/5870))
* resource/aws_security_group: Add `prefix_list_ids` argument for `ingress` rules ([#5916](https://github.com/terraform-providers/terraform-provider-aws/issues/5916))

BUG FIXES:

* resource/aws_config_config_rule: Prevent panic when specifying empty `scope` ([#5852](https://github.com/terraform-providers/terraform-provider-aws/issues/5852))
* resource/aws_iam_policy: Ensure `description` is properly read into Terraform state during resource creation ([#5884](https://github.com/terraform-providers/terraform-provider-aws/issues/5884))
* resource/aws_instance: Properly handle `credit_specifications` with T3 instance types ([#5805](https://github.com/terraform-providers/terraform-provider-aws/issues/5805))
* resource/aws_launch_template: Fix handling of `network_interface` `ipv6_addresses` ([#5883](https://github.com/terraform-providers/terraform-provider-aws/issues/5883))
* resource/aws_redshift_cluster: Properly disable logging when using `logging` nested argument ([#5895](https://github.com/terraform-providers/terraform-provider-aws/issues/5895))
* resource/aws_s3_bucket: Prevent panics with various API read failures ([#5842](https://github.com/terraform-providers/terraform-provider-aws/issues/5842))
* resource/aws_s3_bucket: Prevent `NoSuchBucket` error on deletion ([#5842](https://github.com/terraform-providers/terraform-provider-aws/issues/5842))
* resource/aws_wafregional_byte_match_set: Properly read `byte_match_tuple` into Terraform state ([#5902](https://github.com/terraform-providers/terraform-provider-aws/issues/5902))

## 1.36.0 (September 13, 2018)

FEATURES:

* **New Resource:** `aws_cloudfront_public_key` ([#5737](https://github.com/terraform-providers/terraform-provider-aws/issues/5737))

ENHANCEMENTS:

* data-source/aws_db_instance: Add `enabled_cloudwatch_logs_exports` attribute ([#5801](https://github.com/terraform-providers/terraform-provider-aws/issues/5801))
* resource/aws_api_gateway_stage: Add `xray_tracing_enabled` argument ([#5817](https://github.com/terraform-providers/terraform-provider-aws/issues/5817))
* resource/aws_cloudfront_distribution: Add `lambda_function_association` `include_body` argument ([#5681](https://github.com/terraform-providers/terraform-provider-aws/issues/5681))
* resource/aws_db_instance: Add `domain` and `domain_iam_role_name` arguments (support for domain joining RDS instances) ([#5378](https://github.com/terraform-providers/terraform-provider-aws/issues/5378))
* resource/aws_ecs_task_definition: Suppress `container_definition` differences for equivalent port and host mappings ([#5833](https://github.com/terraform-providers/terraform-provider-aws/issues/5833))
* resource/aws_ecs_task_definition: Add docker volume configuration ([#5727](https://github.com/terraform-providers/terraform-provider-aws/issues/5727))
* resource/aws_iam_user: Allow empty string (`""`) value for `permissions_boundary` argument ([#5859](https://github.com/terraform-providers/terraform-provider-aws/issues/5859))
* resource/aws_iot_topic_rule: Add `firehose` `seperator` argument ([#5734](https://github.com/terraform-providers/terraform-provider-aws/issues/5734))
* resource/aws_launch_template: Allow `network_interface` `ipv4_address_count` configuration ([#5830](https://github.com/terraform-providers/terraform-provider-aws/issues/5830))
* resource/aws_ssm_document: Add support for `Session` `document_type` ([#5850](https://github.com/terraform-providers/terraform-provider-aws/issues/5850))

BUG FIXES:

* resource/aws_iam_policy: Ensure `description` is available as an attribute when empty ([#5815](https://github.com/terraform-providers/terraform-provider-aws/issues/5815))
* resource/aws_iam_user: Remove extraneous `DeleteUserPermissionsBoundary` API call during deletion ([#5857](https://github.com/terraform-providers/terraform-provider-aws/issues/5857))
* resource/aws_lambda_function: Retry on `InvalidParameterValueException` errors relating to KMS-backed environment variables ([#5849](https://github.com/terraform-providers/terraform-provider-aws/issues/5849))
* resource/aws_launch_template: Ensure `ebs_optimized` argument accepts "unspecified" value ([#5627](https://github.com/terraform-providers/terraform-provider-aws/issues/5627))

## 1.35.0 (September 06, 2018)

ENHANCEMENTS:

* data-source/aws_eks_cluster: Add `platform_version` attribute ([#5797](https://github.com/terraform-providers/terraform-provider-aws/issues/5797))
* resource/aws_eks_cluster: Add `platform_version` attribute ([#5797](https://github.com/terraform-providers/terraform-provider-aws/issues/5797))
* resource/aws_lambda_function: Allow empty lists for `vpc_config` `security_group_ids` and `subnet_ids` arguments to unconfigure VPC ([#1341](https://github.com/terraform-providers/terraform-provider-aws/issues/1341))
* resource/aws_iam_role: Allow empty string (`""`) value for `permissions_boundary` argument ([#5740](https://github.com/terraform-providers/terraform-provider-aws/issues/5740))

BUG FIXES:

* resource/aws_ecr_repository: Use `RepositoryUri` instead of our building our own URI for the `repository_url` attribute (AWS China fix) [GH-5748]
* resource/aws_ecr_repository: Use `RepositoryUri` instead of our building our own URI for the `repository_url` attribute (AWS China fix) ([#5748](https://github.com/terraform-providers/terraform-provider-aws/issues/5748))
* resource/aws_lambda_function: Properly handle `vpc_config` removal ([#5798](https://github.com/terraform-providers/terraform-provider-aws/issues/5798))
* resource/aws_redshift_cluster: Properly force new resource when updating `availability_zone` argument ([#5758](https://github.com/terraform-providers/terraform-provider-aws/issues/5758))

## 1.34.0 (August 30, 2018)

Expand Down
29 changes: 16 additions & 13 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@ test: fmtcheck
testacc: fmtcheck
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi

fmt:
gofmt -w $(GOFMT_FILES)
@echo "==> Fixing source code with gofmt..."
gofmt -s -w ./$(PKG_NAME)

# Currently required by tf-deploy compile
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
lint:
@echo "==> Checking source code against linters..."
@gometalinter ./$(PKG_NAME)

tools:
go get -u github.com/kardianos/govendor
go get -u github.com/alecthomas/gometalinter
gometalinter --install

vendor-status:
@govendor status
Expand All @@ -55,12 +54,16 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

website-lint:
@echo "==> Checking website against linters..."
@misspell -error -source=text website/

website-test:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build sweep test testacc vet fmt fmtcheck errcheck vendor-status test-compile website website-test
.PHONY: build sweep test testacc fmt fmtcheck lint tools vendor-status test-compile website website-lint website-test

8 changes: 6 additions & 2 deletions aws/cloudfront_distribution_configuration_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,10 @@ func expandDefaultCacheBehavior(m map[string]interface{}) *cloudfront.DefaultCac
}

func flattenDefaultCacheBehavior(dcb *cloudfront.DefaultCacheBehavior) *schema.Set {
m := make(map[string]interface{})
var cb cloudfront.CacheBehavior

simpleCopyStruct(dcb, &cb)
m = flattenCacheBehaviorDeprecated(&cb)
m := flattenCacheBehaviorDeprecated(&cb)
return schema.NewSet(defaultCacheBehaviorHash, []interface{}{m})
}

Expand Down Expand Up @@ -526,6 +525,7 @@ func lambdaFunctionAssociationHash(v interface{}) int {
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["event_type"].(string)))
buf.WriteString(fmt.Sprintf("%s", m["lambda_arn"].(string)))
buf.WriteString(fmt.Sprintf("%t", m["include_body"].(bool)))
return hashcode.String(buf.String())
}

Expand Down Expand Up @@ -554,6 +554,9 @@ func expandLambdaFunctionAssociation(lf map[string]interface{}) *cloudfront.Lamb
if v, ok := lf["lambda_arn"]; ok {
lfa.LambdaFunctionARN = aws.String(v.(string))
}
if v, ok := lf["include_body"]; ok {
lfa.IncludeBody = aws.Bool(v.(bool))
}
return &lfa
}

Expand All @@ -570,6 +573,7 @@ func flattenLambdaFunctionAssociation(lfa *cloudfront.LambdaFunctionAssociation)
if lfa != nil {
m["event_type"] = *lfa.EventType
m["lambda_arn"] = *lfa.LambdaFunctionARN
m["include_body"] = *lfa.IncludeBody
}
return m
}
Expand Down
10 changes: 6 additions & 4 deletions aws/cloudfront_distribution_configuration_structure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ func trustedSignersConf() []interface{} {
func lambdaFunctionAssociationsConf() *schema.Set {
x := []interface{}{
map[string]interface{}{
"event_type": "viewer-request",
"lambda_arn": "arn:aws:lambda:us-east-1:999999999:function1:alias",
"event_type": "viewer-request",
"lambda_arn": "arn:aws:lambda:us-east-1:999999999:function1:alias",
"include_body": true,
},
map[string]interface{}{
"event_type": "origin-response",
"lambda_arn": "arn:aws:lambda:us-east-1:999999999:function2:alias",
"event_type": "origin-response",
"lambda_arn": "arn:aws:lambda:us-east-1:999999999:function2:alias",
"include_body": true,
},
}

Expand Down
15 changes: 12 additions & 3 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ import (
"github.com/aws/aws-sdk-go/service/waf"
"github.com/aws/aws-sdk-go/service/wafregional"
"github.com/davecgh/go-spew/spew"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/terraform/helper/logging"
"github.com/hashicorp/terraform/terraform"
Expand Down Expand Up @@ -347,7 +346,7 @@ func (c *Config) Client() (interface{}, error) {
Please see https://terraform.io/docs/providers/aws/index.html for more information on
providing credentials for the AWS Provider`)
}
return nil, errwrap.Wrapf("Error creating AWS session: {{err}}", err)
return nil, fmt.Errorf("Error creating AWS session: %s", err)
}

sess.Handlers.Build.PushBackNamed(addTerraformVersionToUserAgent)
Expand Down Expand Up @@ -448,10 +447,20 @@ func (c *Config) Client() (interface{}, error) {
var err error
client.accountid, client.partition, err = GetAccountIDAndPartition(client.iamconn, client.stsconn, cp.ProviderName)
if err != nil {
return nil, fmt.Errorf("Failed getting account information via all available methods. Errors: %s", err)
// DEPRECATED: Next major version of the provider should return the error instead of logging
// if skip_request_account_id is not enabled.
log.Printf("[WARN] %s", fmt.Sprintf(
"AWS account ID not previously found and failed retrieving via all available methods. "+
"This will return an error in the next major version of the AWS provider. "+
"See https://www.terraform.io/docs/providers/aws/index.html#skip_requesting_account_id for workaround and implications. "+
"Errors: %s", err))
}
}

if client.accountid == "" {
log.Printf("[WARN] AWS account ID not found for provider. See https://www.terraform.io/docs/providers/aws/index.html#skip_requesting_account_id for implications.")
}

authErr := c.ValidateAccountId(client.accountid)
if authErr != nil {
return nil, authErr
Expand Down
2 changes: 1 addition & 1 deletion aws/data_source_aws_ami.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func dataSourceAwsAmiRead(d *schema.ResourceData, meta interface{}) error {

// Returns the most recent AMI out of a slice of images.
func mostRecentAmi(images []*ec2.Image) *ec2.Image {
return sortImages(images)[0]
return sortImages(images, false)[0]
}

// populate the numerous fields that the image description returns.
Expand Down
8 changes: 7 additions & 1 deletion aws/data_source_aws_ami_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func dataSourceAwsAmiIds() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"sort_ascending": {
Type: schema.TypeBool,
Default: false,
Optional: true,
},
},
}
}
Expand All @@ -52,6 +57,7 @@ func dataSourceAwsAmiIdsRead(d *schema.ResourceData, meta interface{}) error {
filters, filtersOk := d.GetOk("filter")
nameRegex, nameRegexOk := d.GetOk("name_regex")
owners, ownersOk := d.GetOk("owners")
sortAscending := d.Get("sort_ascending").(bool)

if executableUsersOk == false && filtersOk == false && nameRegexOk == false && ownersOk == false {
return fmt.Errorf("One of executable_users, filters, name_regex, or owners must be assigned")
Expand Down Expand Up @@ -123,7 +129,7 @@ func dataSourceAwsAmiIdsRead(d *schema.ResourceData, meta interface{}) error {
filteredImages = resp.Images[:]
}

for _, image := range sortImages(filteredImages) {
for _, image := range sortImages(filteredImages, sortAscending) {
imageIds = append(imageIds, *image.ImageId)
}

Expand Down
Loading

0 comments on commit dbb2e31

Please sign in to comment.