Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…form-provider-aws into es-require-https
  • Loading branch information
barrytam20 committed Oct 9, 2019
2 parents c22b34d + 1647a5b commit 071671b
Show file tree
Hide file tree
Showing 221 changed files with 8,145 additions and 3,606 deletions.
10 changes: 7 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
issues:
exclude-rules:
# Exclude issues bypassing staticcheck.conf
- linters:
- staticcheck
text: "SA1019:"
max-per-linter: 0
max-same-issues: 0

Expand All @@ -11,8 +16,7 @@ linters:
- gosimple
- ineffassign
- misspell
# Run separately for TravisCI memory issues
# - staticcheck
- staticcheck
- structcheck
- unconvert
- unused
Expand All @@ -24,5 +28,5 @@ linters-settings:
ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,fmt:.*,io:Close

run:
deadline: 5m
modules-download-mode: vendor
timeout: 10m
4 changes: 2 additions & 2 deletions .hashibot.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ behavior "deprecated_import_commenter" "hashicorp_terraform" {
message = <<-EOF
Hello, and thank you for your contribution!
This project recently migrated to the [standalone Terraform Plugin SDK](https://www.terraform.io/docs/extend/plugin-sdk.html). While this will help speed up future feature requests and bug fixes with Terraform AWS Provider's interface with Terraform itself, it also has the unfortunate consequence of requiring some minor changes to pull requests created before the migration.
This project recently migrated to the [standalone Terraform Plugin SDK](https://www.terraform.io/docs/extend/plugin-sdk.html). While the migration helps speed up future feature requests and bug fixes to the Terraform AWS Provider's interface with Terraform, it has the unfortunate consequence of requiring minor changes to pull requests created using the old SDK.
This pull request appears to include the Go import path `${var.import_path}`, which was from the older SDK. The newer SDK uses import paths beginning with `github.com/hashicorp/terraform-plugin-sdk/`.
To resolve this situation without losing any existing work, you may be able to Git rebase your branch against the current master branch (example below), then replacing any remaining old import paths with the newer ones.
To resolve this situation without losing any existing work, you may be able to Git rebase your branch against the current master branch (example below); replacing any remaining old import paths with the newer ones.
```console
$ git fetch --all
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## 2.32.0 (Unreleased)

NOTES:

* provider: The underlying Terraform codebase dependency for the provider SDK and acceptance testing framework has been migrated from `github.com/hashicorp/terraform` to `github.com/hashicorp/terraform-plugin-sdk`. They are functionality equivalent and this should only impact codebase development to switch imports. For more information see the [Terraform Plugin SDK page in the Extending Terraform documentation](https://www.terraform.io/docs/extend/plugin-sdk.html). [GH-10367]

BUG FIXES:

* provider: Fix session handling to correctly validate and use assume_role credentials [GH-10379]
* resource/aws_s3_bucket: Prevent infinite deletion recursion with `force_destroy` argument and object keys with empty "directory" prefixes present since version 2.29.0 [GH-10388]

## 2.31.0 (October 03, 2019)

NOTES:
Expand Down
1 change: 0 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ websitefmtcheck:

lint:
@echo "==> Checking source code against linters..."
@golangci-lint run --no-config --deadline 5m --disable-all --enable staticcheck --exclude SA1019 --max-issues-per-linter 0 --max-same-issues 0 ./$(PKG_NAME)/...
@golangci-lint run ./$(PKG_NAME)/...
@tfproviderlint \
-c 1 \
Expand Down
13 changes: 12 additions & 1 deletion aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ type AWSClient struct {
resourcegroupsconn *resourcegroups.ResourceGroups
route53resolverconn *route53resolver.Route53Resolver
s3conn *s3.S3
s3connUriCleaningDisabled *s3.S3
s3controlconn *s3control.S3Control
sagemakerconn *sagemaker.SageMaker
scconn *servicecatalog.ServiceCatalog
Expand Down Expand Up @@ -470,7 +471,6 @@ func (c *Config) Client() (interface{}, error) {
region: c.Region,
resourcegroupsconn: resourcegroups.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["resourcegroups"])})),
route53resolverconn: route53resolver.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["route53resolver"])})),
s3conn: s3.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["s3"]), S3ForcePathStyle: aws.Bool(c.S3ForcePathStyle)})),
s3controlconn: s3control.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["s3control"])})),
sagemakerconn: sagemaker.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["sagemaker"])})),
scconn: servicecatalog.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["servicecatalog"])})),
Expand Down Expand Up @@ -508,6 +508,17 @@ func (c *Config) Client() (interface{}, error) {
Endpoint: aws.String(c.Endpoints["shield"]),
}

// Services that require multiple client configurations
s3Config := &aws.Config{
Endpoint: aws.String(c.Endpoints["s3"]),
S3ForcePathStyle: aws.Bool(c.S3ForcePathStyle),
}

client.s3conn = s3.New(sess.Copy(s3Config))

s3Config.DisableRestProtocolURICleaning = aws.Bool(true)
client.s3connUriCleaningDisabled = s3.New(sess.Copy(s3Config))

// Handle deprecated endpoint configurations
if c.Endpoints["kinesis_analytics"] != "" {
client.kinesisanalyticsconn = kinesisanalytics.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["kinesis_analytics"])}))
Expand Down
22 changes: 7 additions & 15 deletions aws/data_source_aws_elasticsearch_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ provider "aws" {
locals {
random_name = "test-es-%d"
}
data "aws_region" "current" {}
data "aws_caller_identity" "current" {}
resource "aws_elasticsearch_domain" "test" {
domain_name = "${local.random_name}"
elasticsearch_version = "1.5"
access_policies = <<POLICY
{
"Version": "2012-10-17",
Expand Down Expand Up @@ -135,9 +135,9 @@ func testAccAWSElasticsearchDomainConfigAdvancedWithDataSource(rInt int) string
provider "aws" {
region = "us-east-1"
}
data "aws_region" "current" {}
data "aws_caller_identity" "current" {}
locals {
Expand Down Expand Up @@ -200,14 +200,10 @@ resource "aws_security_group_rule" "test" {
security_group_id = "${aws_security_group.test.id}"
}
resource "aws_iam_service_linked_role" "test" {
aws_service_name = "es.amazonaws.com"
}
resource "aws_elasticsearch_domain" "test" {
domain_name = "${local.random_name}"
elasticsearch_version = "1.5"
access_policies = <<POLICY
{
"Version": "2012-10-17",
Expand Down Expand Up @@ -256,10 +252,6 @@ POLICY
tags = {
Domain = "TestDomain"
}
depends_on = [
"aws_iam_service_linked_role.test",
]
}
data "aws_elasticsearch_domain" "test" {
Expand Down
59 changes: 51 additions & 8 deletions aws/internal/keyvaluetags/generators/updatetags/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var serviceNames = []string{
"directoryservice",
"docdb",
"dynamodb",
"ec2",
"ecr",
"ecs",
"efs",
Expand Down Expand Up @@ -101,14 +102,16 @@ func main() {
ServiceNames: serviceNames,
}
templateFuncMap := template.FuncMap{
"ClientType": keyvaluetags.ServiceClientType,
"TagFunction": ServiceTagFunction,
"TagInputIdentifierField": ServiceTagInputIdentifierField,
"TagInputResourceTypeField": ServiceTagInputResourceTypeField,
"TagInputTagsField": ServiceTagInputTagsField,
"Title": strings.Title,
"UntagFunction": ServiceUntagFunction,
"UntagInputTagsField": ServiceUntagInputTagsField,
"ClientType": keyvaluetags.ServiceClientType,
"TagFunction": ServiceTagFunction,
"TagInputIdentifierField": ServiceTagInputIdentifierField,
"TagInputIdentifierRequiresSlice": ServiceTagInputIdentifierRequiresSlice,
"TagInputResourceTypeField": ServiceTagInputResourceTypeField,
"TagInputTagsField": ServiceTagInputTagsField,
"Title": strings.Title,
"UntagFunction": ServiceUntagFunction,
"UntagInputRequiresTagType": ServiceUntagInputRequiresTagType,
"UntagInputTagsField": ServiceUntagInputTagsField,
}

tmpl, err := template.New("updatetags").Funcs(templateFuncMap).Parse(templateBody)
Expand Down Expand Up @@ -169,11 +172,19 @@ func {{ . | Title }}UpdateTags(conn {{ . | ClientType }}, identifier string{{ if
if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 {
input := &{{ . }}.{{ . | UntagFunction }}Input{
{{- if . | TagInputIdentifierRequiresSlice }}
{{ . | TagInputIdentifierField }}: aws.StringSlice([]string{identifier}),
{{- else }}
{{ . | TagInputIdentifierField }}: aws.String(identifier),
{{- end }}
{{- if . | TagInputResourceTypeField }}
{{ . | TagInputResourceTypeField }}: aws.String(resourceType),
{{- end }}
{{- if . | UntagInputRequiresTagType }}
{{ . | UntagInputTagsField }}: removedTags.IgnoreAws().{{ . | Title }}Tags(),
{{- else }}
{{ . | UntagInputTagsField }}: aws.StringSlice(removedTags.Keys()),
{{- end }}
}
_, err := conn.{{ . | UntagFunction }}(input)
Expand All @@ -185,7 +196,11 @@ func {{ . | Title }}UpdateTags(conn {{ . | ClientType }}, identifier string{{ if
if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 {
input := &{{ . }}.{{ . | TagFunction }}Input{
{{- if . | TagInputIdentifierRequiresSlice }}
{{ . | TagInputIdentifierField }}: aws.StringSlice([]string{identifier}),
{{- else }}
{{ . | TagInputIdentifierField }}: aws.String(identifier),
{{- end }}
{{- if . | TagInputResourceTypeField }}
{{ . | TagInputResourceTypeField }}: aws.String(resourceType),
{{- end }}
Expand Down Expand Up @@ -215,6 +230,8 @@ func ServiceTagFunction(serviceName string) string {
return "AddTagsToResource"
case "docdb":
return "AddTagsToResource"
case "ec2":
return "CreateTags"
case "efs":
return "CreateTags"
case "elasticache":
Expand Down Expand Up @@ -269,6 +286,8 @@ func ServiceTagInputIdentifierField(serviceName string) string {
return "ResourceId"
case "docdb":
return "ResourceName"
case "ec2":
return "Resources"
case "efs":
return "FileSystemId"
case "elasticache":
Expand Down Expand Up @@ -322,6 +341,16 @@ func ServiceTagInputIdentifierField(serviceName string) string {
}
}

// ServiceTagInputIdentifierRequiresSlice determines if the service tagging resource field requires a slice.
func ServiceTagInputIdentifierRequiresSlice(serviceName string) string {
switch serviceName {
case "ec2":
return "yes"
default:
return ""
}
}

// ServiceTagInputTagsField determines the service tagging tags field.
func ServiceTagInputTagsField(serviceName string) string {
switch serviceName {
Expand Down Expand Up @@ -357,6 +386,8 @@ func ServiceUntagFunction(serviceName string) string {
return "RemoveTagsFromResource"
case "docdb":
return "RemoveTagsFromResource"
case "ec2":
return "DeleteTags"
case "efs":
return "DeleteTags"
case "elasticache":
Expand Down Expand Up @@ -390,6 +421,16 @@ func ServiceUntagFunction(serviceName string) string {
}
}

// ServiceUntagInputRequiresTagType determines if the service untagging requires full Tag type.
func ServiceUntagInputRequiresTagType(serviceName string) string {
switch serviceName {
case "ec2":
return "yes"
default:
return ""
}
}

// ServiceUntagInputTagsField determines the service untagging tags field.
func ServiceUntagInputTagsField(serviceName string) string {
switch serviceName {
Expand All @@ -399,6 +440,8 @@ func ServiceUntagInputTagsField(serviceName string) string {
return "TagKeyList"
case "datasync":
return "Keys"
case "ec2":
return "Tags"
case "glue":
return "TagsToRemove"
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/aws/aws-sdk-go/service/directoryservice"
"github.com/aws/aws-sdk-go/service/docdb"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ecr"
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/aws/aws-sdk-go/service/efs"
Expand Down Expand Up @@ -147,6 +148,8 @@ func ServiceClientType(serviceName string) string {
funcType = reflect.TypeOf(docdb.New)
case "dynamodb":
funcType = reflect.TypeOf(dynamodb.New)
case "ec2":
funcType = reflect.TypeOf(ec2.New)
case "ecr":
funcType = reflect.TypeOf(ecr.New)
case "ecs":
Expand Down
37 changes: 37 additions & 0 deletions aws/internal/keyvaluetags/update_tags_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 071671b

Please sign in to comment.