Skip to content

Commit

Permalink
Merge tag 'v2.3.0' into master2-with-emr-fleet
Browse files Browse the repository at this point in the history
  • Loading branch information
jocgir committed Apr 24, 2019
2 parents 8beb502 + 29bbaaa commit 4ee8af3
Show file tree
Hide file tree
Showing 1,102 changed files with 246,583 additions and 2,261 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ linters:
- gosimple
- ineffassign
- misspell
- staticcheck
- structcheck
- unconvert
- unused
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist: trusty
dist: xenial
sudo: required
services:
- docker
Expand Down Expand Up @@ -37,7 +37,7 @@ script:
matrix:
fast_finish: true
allow_failures:
- go: tip
- go: tip

after_success:
- if [ ${TRAVIS_TAG::1} = v ];
Expand Down
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
## 2.3.0 (March 21, 2019)

BREAKING CHANGES:

* service/appmesh: Changes to support AppMesh General Availability (GA) release. The AppMesh resources were added while the API was under Public Preview and the GA release earlier this month introduced breaking changes which prevented further AWS Go SDK updates. This is a very atypical situation for the Terraform AWS Provider as most AWS API and SDK changes are additive. To prevent this situation in the future we may introduce separate Terraform AWS Provider(s) specifically for Public Preview or Beta APIs. If or when this occurs, it will be separately announced. The maintainers will continue following Terraform Provider compatibility promises outlined on the [HashiCorp Blog](https://www.hashicorp.com/blog/hashicorp-terraform-provider-versioning) and [Extending Terraform documentation](https://www.terraform.io/docs/extend/best-practices/versioning.html) as best as possible except other existing Public Preview resources. ([#7659](https://github.com/terraform-providers/terraform-provider-aws/issues/7659))
* resource/aws_appmesh_virtual_node: Replace `backends` configuration block(s) with `backend` configuration blocks ([#7858](https://github.com/terraform-providers/terraform-provider-aws/issues/7858))
* resource/aws_appmesh_virtual_node: Replace `service_discovery` configuration block `service_name` argument with `service_discovery` configuration block `dns` configuration block ([#7858](https://github.com/terraform-providers/terraform-provider-aws/issues/7858))
* resource/aws_appmesh_virtual_router: Remove `spec` configuration block `service_names` argument ([#7858](https://github.com/terraform-providers/terraform-provider-aws/issues/7858))

FEATURES:

* **New Data Source:** `aws_transfer_server` ([#7977](https://github.com/terraform-providers/terraform-provider-aws/issues/7977))
* **New Resource:** `aws_appmesh_virtual_service` ([#7858](https://github.com/terraform-providers/terraform-provider-aws/issues/7858))
* **New Resource:** `aws_backup_plan` ([#7350](https://github.com/terraform-providers/terraform-provider-aws/issues/7350))
* **New Resource:** `aws_cloudformation_stack_set` ([#8020](https://github.com/terraform-providers/terraform-provider-aws/issues/8020))
* **New Resource:** `aws_cloudformation_stack_set_instance` ([#8020](https://github.com/terraform-providers/terraform-provider-aws/issues/8020))

ENHANCEMENTS:

* data-source/aws_eks_cluster: Add `vpc_config` configuration block `endpoint_private_access` and `endpoint_public_access` attributes ([#8024](https://github.com/terraform-providers/terraform-provider-aws/issues/8024))
* data-source/aws_instance: Add `get_user_data` argument and `user_data_base64` attribute ([#8001](https://github.com/terraform-providers/terraform-provider-aws/issues/8001))
* provider: Support custom endpoint for `ses` ([#7986](https://github.com/terraform-providers/terraform-provider-aws/issues/7986))
* provider: Support custom endpoints for `firehose` and `redshift` ([#8007](https://github.com/terraform-providers/terraform-provider-aws/issues/8007))
* resource/aws_api_gateway_deployment: Allow `stage_name` argument to be optional ([#6459](https://github.com/terraform-providers/terraform-provider-aws/issues/6459))
* resource/aws_appautoscaling_policy: Support resource import ([#8032](https://github.com/terraform-providers/terraform-provider-aws/issues/8032))
* resource/aws_appautoscaling_target: Support resource import ([#8032](https://github.com/terraform-providers/terraform-provider-aws/issues/8032))
* resource/aws_appmesh_route: Support resource import ([#7858](https://github.com/terraform-providers/terraform-provider-aws/issues/7858))
* resource/aws_appmesh_virtual_node: Support resource import ([#7858](https://github.com/terraform-providers/terraform-provider-aws/issues/7858))
* resource/aws_appmesh_virtual_router: Support resource import ([#7858](https://github.com/terraform-providers/terraform-provider-aws/issues/7858))
* resource/aws_appmesh_virtual_router: Add `spec` configuration block `listener` configuration block ([#7858](https://github.com/terraform-providers/terraform-provider-aws/issues/7858))
* resource/aws_cloudfront_distribution: Add `origin_group` configuration block (support Origin Groups and failover) ([#7202](https://github.com/terraform-providers/terraform-provider-aws/issues/7202))
* resource/aws_codebuild_project: Add `project_environment` configuration block `image_pull_credentials_type` argument (support cross-account images) ([#7458](https://github.com/terraform-providers/terraform-provider-aws/issues/7458))
* resource/aws_ecr_repository_policy: Support resource import ([#7974](https://github.com/terraform-providers/terraform-provider-aws/issues/7974))
* resource/aws_eks_cluster: Add `vpc_config` configuration block `endpoint_private_access` and `endpoint_public_access` arguments (support disabling public access) ([#8024](https://github.com/terraform-providers/terraform-provider-aws/issues/8024))
* resource/aws_iam_access_key: Support `status` updates (support disabling/enabling access keys) ([#7961](https://github.com/terraform-providers/terraform-provider-aws/issues/7961))
* resource/aws_kinesis_analytics_application: Support resource import ([#8027](https://github.com/terraform-providers/terraform-provider-aws/issues/8027))
* resource/aws_media_package_channel: Add `tags` argument ([#7984](https://github.com/terraform-providers/terraform-provider-aws/issues/7984))
* resource/aws_route53_zone_association: Support resource import ([#7966](https://github.com/terraform-providers/terraform-provider-aws/issues/7966))
* resource/aws_s3_bucket_inventory: Support plan-time validation of `optional_fields` values `ObjectLockRetainUntilDate`, `ObjectLockMode` and `ObjectLockLegalHoldStatus` ([#7952](https://github.com/terraform-providers/terraform-provider-aws/issues/7952))
* resource/aws_ssm_association: Add `compliance_severity` argument ([#7852](https://github.com/terraform-providers/terraform-provider-aws/issues/7852))
* resource/aws_ssm_association: Add `max_concurrency` and `max_errors` arguments ([#7970](https://github.com/terraform-providers/terraform-provider-aws/issues/7970))

BUG FIXES:

* resource/aws_appautoscaling_policy: Recreate resource for `resource_id` updates ([#7982](https://github.com/terraform-providers/terraform-provider-aws/issues/7982))
* resource/aws_appautoscaling_policy: Ignore `ObjectNotFoundException` on deletion ([#7982](https://github.com/terraform-providers/terraform-provider-aws/issues/7982))
* resource/aws_route53_zone_association: Properly trigger resource recreation on all updates ([#7966](https://github.com/terraform-providers/terraform-provider-aws/issues/7966))

## 2.2.0 (March 15, 2019)

FEATURES:
Expand Down
4 changes: 2 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ lint:
@golangci-lint run ./$(PKG_NAME)

tools:
GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell
GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
GO111MODULE=on go install github.com/client9/misspell/cmd/misspell
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
Expand Down
146 changes: 145 additions & 1 deletion aws/cloudfront_distribution_configuration_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func expandDistributionConfig(d *schema.ResourceData) *cloudfront.DistributionCo
if v, ok := d.GetOk("viewer_certificate"); ok {
distributionConfig.ViewerCertificate = expandViewerCertificate(v.([]interface{})[0].(map[string]interface{}))
}

if v, ok := d.GetOk("origin_group"); ok {
distributionConfig.OriginGroups = expandOriginGroups(v.(*schema.Set))
}
return distributionConfig
}

Expand Down Expand Up @@ -151,6 +153,12 @@ func flattenDistributionConfig(d *schema.ResourceData, distributionConfig *cloud
return err
}
}
if *distributionConfig.OriginGroups.Quantity > 0 {
err = d.Set("origin_group", flattenOriginGroups(distributionConfig.OriginGroups))
if err != nil {
return err
}
}

return nil
}
Expand Down Expand Up @@ -595,6 +603,104 @@ func flattenOrigin(or *cloudfront.Origin) map[string]interface{} {
return m
}

func expandOriginGroups(s *schema.Set) *cloudfront.OriginGroups {
qty := 0
items := []*cloudfront.OriginGroup{}
for _, v := range s.List() {
items = append(items, expandOriginGroup(v.(map[string]interface{})))
qty++
}
return &cloudfront.OriginGroups{
Quantity: aws.Int64(int64(qty)),
Items: items,
}
}

func flattenOriginGroups(ogs *cloudfront.OriginGroups) *schema.Set {
s := []interface{}{}
for _, v := range ogs.Items {
s = append(s, flattenOriginGroup(v))
}
return schema.NewSet(originGroupHash, s)
}

func expandOriginGroup(m map[string]interface{}) *cloudfront.OriginGroup {
failoverCriteria := m["failover_criteria"].([]interface{})[0].(map[string]interface{})
members := m["member"].([]interface{})
originGroup := &cloudfront.OriginGroup{
Id: aws.String(m["origin_id"].(string)),
FailoverCriteria: expandOriginGroupFailoverCriteria(failoverCriteria),
Members: expandMembers(members),
}
return originGroup
}

func flattenOriginGroup(og *cloudfront.OriginGroup) map[string]interface{} {
m := make(map[string]interface{})
m["origin_id"] = *og.Id
if og.FailoverCriteria != nil {
m["failover_criteria"] = flattenOriginGroupFailoverCriteria(og.FailoverCriteria)
}
if og.Members != nil {
m["member"] = flattenOriginGroupMembers(og.Members)
}
return m
}

func expandOriginGroupFailoverCriteria(m map[string]interface{}) *cloudfront.OriginGroupFailoverCriteria {
failoverCriteria := &cloudfront.OriginGroupFailoverCriteria{}
if v, ok := m["status_codes"]; ok {
codes := []*int64{}
for _, code := range v.(*schema.Set).List() {
codes = append(codes, aws.Int64(int64(code.(int))))
}
failoverCriteria.StatusCodes = &cloudfront.StatusCodes{
Items: codes,
Quantity: aws.Int64(int64(len(codes))),
}
}
return failoverCriteria
}

func flattenOriginGroupFailoverCriteria(ogfc *cloudfront.OriginGroupFailoverCriteria) []interface{} {
m := make(map[string]interface{})
if ogfc.StatusCodes.Items != nil {
l := []interface{}{}
for _, i := range ogfc.StatusCodes.Items {
l = append(l, int(*i))
}
m["status_codes"] = schema.NewSet(schema.HashInt, l)
}
return []interface{}{m}
}

func expandMembers(l []interface{}) *cloudfront.OriginGroupMembers {
qty := 0
items := []*cloudfront.OriginGroupMember{}
for _, m := range l {
ogm := &cloudfront.OriginGroupMember{
OriginId: aws.String(m.(map[string]interface{})["origin_id"].(string)),
}
items = append(items, ogm)
qty++
}
return &cloudfront.OriginGroupMembers{
Quantity: aws.Int64(int64(qty)),
Items: items,
}
}

func flattenOriginGroupMembers(ogm *cloudfront.OriginGroupMembers) []interface{} {
s := []interface{}{}
for _, i := range ogm.Items {
m := map[string]interface{}{
"origin_id": *i.OriginId,
}
s = append(s, m)
}
return s
}

// Assemble the hash for the aws_cloudfront_distribution origin
// TypeSet attribute.
func originHash(v interface{}) int {
Expand All @@ -621,6 +727,44 @@ func originHash(v interface{}) int {
return hashcode.String(buf.String())
}

// Assemble the hash for the aws_cloudfront_distribution origin group
// TypeSet attribute.
func originGroupHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["origin_id"].(string)))
if v, ok := m["failover_criteria"]; ok {
if l := v.([]interface{}); len(l) > 0 {
buf.WriteString(fmt.Sprintf("%d-", failoverCriteriaHash(l[0])))
}
}
if v, ok := m["member"]; ok {
if members := v.([]interface{}); len(members) > 0 {
for _, member := range members {
buf.WriteString(fmt.Sprintf("%d-", memberHash(member)))
}
}
}
return hashcode.String(buf.String())
}

func memberHash(v interface{}) int {
var buf bytes.Buffer
buf.WriteString(fmt.Sprintf("%s-", v.(map[string]interface{})["origin_id"]))
return hashcode.String(buf.String())
}

func failoverCriteriaHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
if v, ok := m["status_codes"]; ok {
for _, w := range v.(*schema.Set).List() {
buf.WriteString(fmt.Sprintf("%d-", w))
}
}
return hashcode.String(buf.String())
}

func expandCustomHeaders(s *schema.Set) *cloudfront.CustomHeaders {
qty := 0
items := []*cloudfront.OriginCustomHeader{}
Expand Down
73 changes: 73 additions & 0 deletions aws/cloudfront_distribution_configuration_structure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,32 @@ func multiOriginConf() *schema.Set {
return schema.NewSet(originHash, []interface{}{originWithCustomConf(), originWithS3Conf()})
}

func originGroupMembers() []interface{} {
return []interface{}{map[string]interface{}{
"origin_id": "S3origin",
}, map[string]interface{}{
"origin_id": "S3failover",
}}
}

func failoverStatusCodes() map[string]interface{} {
return map[string]interface{}{
"status_codes": schema.NewSet(schema.HashInt, []interface{}{503, 504}),
}
}

func originGroupConf() map[string]interface{} {
return map[string]interface{}{
"origin_id": "groupS3",
"failover_criteria": []interface{}{failoverStatusCodes()},
"member": originGroupMembers(),
}
}

func originGroupsConf() *schema.Set {
return schema.NewSet(originGroupHash, []interface{}{originGroupConf()})
}

func geoRestrictionWhitelistConf() map[string]interface{} {
return map[string]interface{}{
"restriction_type": "whitelist",
Expand Down Expand Up @@ -540,6 +566,53 @@ func TestCloudFrontStructure_flattenOrigins(t *testing.T) {
}
}

func TestCloudFrontStructure_expandOriginGroups(t *testing.T) {
in := originGroupsConf()
groups := expandOriginGroups(in)

if *groups.Quantity != 1 {
t.Fatalf("Expected origin group quantity to be %v, got %v", 1, *groups.Quantity)
}
originGroup := groups.Items[0]
if *originGroup.Id != "groupS3" {
t.Fatalf("Expected origin group id to be %v, got %v", "groupS3", *originGroup.Id)
}
if *originGroup.FailoverCriteria.StatusCodes.Quantity != 2 {
t.Fatalf("Expected 2 origin group status codes, got %v", *originGroup.FailoverCriteria.StatusCodes.Quantity)
}
statusCodes := originGroup.FailoverCriteria.StatusCodes.Items
for _, code := range statusCodes {
if *code != 503 && *code != 504 {
t.Fatalf("Expected origin group failover status code to either 503 or 504 got %v", *code)
}
}

if *originGroup.Members.Quantity > 2 {
t.Fatalf("Expected origin group member quantity to be 2, got %v", *originGroup.Members.Quantity)
}

members := originGroup.Members.Items
if len(members) > 2 {
t.Fatalf("Expected 2 origin group members, got %v", len(members))
}
for _, member := range members {
if *member.OriginId != "S3failover" && *member.OriginId != "S3origin" {
t.Fatalf("Expected origin group member to either S3failover or s3origin got %v", *member.OriginId)
}
}
}

func TestCloudFrontStructure_flattenOriginGroups(t *testing.T) {
in := originGroupsConf()
groups := expandOriginGroups(in)
out := flattenOriginGroups(groups)
diff := in.Difference(out)

if len(diff.List()) > 0 {
t.Fatalf("Expected out to be %v, got %v, diff: %v", in, out, diff)
}
}

func TestCloudFrontStructure_expandOrigin(t *testing.T) {
data := originWithCustomConf()
or := expandOrigin(data)
Expand Down
9 changes: 6 additions & 3 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,18 @@ type Config struct {
EfsEndpoint string
EsEndpoint string
ElbEndpoint string
FirehoseEndpoint string
IamEndpoint string
KinesisEndpoint string
KinesisAnalyticsEndpoint string
KmsEndpoint string
LambdaEndpoint string
RdsEndpoint string
RedshiftEndpoint string
R53Endpoint string
S3Endpoint string
S3ControlEndpoint string
SesEndpoint string
SnsEndpoint string
SqsEndpoint string
StsEndpoint string
Expand Down Expand Up @@ -404,7 +407,7 @@ func (c *Config) Client() (interface{}, error) {
elbv2conn: elbv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.ElbEndpoint)})),
emrconn: emr.New(sess),
esconn: elasticsearch.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.EsEndpoint)})),
firehoseconn: firehose.New(sess),
firehoseconn: firehose.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.FirehoseEndpoint)})),
fmsconn: fms.New(sess),
fsxconn: fsx.New(sess),
gameliftconn: gamelift.New(sess),
Expand Down Expand Up @@ -441,7 +444,7 @@ func (c *Config) Client() (interface{}, error) {
r53conn: route53.New(sess.Copy(&aws.Config{Region: aws.String("us-east-1"), Endpoint: aws.String(c.R53Endpoint)})),
ramconn: ram.New(sess),
rdsconn: rds.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.RdsEndpoint)})),
redshiftconn: redshift.New(sess),
redshiftconn: redshift.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.RedshiftEndpoint)})),
region: c.Region,
resourcegroupsconn: resourcegroups.New(sess),
route53resolverconn: route53resolver.New(sess),
Expand All @@ -453,7 +456,7 @@ func (c *Config) Client() (interface{}, error) {
secretsmanagerconn: secretsmanager.New(sess),
securityhubconn: securityhub.New(sess),
serverlessapplicationrepositoryconn: serverlessapplicationrepository.New(sess),
sesConn: ses.New(sess),
sesConn: ses.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.SesEndpoint)})),
sfnconn: sfn.New(sess),
shieldconn: shield.New(sess),
simpledbconn: simpledb.New(sess),
Expand Down
Loading

0 comments on commit 4ee8af3

Please sign in to comment.